Skip to content

Commit 111fbfa

Browse files
committed
Add test for tick history consistency
1 parent 2504ddb commit 111fbfa

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

Tests/Algorithm/AlgorithmHistoryTests.cs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,9 +3975,9 @@ public void HistoryRequestUsesSecurityConfigOrExplicitValues(bool explicitParame
39753975
var start = new DateTime(2013, 10, 28);
39763976
var algorithm = GetAlgorithm(start);
39773977
var future = algorithm.AddFuture(
3978-
Futures.Indices.SP500EMini,
3979-
dataNormalizationMode: DataNormalizationMode.BackwardsRatio,
3980-
dataMappingMode: DataMappingMode.LastTradingDay,
3978+
Futures.Indices.SP500EMini,
3979+
dataNormalizationMode: DataNormalizationMode.BackwardsRatio,
3980+
dataMappingMode: DataMappingMode.LastTradingDay,
39813981
contractDepthOffset: 0,
39823982
extendedMarketHours: true);
39833983

@@ -4040,6 +4040,41 @@ public void HistoryRequestUsesSecurityConfigOrExplicitValues(bool explicitParame
40404040
}
40414041
}
40424042

4043+
[Test]
4044+
public void TickHistoryRequestsForFuturesShouldReturnSameDataCount()
4045+
{
4046+
var start = new DateTime(2013, 10, 09);
4047+
_algorithm = GetAlgorithm(start);
4048+
_algorithm.SetEndDate(2013, 10, 10);
4049+
4050+
4051+
var symbol = Symbol.CreateFuture(Futures.Metals.Gold, Market.COMEX, new DateTime(2013, 10, 29));
4052+
_algorithm.AddFutureContract(symbol, Resolution.Tick);
4053+
4054+
var startDate = new DateTime(2013, 10, 08, 9, 30, 0);
4055+
var endDate = startDate.AddHours(1);
4056+
4057+
var history1 = _algorithm.History<Tick>(symbol, startDate, endDate, Resolution.Tick).ToList();
4058+
var history1Count = history1.Count;
4059+
int history2Count = 0;
4060+
int history3Count = 0;
4061+
using (Py.GIL())
4062+
{
4063+
_algorithm.SetPandasConverter();
4064+
var type = typeof(Tick).ToPython();
4065+
4066+
dynamic history2 = _algorithm.History(symbol.ToPython(), startDate, endDate, Resolution.Tick);
4067+
history2Count = history2.shape[0].As<int>();
4068+
4069+
dynamic history3 = _algorithm.History(type, symbol.ToPython(), startDate, endDate, Resolution.Tick);
4070+
history3Count = history3.shape[0].As<int>();
4071+
}
4072+
4073+
Assert.Greater(history1Count, 0);
4074+
Assert.AreEqual(history1Count, history2Count);
4075+
Assert.AreEqual(history1Count, history3Count);
4076+
}
4077+
40434078
private class CustomTestHistoryProvider : SubscriptionDataReaderHistoryProvider
40444079
{
40454080
public List<HistoryRequest> HistoryRequests { get; } = new List<HistoryRequest>();

0 commit comments

Comments
 (0)