diff --git a/rdagent/scenarios/qlib/experiment/factor_data_template/generate.py b/rdagent/scenarios/qlib/experiment/factor_data_template/generate.py index f05aee5b02..9bf71810e3 100755 --- a/rdagent/scenarios/qlib/experiment/factor_data_template/generate.py +++ b/rdagent/scenarios/qlib/experiment/factor_data_template/generate.py @@ -12,16 +12,14 @@ fields = ["$open", "$close", "$high", "$low", "$volume", "$factor"] -data = ( - ( - D.features(instruments, fields, start_time="2018-01-01", end_time="2019-12-31", freq="day") - .swaplevel() - .sort_index() - ) - .swaplevel() - .loc[data.reset_index()["instrument"].unique()[:100]] - .swaplevel() +# Debug slice: pick instruments that actually trade in the debug window. +# (Taking the first 100 of the full-history panel breaks on universes with +# delisted securities: names dead before 2018 are absent from this window.) +data_debug = ( + D.features(instruments, fields, start_time="2018-01-01", end_time="2019-12-31", freq="day") .sort_index() ) +keep = data_debug.index.get_level_values("instrument").unique()[:100] +data_debug = data_debug.loc[keep].swaplevel().sort_index() -data.to_hdf("./daily_pv_debug.h5", key="data") +data_debug.to_hdf("./daily_pv_debug.h5", key="data")