Skip to content

Commit

Permalink
Add an extra period if the TZ are different
Browse files Browse the repository at this point in the history
  • Loading branch information
JosueNina committed Dec 20, 2024
1 parent 83117a5 commit 0cad9a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Algorithm.CSharp/AddBetaIndicatorRegressionAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override void OnOrderEvent(OrderEvent orderEvent)
/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 13;
public int AlgorithmHistoryDataPoints => 11;

/// <summary>
/// Final status of the algorithm
Expand Down
3 changes: 1 addition & 2 deletions Indicators/Beta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ public Beta(string name, Symbol targetSymbol, Symbol referenceSymbol, int period
{
throw new ArgumentException($"Period parameter for Beta indicator must be greater than 2 but was {period}.");
}

WarmUpPeriod = period + 2;
_referenceSymbol = referenceSymbol;
_targetSymbol = targetSymbol;

Expand All @@ -137,6 +135,7 @@ public Beta(string name, Symbol targetSymbol, Symbol referenceSymbol, int period
_targetTimeZone = dataFolder.GetExchangeHours(_targetSymbol.ID.Market, _targetSymbol, _targetSymbol.ID.SecurityType).TimeZone;
_referenceTimeZone = dataFolder.GetExchangeHours(_referenceSymbol.ID.Market, _referenceSymbol, _referenceSymbol.ID.SecurityType).TimeZone;
_isTimezoneDifferent = _targetTimeZone != _referenceTimeZone;
WarmUpPeriod = period + 1 + (_isTimezoneDifferent ? 1 : 0);
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Tests/Algorithm/AlgorithmIndicatorsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ public void IndicatorMultiSymbol(Language language)
}

// the historical indicator current values
Assert.AreEqual(1561, indicatorValues.Current.Count);
Assert.AreEqual(1561, indicatorValues["current"].Count);
Assert.AreEqual(1560, indicatorValues.Current.Count);
Assert.AreEqual(1560, indicatorValues["current"].Count);
Assert.AreEqual(indicatorValues.Current, indicatorValues["current"]);
Assert.IsNull(indicatorValues["NonExisting"]);

Assert.AreEqual(1561, dataCount);
Assert.AreEqual(1560, dataCount);
Assert.IsTrue(indicator.IsReady);
}

Expand Down

0 comments on commit 0cad9a7

Please sign in to comment.