SPB Git

Repository Public Research preview

09_export_panels.py 802 B 18 lines python

1"""Save the exact estimation panels used by the C++ randomisation programs (data/derived/perm_inputs)."""2import importlib34from config import DER5from sample import daily_panel, winsor67OUT = DER / "perm_inputs"8OUT.mkdir(exist_ok=True)9keep = ["ccy", "date", "F", "u_pol", "u_phy", "r_brent", "d_vix", "r_usd", "d_y2", "d_cr25", "d_cr10", "d_bf10", "d_atm"]10for t in ["1M", "3M", "1Y"]:11    p = winsor(daily_panel(t), ["d_cr25", "d_cr10", "d_bf10", "d_atm"])12    p[keep].to_parquet(OUT / f"daily_{t}.parquet", index=False)13m = importlib.import_module("05_monthly")14d = m.monthly_panel()15for c in ["d_cr25", "d_cr10"]:16    lo, hi = d[c].quantile([.005, .995]); d[c] = d[c].clip(lo, hi)17d[["ccy", "date", "F", "d_cr25", "d_cr10"] + m.SHOCKS + m.CTL].to_parquet(OUT / "monthly_1M.parquet", index=False)18
Files main
Menu

Theme