Fall back to backup universe files in live trading when the expected ones are unavailable - #9690
Draft
jhonabreul wants to merge 6 commits into
Draft
Conversation
…n universe file reads
…ected ones are unavailable
11 tasks
…a enumerator factory
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
In live trading, file-based universe selection (option and futures chains, coarse fundamental, ETF constituents) depends on the daily universe file for the previous tradable date being on disk. If the data pipeline hasn't produced that file yet by the time the market is about to open, selection silently doesn't happen.
The change adds a safety net: a backup universe file (
<universe file>.backup), when present, is used as a last resort:LiveCustomDataSubscriptionEnumeratorFactoryowns the fallback (GetUniverseFileBackupSourceAdjustment), evaluated at the same rate-limited cadence as source refreshes and only forLocalFilesources. It is enabled with a new opt-infallBackToBackupUniverseFilesconstructor flag, off by default so custom data and custom universe subscriptions never probe backup files.LiveTradingDataFeed.CreateUniverseSubscriptionenables it for every universe served by the file-based branch: option chains, futures chains, fundamental/coarse and ETF constituents.universe-file-backup-fallback-minutes(new config, default 30) of the next market open, if the expected universe file can't be fetched, the subscription falls back to<file>.backup(logged).Related Issue
N/A
Motivation and Context
The daily chain universe files are written by a data pipeline shortly before the market opens. If a file is late or missing, live algorithms get no chain selection for the day. With this change, a previously generated backup file keeps selection working until the expected file shows up.
Requires Documentation Change
No
How Has This Been Tested?
LiveCustomDataSubscriptionEnumeratorFactoryTests:FallsBackToBackupUniverseFileWhenExpectedSourceIsNotAvailable(fallback fires, checks are rate limited like refreshes, and the expected file is preferred again once it becomes available),DoesNotFallBackToBackupUniverseFileFarFromMarketOpenandDoesNotFallBackToBackupUniverseFileWhenNotConfigured(no availability probing in either case).LiveTradingDataFeedTests.UniverseSelectionFallsBackToBackupUniverseFileCloseToMarketOpen: 8 cases — equity option chain, index option chain, coarse fundamental and ETF constituents universes, each with the expected file available and missing. Selection succeeds from the backup only when the expected file is missing; the backup is never touched when the expected file exists.LiveTradingDataFeedTests.ChainSelectionDoesNotFallBackToBackupUniverseFileFarFromMarketOpen: no backup probing outside the pre-open window (the gating is shared by all universe types).LiveChainSelectioncases, the fullLiveCustomDataSubscriptionEnumeratorFactoryTestsfixture, and the*ImmediateSelection/FundamentalScheduleSelectiontests pass; the new feed-level tests passed repeat runs with no flakiness.FakeDataQueue, test-only shifted engine clock, fabricated GOOG universe files): deployed pre-open with only a backup file on disk, the backup was correctly not probed outside the window, then read on the first refresh inside it — the option filter selected all 2192 contracts from the backup, zero errors.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>