doc headers

This commit is contained in:
Miha Kralj
2026-02-27 07:48:12 -08:00
parent 8a1ba95173
commit 4ab3a7fb53
389 changed files with 6682 additions and 468 deletions
@@ -594,12 +594,12 @@ public sealed class CorrelationValidationTests : IDisposable
{
// Create two series with negative correlation
var indicator = new Correlation(20);
var random = new Random(42);
var random = new GBM(startPrice: 100.0, sigma: 1.0, seed: 42);
for (int i = 0; i < 100; i++)
{
double x = 100.0 + i + (random.NextDouble() - 0.5) * 2;
double y = 200.0 - 0.8 * i + (random.NextDouble() - 0.5) * 2; // Negative relationship
double x = 100.0 + i + Math.Log(random.Next().Close / 100.0) * 2;
double y = 200.0 - 0.8 * i + Math.Log(random.Next().Close / 100.0) * 2; // Negative relationship
indicator.Update(x, y);
}
@@ -611,12 +611,12 @@ public sealed class CorrelationValidationTests : IDisposable
{
// Create two series with weak correlation (lots of noise)
var indicator = new Correlation(20);
var random = new Random(42);
var random = new GBM(startPrice: 100.0, sigma: 1.0, seed: 43);
for (int i = 0; i < 100; i++)
{
double x = 100.0 + i + (random.NextDouble() - 0.5) * 50;
double y = 100.0 + 0.1 * i + (random.NextDouble() - 0.5) * 50; // Weak relationship
double x = 100.0 + i + Math.Log(random.Next().Close / 100.0) * 50;
double y = 100.0 + 0.1 * i + Math.Log(random.Next().Close / 100.0) * 50; // Weak relationship
indicator.Update(x, y);
}
+18 -1
View File
@@ -1,5 +1,22 @@
# CORR: Pearson Correlation Coefficient
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
| **Inputs** | Source (close) |
| **Parameters** | `period` (default 20) |
| **Outputs** | Single series (Correlation) |
| **Output range** | Varies (see docs) |
| **Warmup** | `period` bars |
### TL;DR
- The Pearson Correlation Coefficient measures the linear relationship between two variables, returning a value from -1 (perfect negative correlation...
- Parameterized by `period` (default 20).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Correlation is not causation, but it sure is a hint. The market doesn't care why two instruments move together—only that they do, and whether that relationship will persist long enough for you to profit from it."
The Pearson Correlation Coefficient measures the linear relationship between two variables, returning a value from -1 (perfect negative correlation) to +1 (perfect positive correlation). Zero indicates no linear relationship. This implementation uses running sums for O(1) streaming updates, making it suitable for real-time analysis of price relationships.
@@ -265,4 +282,4 @@ corr.Update(101.0, 51.0, isNew: false); // Recalculates without advancing state
- Pearson, K. (1895). "Notes on regression and inheritance in the case of two parents." *Proceedings of the Royal Society of London*, 58, 240-242.
- TradingView. "ta.correlation() function." *Pine Script Language Reference Manual*.
- Vidyamurthy, G. (2004). "Pairs Trading: Quantitative Methods and Analysis." *Wiley Finance*. Chapter on correlation analysis.
- Embrechts, P., McNeil, A., & Straumann, D. (2002). "Correlation and dependence in risk management: properties and pitfalls." *Risk Management: Value at Risk and Beyond*, Cambridge University Press.
- Embrechts, P., McNeil, A., & Straumann, D. (2002). "Correlation and dependence in risk management: properties and pitfalls." *Risk Management: Value at Risk and Beyond*, Cambridge University Press.