21 using System.Collections.Generic;
36 private bool _loggedPreviousTradableDate;
61 return GetOptionSymbols(canonicalSymbol, date);
64 IEnumerable<string> entries =
null;
66 foreach (var resolution
in Resolutions)
68 usedResolution = resolution;
69 entries = GetZipEntries(canonicalSymbol, date, usedResolution);
79 if (mhdb.TryGetEntry(canonicalSymbol.ID.Market, canonicalSymbol, canonicalSymbol.SecurityType, out var entry) && !entry.ExchangeHours.IsDateOpen(date))
81 if (!_loggedPreviousTradableDate)
83 _loggedPreviousTradableDate =
true;
84 Log.
Trace($
"BacktestingCacheProvider.GetSymbols(): {date} is not a tradable date for {canonicalSymbol}. When requesting contracts" +
85 $
" for non tradable dates, will return contracts of previous tradable date.");
94 Log.
Debug($
"BacktestingCacheProvider.GetSymbols(): found no source of contracts for {canonicalSymbol} for date {date.ToString(DateFormat.EightCharacter)} for any tick type");
97 return Enumerable.Empty<
Symbol>();
106 private IEnumerable<Symbol> GetOptionSymbols(
Symbol canonicalSymbol, DateTime date)
112 var marketHoursEntry = marketHoursDataBase.GetEntry(canonicalSymbol,
new[] { optionUniverseType });
115 extendedMarketHours:
false, marketHoursEntry.DataTimeZone);
117 previousTradingDate.ConvertToUtc(marketHoursEntry.ExchangeHours.TimeZone),
118 date.ConvertToUtc(marketHoursEntry.ExchangeHours.TimeZone),
122 marketHoursEntry.ExchangeHours,
123 marketHoursEntry.DataTimeZone,
129 var history = historyProvider.GetHistory(
new[] { request }, marketHoursEntry.DataTimeZone).ToList();
131 if (history ==
null || history.Count == 0)
133 return Enumerable.Empty<
Symbol>();
136 return history.GetUniverseData().SelectMany(x => x.Values.Single().Where(x => x.Symbol.SecurityType.IsOption())).Select(x => x.Symbol);
144 return symbol.
ID.
Date.Date < date.Date;
147 private IEnumerable<string> GetZipEntries(
Symbol canonicalSymbol, DateTime date,
Resolution resolution)
149 foreach (var tickType
in DataTypes)