Skip to content

Commit 99c8b50

Browse files
committed
Minor future chains unit test improvement
1 parent 3cc0148 commit 99c8b50

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

Tests/Algorithm/AlgorithmChainsTests.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,21 +279,30 @@ private static IEnumerable<TestCaseData> GetFutureChainApisTestData()
279279

280280
foreach (var symbol in new[] { futureSymbol, canonicalFutureSymbol, futureOptionSymbol })
281281
{
282-
yield return new TestCaseData(symbol, new DateTime(2013, 10, 06, 23, 0, 0));
283-
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 0, 0, 0));
284-
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 1, 0, 0));
285-
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 2, 0, 0));
286-
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 6, 0, 0));
287-
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 12, 0, 0));
288-
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 16, 0, 0));
282+
foreach (var withFutureAdded in new[] { true, false })
283+
{
284+
yield return new TestCaseData(symbol, new DateTime(2013, 10, 06, 23, 0, 0), withFutureAdded);
285+
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 0, 0, 0), withFutureAdded);
286+
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 1, 0, 0), withFutureAdded);
287+
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 2, 0, 0), withFutureAdded);
288+
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 6, 0, 0), withFutureAdded);
289+
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 12, 0, 0), withFutureAdded);
290+
yield return new TestCaseData(symbol, new DateTime(2013, 10, 07, 16, 0, 0), withFutureAdded);
291+
}
289292
}
290293
}
291294

292295
[TestCaseSource(nameof(GetFutureChainApisTestData))]
293-
public void FuturesChainApisAreConsistent(Symbol symbol, DateTime dateTime)
296+
public void FuturesChainApisAreConsistent(Symbol symbol, DateTime dateTime, bool withFutureAdded)
294297
{
295298
_algorithm.SetDateTime(dateTime.ConvertToUtc(_algorithm.TimeZone));
296299

300+
if (withFutureAdded)
301+
{
302+
// It should work regardless of whether the future is added to the algorithm
303+
_algorithm.AddFuture("ES");
304+
}
305+
297306
var exchange = MarketHoursDatabase.FromDataFolder().GetExchangeHours(symbol.ID.Market, symbol, symbol.SecurityType);
298307
var chainFromAlgorithmApi = _algorithm.FuturesChain(symbol).Select(x => x.Symbol).ToList();
299308
var chainFromChainProviderApi = _futureChainProvider.GetFutureContractList(symbol,

0 commit comments

Comments
 (0)