Skip to content

Commit

Permalink
Refactor GetMatchingSubscriptions:
Browse files Browse the repository at this point in the history
- Fixed retrieval of minute-resolution quote data for hour-resolution
  equity
- Ensured correct retrieval of data regardless of equity resolution
- Created a unit test to verify functionality
  • Loading branch information
JosueNina committed Jan 15, 2025
1 parent 5accfd6 commit 6eb4040
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 49 deletions.
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

0 comments on commit 6eb4040

Please sign in to comment.