fix: debug data generation crashes on universes with delisted instruments - #1463
Open
chrisbatso wants to merge 1 commit into
Open
fix: debug data generation crashes on universes with delisted instruments#1463chrisbatso wants to merge 1 commit into
chrisbatso wants to merge 1 commit into
Conversation
…afe) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
chrisbatso please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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.
Problem
rdagent/scenarios/qlib/experiment/factor_data_template/generate.pybuilds the debug slice by taking the first 100 instruments of the full-history panel and then.loc-ing them inside the 2018–2019 window:Any instrument that stopped trading before 2018 (delisted, acquired, bankrupt) is absent from the 2018–2019 frame, so the lookup raises:
With the stock cn_data bundle this happens to work because that universe contains only surviving instruments — which is itself worth noting for a quant framework: the data template implicitly assumes a survivorship-biased universe. On any point-in-time bundle that includes dead securities (the kind of data needed for unbiased backtests), data preparation crashes before the first loop.
Fix
Select the 100 debug instruments from the debug window itself, so only instruments that actually trade in 2018–2019 are kept. Behavior on cn_data is unchanged (same instruments end up selected); universes with delisted names now work.
Testing
Reproduced with a custom survivorship-bias-free S&P 500 bundle (876 point-in-time securities, 215 of which delist inside the sample):
generate.pycrashed with the KeyError above; with this patch it completes, and fullfin_factorR&D loops run end-to-end on both that bundle and the code path used by cn_data.🤖 Generated with Claude Code
📚 Documentation preview 📚: https://RDAgent--1463.org.readthedocs.build/en/1463/