diff --git a/Tests/Algorithm/AlgorithmHistoryTests.cs b/Tests/Algorithm/AlgorithmHistoryTests.cs index 72e9fac5ec4d..e6c615377946 100644 --- a/Tests/Algorithm/AlgorithmHistoryTests.cs +++ b/Tests/Algorithm/AlgorithmHistoryTests.cs @@ -3975,9 +3975,9 @@ public void HistoryRequestUsesSecurityConfigOrExplicitValues(bool explicitParame var start = new DateTime(2013, 10, 28); var algorithm = GetAlgorithm(start); var future = algorithm.AddFuture( - Futures.Indices.SP500EMini, - dataNormalizationMode: DataNormalizationMode.BackwardsRatio, - dataMappingMode: DataMappingMode.LastTradingDay, + Futures.Indices.SP500EMini, + dataNormalizationMode: DataNormalizationMode.BackwardsRatio, + dataMappingMode: DataMappingMode.LastTradingDay, contractDepthOffset: 0, extendedMarketHours: true); @@ -4040,6 +4040,52 @@ public void HistoryRequestUsesSecurityConfigOrExplicitValues(bool explicitParame } } + [TestCase(Resolution.Tick)] + [TestCase(Resolution.Second)] + [TestCase(Resolution.Minute)] + [TestCase(Resolution.Hour)] + [TestCase(Resolution.Daily)] + [TestCase(null)] + public void TickHistoryRequestsForFuturesShouldReturnSameDataCount(Resolution? resolution) + { + var start = new DateTime(2013, 10, 09); + _algorithm = GetAlgorithm(start); + _algorithm.SetEndDate(2013, 10, 10); + + var symbol = Symbol.CreateFuture(Futures.Metals.Gold, Market.COMEX, new DateTime(2013, 10, 29)); + if (resolution == null) + { + _algorithm.AddFutureContract(symbol); + } + else + { + _algorithm.AddFutureContract(symbol, resolution); + } + + var startDate = new DateTime(2013, 10, 08, 9, 30, 0); + var endDate = startDate.AddMinutes(10); + + var history1 = _algorithm.History(symbol, startDate, endDate, Resolution.Tick).ToList(); + var history1Count = history1.Count; + int history2Count = 0; + int history3Count = 0; + using (Py.GIL()) + { + _algorithm.SetPandasConverter(); + var type = typeof(Tick).ToPython(); + + dynamic history2 = _algorithm.History(symbol.ToPython(), startDate, endDate, Resolution.Tick); + history2Count = history2.shape[0].As(); + + dynamic history3 = _algorithm.History(type, symbol.ToPython(), startDate, endDate, Resolution.Tick); + history3Count = history3.shape[0].As(); + } + + Assert.AreEqual(4923, history1Count); + Assert.AreEqual(history1Count, history2Count); + Assert.AreEqual(history1Count, history3Count); + } + private class CustomTestHistoryProvider : SubscriptionDataReaderHistoryProvider { public List HistoryRequests { get; } = new List();