Expected Behavior
All three raise on a period of two, which is what their comment and their message both say.
Actual Behavior
Indicators/Correlation.cs:63:
// Assert the period is greater than two, otherwise the correlation can not be computed
if (period < 2)
{
throw new ArgumentException($"Period parameter for Correlation indicator must be greater than 2 but was {period}");
}
The comment says three, the message says three, the condition admits two. Beta.cs:62 and Covariance.cs:55 are the same three lines. ValueAtRisk.cs:61 states the identical bound and tests period < 3.
A two point window has nothing to measure. Fed ten bars of two series that are not proportional, Correlation at period 2 returns 1 or -1 on every one of its nine readings; the same series at period 3 gives values between -0.40 and 0.33.
period 2: 1 -1 -1 -1 -1 -1 -1 -1 -1
period 3: 0.3273 -0.2402 -0.2402 -0.3974 -0.2895 -0.2895 -0.2895 -0.2895
period 4: 0.3586 0 -0.049 -0.0804 -0.0476 -0.0476 -0.0476
period 10: 0.749
So the value is the sign of the last move, whatever the data is.
Potential Solution
period < 3 in all three, matching the message and ValueAtRisk. Nothing in Tests/, Algorithm.CSharp/ or Algorithm.Python/ constructs any of the three with 2; the smallest literal in use is 3.
Reproducing the Problem
var correlation = new Correlation(Symbols.SPY, Symbols.AAPL, 2);
// feed any two non-proportional series; every reading is 1 or -1
System Information
master, net10.0.
Expected Behavior
All three raise on a period of two, which is what their comment and their message both say.
Actual Behavior
Indicators/Correlation.cs:63:The comment says three, the message says three, the condition admits two.
Beta.cs:62andCovariance.cs:55are the same three lines.ValueAtRisk.cs:61states the identical bound and testsperiod < 3.A two point window has nothing to measure. Fed ten bars of two series that are not proportional,
Correlationat period 2 returns 1 or -1 on every one of its nine readings; the same series at period 3 gives values between -0.40 and 0.33.So the value is the sign of the last move, whatever the data is.
Potential Solution
period < 3in all three, matching the message andValueAtRisk. Nothing inTests/,Algorithm.CSharp/orAlgorithm.Python/constructs any of the three with 2; the smallest literal in use is 3.Reproducing the Problem
System Information
master, net10.0.