Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Retrieval of Historical Data for Equities with Different Resolutions #8538

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
27 changes: 27 additions & 0 deletions Algorithm/QCAlgorithm.History.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,33 @@ private IEnumerable<SubscriptionDataConfig> GetMatchingSubscriptions(Symbol symb
// since this might be called when creating a security and warming it up
if (configs != null && configs.Count != 0)
{
// Check if resolution is set and not Daily or Hourly for an Equity symbol
if (resolution.HasValue && resolution != Resolution.Daily && resolution != Resolution.Hour && symbol.SecurityType == SecurityType.Equity)
{
// Lookup the subscription configuration data type for the Equity symbol, filtering for Quote tick type
type = SubscriptionManager.LookupSubscriptionConfigDataTypes(SecurityType.Equity, resolution.Value, false).Where(e => e.Item2 == TickType.Quote).FirstOrDefault().Item1;
var entry = MarketHoursDatabase.GetEntry(symbol, new[] { type });

// Create a new SubscriptionDataConfig
var newConfig = new SubscriptionDataConfig(
type,
symbol,
resolution.Value,
entry.DataTimeZone,
entry.ExchangeHours.TimeZone,
UniverseSettings.FillForward,
UniverseSettings.ExtendedMarketHours,
false);

// If no existing configuration for the Quote tick type, add the new config
if (!configs.Any(config => config.TickType == TickType.Quote))
{
configs.Add(newConfig);
}

// Sort the configs in descending order based on tick type
configs = configs.OrderByDescending(config => GetTickTypeOrder(config.SecurityType, config.TickType)).ToList();
}
if (resolution.HasValue
&& (resolution == Resolution.Daily || resolution == Resolution.Hour)
&& symbol.SecurityType == SecurityType.Equity)
Expand Down
Loading