Skip to content

Commit

Permalink
Update regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
JosueNina committed Dec 30, 2024
1 parent b122657 commit f71b075
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class CorrelationLastComputedValueRegressionAlgorithm : QCAlgorithm, IReg
{
private Correlation _correlationPearson;
private decimal _lastCorrelationValue;
private decimal _totalCount;
private decimal _matchingCount;

public override void Initialize()
{
Expand All @@ -44,19 +46,32 @@ public override void Initialize()
throw new RegressionTestException("Correlation indicator was expected to be ready");
}
_lastCorrelationValue = _correlationPearson.Current.Value;
_totalCount = 0;
_matchingCount = 0;
}

public override void OnData(Slice slice)
{
if (_correlationPearson.IsReady)
if (_lastCorrelationValue == _correlationPearson[1].Value)
{
if (_lastCorrelationValue != _correlationPearson[1].Value)
{
throw new RegressionTestException("Mismatch in last computed CorrelationPearson value.");
}
Debug($"CorrelationPearson between BTCUSD and SPY - Current: {_correlationPearson[0].Value}, Previous: {_correlationPearson[1].Value}");
_lastCorrelationValue = _correlationPearson.Current.Value;
_matchingCount++;
}
Debug($"CorrelationPearson between BTCUSD and SPY - Current: {_correlationPearson[0].Value}, Previous: {_correlationPearson[1].Value}");
_lastCorrelationValue = _correlationPearson.Current.Value;
_totalCount++;
}

public override void OnEndOfAlgorithm()
{
if (_totalCount == 0)
{
throw new RegressionTestException("No data points were processed.");
}
if (_totalCount != _matchingCount)
{
throw new RegressionTestException("Mismatch in the last computed CorrelationPearson values.");
}
Debug($"{_totalCount} data points were processed, {_matchingCount} matched the last computed value.");
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Common/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4445,4 +4445,4 @@ private static Symbol ConvertToSymbol(PyObject item, bool dispose)
}
}
}
}
}

0 comments on commit f71b075

Please sign in to comment.