Skip to content

Fix RelativeDailyVolume fallback denominator for intra-day gaps#9630

Merged
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
AlexCatarino:bug-9629-rdv-missing-break
Jul 20, 2026
Merged

Fix RelativeDailyVolume fallback denominator for intra-day gaps#9630
Martin-Molinero merged 1 commit into
QuantConnect:masterfrom
AlexCatarino:bug-9629-rdv-missing-break

Conversation

@AlexCatarino

@AlexCatarino AlexCatarino commented Jul 20, 2026

Copy link
Copy Markdown
Member

Description

Fixes #9629.

RelativeDailyVolume.ComputeNextValue has a fallback path for when the current time-of-day has no exact historical slot in _relativeData (intra-day data gaps — small/mid-cap equities, crypto during low-volume periods, circuit-breaker events). It is meant to use the value of the greatest historical slot that is still <= currentTimeBar, but the loop was missing a break, so it kept overwriting denominator with later slots and ended on the last key of the sorted dictionary.

Example — history at 09:30, 09:44, 16:00, 16:01, a bar arrives at 09:45:

i key > 09:45? denominator
2 16:00 yes [09:44] ← correct
3 16:01 yes [16:00] ← wrong, overwrites

The denominator ended up as cumulative volume through 16:00 instead of 09:44, making the ratio far too small.

Changes

  • Add break; after setting the denominator so the fallback stops at the first slot greater than currentTimeBar, using the greatest slot <= currentTimeBar.
  • Add regression test UsesMostRecentHistoricalSlotForIntradayGap reproducing the gap scenario (asserts 50/200, not 50/300).

Note

The issue also describes a secondary design consideration around day-rollover fill-forward for SMA slots that receive no update on gap days. That is a larger behavioral change (would affect the spy_rdv.txt reference values) and is left out of this PR, which targets the clear-cut, confirmed bug in the issue title. Happy to follow up separately if desired.

The fallback loop that runs when the current time-of-day has no exact
historical slot was missing a break, so it kept overwriting the
denominator with later slots and ended on the last slot of the day
instead of the greatest slot <= the current time. This gave a far too
small ratio for securities with intra-day data gaps.

Add the break and a regression test covering the gap scenario.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Martin-Molinero
Martin-Molinero merged commit f34dbc9 into QuantConnect:master Jul 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RelativeDailyVolume: missing break in fallback loop causes wrong denominator for intra-day gap securities

2 participants