Fix RelativeDailyVolume fallback denominator for intra-day gaps#9630
Merged
Martin-Molinero merged 1 commit intoJul 20, 2026
Merged
Conversation
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
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #9629.
RelativeDailyVolume.ComputeNextValuehas 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 abreak, so it kept overwritingdenominatorwith 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 at09:45:i> 09:45?denominator[09:44]← correct[16:00]← wrong, overwritesThe denominator ended up as cumulative volume through 16:00 instead of 09:44, making the ratio far too small.
Changes
break;after setting the denominator so the fallback stops at the first slot greater thancurrentTimeBar, using the greatest slot<= currentTimeBar.UsesMostRecentHistoricalSlotForIntradayGapreproducing the gap scenario (asserts50/200, not50/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.txtreference 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.