Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 49 additions & 3 deletions Tests/Algorithm/AlgorithmHistoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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<Tick>(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<int>();

dynamic history3 = _algorithm.History(type, symbol.ToPython(), startDate, endDate, Resolution.Tick);
history3Count = history3.shape[0].As<int>();
}

Assert.AreEqual(4923, history1Count);
Assert.AreEqual(history1Count, history2Count);
Assert.AreEqual(history1Count, history3Count);
}

private class CustomTestHistoryProvider : SubscriptionDataReaderHistoryProvider
{
public List<HistoryRequest> HistoryRequests { get; } = new List<HistoryRequest>();
Expand Down
Loading