Repository Public Research preview
1"""Generate every table and figure of the paper, plus results/numbers.json quoted in the text."""2import importlib3import json45import matplotlib6matplotlib.use("Agg")7import matplotlib.pyplot as plt8import numpy as np9import pandas as pd10from scipy.stats import norm1112import jumpmodel as jm13from config import DER, EXT, FIG, RES, TAB14from panel import fe_ols, stars15from sample import CONTROLS, add_interactions, daily_panel, raw_exposure, winsor1617plt.rcParams.update({"font.size": 9, "font.family": "serif", "axes.spines.top": False, "axes.spines.right": False,18 "figure.dpi": 150, "savefig.bbox": "tight"})19NUM = {}20OUT = ["d_cr25", "d_cr10", "d_skew25", "d_bf10", "d_atm"]21SC = {"d_skew25": 100.0}22LAB = {"d_cr25": r"$\Delta CR^{25}$", "d_cr10": r"$\Delta CR^{10}$", "d_skew25": r"$\Delta (CR^{25}/\sigma^{ATM})\!\times\!100$",23 "d_bf10": r"$\Delta BF^{10}$", "d_atm": r"$\Delta \sigma^{ATM}$", "r_fx": r"$r^{FX}$"}242526def cell(b, t, dec=4, scale=1.0):27 return f"{scale*b:.{dec}f}{stars(t)}"282930def write(name, body):31 (TAB / name).write_text(body)323334# ------------------------------------------------------------------ Table 1: sample35p = winsor(daily_panel("1M"), OUT + ["r_fx"])36e = raw_exposure()37g = p.groupby("ccy").agg(first=("date", "min"), n=("d_cr25", "count"), cr25=("cr25", "mean"), cr10=("cr10", "mean"),38 atm=("atm", "mean"), bf10=("bf10", "mean"))39g = g.join(e[["F_netx_pre", "F_rents_pre", "F_xshare_pre"]]).sort_values("F_netx_pre", ascending=False)40rows = [f"{c} & {r['first']:%Y-%m} & {int(r.n):,} & {r.atm:.2f} & {r.cr25:.2f} & {r.cr10:.2f} & {r.bf10:.2f} & "41 f"{r.F_netx_pre:.2f} & {r.F_rents_pre:.2f} & {r.F_xshare_pre:.1f} \\\\" for c, r in g.iterrows()]42us = e.loc["USD"]43rows.append(f"\\midrule USD (reference) & & & & & & & {us.F_netx_pre:.2f} & {us.F_rents_pre:.2f} & {us.F_xshare_pre:.1f} \\\\")44write("tab_sample.tex", "\n".join(rows))45NUM.update(n_ccy=int(p.ccy.nunique()),46 sd_dcr25=float(p.d_cr25.std()), sd_dcr10=float(p.d_cr10.std()), sd_dbf10=float(p.d_bf10.std()),47 sd_datm=float(p.d_atm.std()), mean_atm=float(p.atm.mean()), mean_cr25=float(p.cr25.mean()),48 corr_F_cr25=float(np.corrcoef(g.F_netx_pre, g.cr25)[0, 1]),49 corr_netx_rents=float(np.corrcoef(g.F_netx_pre, g.F_rents_pre)[0, 1]))5051# ------------------------------------------------------------------ Table 2: baseline daily52perm = pd.read_csv(RES / "permutation_grid.csv") if (RES / "permutation_grid.csv").exists() else None53cols, fits = OUT + ["r_fx"], {}54for y in cols:55 X = add_interactions(p, ["u_pol", "u_phy"], ("F",), CONTROLS)56 fits[y] = fe_ols(p, y, X)57names = [("u_pol:F", r"Policy news $\times F_i$"), ("u_phy:F", r"Physical news $\times F_i$"),58 ("r_brent:F", r"Brent return $\times F_i$"), ("d_vix:F", r"$\Delta$VIX $\times F_i$"),59 ("r_usd:F", r"Dollar return $\times F_i$"), ("d_y2:F", r"$\Delta y^{2Y}$ $\times F_i$")]60L = [" & " + " & ".join(LAB[y] for y in cols) + r" \\ \midrule"]61for j, (k, lab) in enumerate(names):62 L.append(lab + " & " + " & ".join(cell(fits[y].b[j], fits[y].t()[j], 4, SC.get(y, 1)) for y in cols) + r" \\")63 L.append(" & " + " & ".join(f"({SC.get(y, 1)*fits[y].se()[j]:.4f})" for y in cols) + r" \\")64 if j < 2:65 L.append(r"\quad {\footnotesize DK $t$ / currency $t$} & " + " & ".join(66 f"{{\\footnotesize {fits[y].t('dk')[j]:.2f} / {fits[y].t('unit')[j]:.2f}}}" for y in cols) + r" \\")67if perm is not None:68 q = perm[(perm.panel == "daily_1M")].set_index("y")69 L.append(r"Randomisation $p$ (policy) & " + " & ".join(f"{q.p_perm_t[y]:.2f}" if y in q.index else "--" for y in cols) + r" \\")70L.append(r"\midrule Observations & " + " & ".join(f"{fits[y].n:,}" for y in cols) + r" \\")71L.append(r"Currencies / days & " + " & ".join(f"{fits[y].ni} / {fits[y].nt:,}" for y in cols) + r" \\")72L.append(r"SD of dependent variable & " + " & ".join(f"{SC.get(y, 1)*p[y].std():.3f}" for y in cols) + r" \\")73write("tab_baseline.tex", "\n".join(L))74f = fits["d_cr25"]75NUM.update(n_obs=int(f.n), n_days=int(f.nt), b_pol=float(f.b[0]), se_pol=float(f.se()[0]), t_pol=float(f.t()[0]), b_phy=float(f.b[1]), se_phy=float(f.se()[1]),76 b_pol10=float(fits["d_cr10"].b[0]), se_pol10=float(fits["d_cr10"].se()[0]),77 b_oil_fx=float(fits["r_fx"].b[2]), t_oil_fx=float(fits["r_fx"].t()[2]),78 b_oil_cr=float(f.b[2]), tdk_oil_cr=float(f.t("dk")[2]), b_vix_atm=float(fits["d_atm"].b[3]),79 tdk_vix_atm=float(fits["d_atm"].t("dk")[3]))8081# ------------------------------------------------------------------ Table 3: monthly CPU82M = pd.read_csv(RES / "monthly_cpu.csv")83M = M[M.char == "F"]84sl = {"cpu_shock": "GKRS structural CPU shock", "cpu_instrument": "GKRS event-based instrument",85 "u_cpu_narrow": "AR innovation, GKRS narrow CPU", "u_cpu_broad": "AR innovation, GKRS broad CPU",86 "u_cpu_gavriilidis": "AR innovation, Gavriilidis CPU", "u_cpnews_narrow": "AR innovation, climate policy news"}87L = [" & " + " & ".join(LAB[y] for y in OUT) + r" & Obs. \\ \midrule"]88for s, lab in sl.items():89 q = M[M.shock == s].set_index("y")90 L.append(lab + " & " + " & ".join(cell(q.b[y], q.b[y] / q.se[y], 3, SC.get(y, 1)) for y in OUT) + f" & {int(q.n['d_cr25']):,}" + r" \\")91 L.append(" & " + " & ".join(f"({SC.get(y, 1)*q.se[y]:.3f})" for y in OUT) + r" & \\")92 L.append(r"\quad {\footnotesize DK $t$} & " + " & ".join(f"{{\\footnotesize {q.t_dk[y]:.2f}}}" for y in OUT) + r" & \\")93write("tab_monthly.tex", "\n".join(L))94q = M[(M.shock == "cpu_shock") & (M.y == "d_cr25")].iloc[0]95mod = importlib.import_module("05_monthly")96md = mod.monthly_panel()97_m = md.dropna(subset=["cpu_shock"]).copy()98_lo, _hi = md.d_cr25.quantile([.005, .995])99NUM.update(b_cpu=float(q.b), se_cpu=float(q.se), tdk_cpu=float(q.t_dk), sd_dcr25_m=float(_m.d_cr25.clip(_lo, _hi).std()), n_m=int(q.n))100101# ------------------------------------------------------------------ Table 4: robustness102R = pd.read_csv(RES / "robustness_daily.csv")103R = R[(R.shock.isin(["u_pol", "u_big", "u_small"]))]104nice = {"tenor=1M": "Tenor 1M (baseline)", "tenor=3M": "Tenor 3M", "tenor=1Y": "Tenor 1Y",105 "exposure=F_netx_full": "Net fuel exports/GDP, 2005--21", "exposure=F_rents_pre": "Fossil rents/GDP, 2000--04",106 "exposure=F_rents_full": "Fossil rents/GDP, 2005--21", "exposure=F_xshare_pre": "Fuel share of exports",107 "exposure=F_oilgas_pre": "Oil and gas rents/GDP", "exposure=co2_int_pre": "CO$_2$ intensity of GDP",108 "exposure=top-quartile dummy": "Top-quartile exporter dummy", "sample=G10": "G10 currencies",109 "sample=EM": "Non-G10 currencies", "sample=ex RUB,NOK": "Excluding RUB and NOK",110 "sample=ex 2008-09,2020": "Excluding 2008--09 and 2020", "sample=pre-Paris": "Before 12 Dec 2015",111 "sample=post-Paris": "From 12 Dec 2015", "sample=post-2019": "From 2019",112 "add own d_atm, r_fx": "Adding own $\\Delta\\sigma^{ATM}$ and spot return", "big vs small shocks": "Largest 5\\% of shocks only"}113L = []114for tag, lab in nice.items():115 q = R[(R.tag == tag) & (R.y == "d_cr25")]116 if tag == "big vs small shocks":117 q = q[q.shock == "u_big"]118 if q.empty:119 continue120 r = q.iloc[0]121 extra = ""122 if tag.startswith("tenor"):123 r10 = R[(R.tag == tag) & (R.y == "d_cr10")].iloc[0]124 extra = f"{cell(r10.b, r10.t)} & ({r10.se:.4f})"125 else:126 extra = " & "127 L.append(f"{lab} & {cell(r.b, r.t)} & ({r.se:.4f}) & {r.t_dk:.2f} & {extra} & {int(r.n):,} & {int(r.N)} \\\\")128write("tab_robust.tex", "\n".join(L))129130# ------------------------------------------------------------------ Table 5: S&P 500131S = pd.read_csv(RES / "spx_and_exploratory.csv")132H = S[(S.block == "H6 SPX weekly") & (S.ctl.fillna("") == "")]133ylab = {"dl_LJV": r"$\Delta\log$ left jump variation (Q)", "dl_RJV": r"$\Delta\log$ right jump variation (Q)",134 "dl_LJI": r"$\Delta\log$ left jump intensity (Q)", "d_fear": r"$\Delta$ fear index ($\times100$)",135 "dl_atm_vol": r"$\Delta\log$ ATM volatility", "dl_vix": r"$\Delta\log$ VIX", "d_skew": r"$\Delta$ CBOE SKEW",136 "r_spx": "S\\&P 500 return (\\%)", "rsemi": "Realised down-minus-up semi-vol.", "f_rsemi": "\\quad next week",137 "f_rsdn4": "Realised downside vol., next 4 weeks"}138xs = ["u_pol", "u_phy", "bua_tri", "bua_pri", "u_agg"]139L = []140for y, lab in ylab.items():141 q = H[H.y == y].set_index("x")142 L.append(lab + " & " + " & ".join(cell(q.b[x], q.t[x], 3) for x in xs) + f" & {q.sd_y.iloc[0]:.3f} & {int(q.n.iloc[0])}" + r" \\")143 L.append(" & " + " & ".join(f"({q.se[x]:.3f})" for x in xs) + r" & & \\")144write("tab_spx.tex", "\n".join(L))145q = H[(H.y == "dl_LJV") & (H.x == "u_pol")].iloc[0]146NUM.update(spx_b=float(q.b), spx_se=float(q.se), spx_sd=float(q.sd_y), spx_n=int(q.n),147 spx_share_sig=float((H.t.abs() > 1.96).mean()), spx_ntests=int(len(H)))148149# ------------------------------------------------------------------ Table 6: exploratory150A = S[S.block.str.startswith("Expl")]151al = {"u_CPU_pos_US": "Uncertainty about stronger policy $\\times F_i$", "u_CPU_neg_US": "Uncertainty about weaker policy $\\times F_i$",152 "u_CPU_US": "Basaglia et al. total CPU $\\times F_i$", "u_cpsent": "Climate policy sentiment $\\times F_i$"}153L = [r"\multicolumn{5}{l}{\textit{A. Directional climate policy uncertainty, monthly, 1M options}} \\"]154for x, lab in al.items():155 q = A[A.x == x].set_index("y")156 ys = ["d_cr25", "d_cr10", "d_skew25", "d_atm"]157 L.append(lab + " & " + " & ".join(cell(q.b[y], q.t[y], 3, SC.get(y, 1)) for y in ys) + r" \\")158 L.append(" & " + " & ".join(f"({SC.get(y, 1)*q.se[y]:.3f})" for y in ys) + r" \\")159L.append(r"\midrule \multicolumn{5}{l}{\textit{B. Long-dated options, daily, $\Delta CR^{25}$}} \\")160for ten in ["2Y", "5Y"]:161 q = A[A.block == f"Expl B tenor {ten} daily"].set_index("x")162 L.append(f"Tenor {ten}: policy news $\\times F_i$ & {cell(q.b['u_pol:F'], q.t['u_pol:F'])} & ({q.se['u_pol:F']:.4f}) & "163 f"$N={int(q.N.iloc[0])}$ & $n={int(q.n.iloc[0]):,}$ \\\\")164 L.append(f"Tenor {ten}: physical news $\\times F_i$ & {cell(q.b['u_phy:F'], q.t['u_phy:F'])} & ({q.se['u_phy:F']:.4f}) & & \\\\")165write("tab_exploratory.tex", "\n".join(L))166167# ------------------------------------------------------------------ Table 7: what the null rules out168bd = []169SIG = {"1M": None, "3M": None, "1Y": None}170for ten, tau in (("1M", 1 / 12), ("3M", 0.25), ("1Y", 1.0)):171 pp = winsor(daily_panel(ten), OUT)172 X = add_interactions(pp, ["u_pol", "u_phy"], ("F",), CONTROLS)173 f = fe_ols(pp, "d_cr25", X)174 b, se = f.b[0], f.se()[0]175 sig = pp.atm.mean() / 100176 ub = b + 1.645 * se # one-sided 95% upper bound on the H1 coefficient177 row = dict(tenor=ten, b=b, se=se, ub=ub, mde=2.8 * se, sd=pp.d_cr25.std(), sig=sig)178 for x in (0.05, 0.10, 0.20):179 sens = jm.dcr_dlam_exact(sig, 0.02, x, tau) # vol units per unit of annual intensity180 row[f"dlam_{int(x*100)}"] = (ub / 100) / sens * 1e4 # basis points of annual Q-probability181 row[f"mde_{int(x*100)}"] = (2.8 * se / 100) / sens * 1e4182 bd.append(row)183B = pd.DataFrame(bd)184B.to_csv(RES / "bounds.csv", index=False)185L = []186for _, r in B.iterrows():187 L.append(f"{r.tenor} & {r.b:.4f} & {r.se:.4f} & {r.ub:.4f} & {100*r.ub/r.sd:.2f} & {r.mde:.4f} & "188 f"{r.dlam_5:.1f} & {r.dlam_10:.2f} & {r.dlam_20:.2f} \\\\")189write("tab_bounds.tex", "\n".join(L))190b1 = B.iloc[0]191NUM.update(ub_1m=float(b1.ub), ub_pct_sd=float(100 * b1.ub / b1.sd), mde_1m=float(b1.mde), mde_pct_sd=float(100 * b1.mde / b1.sd),192 dlam10_1m=float(b1.dlam_10), dlam10_1y=float(B.iloc[2].dlam_10), dlam5_1m=float(b1.dlam_5), dlam20_1m=float(b1.dlam_20))193# equivalence test (TOST) against a smallest effect of interest of 1% of a daily SD194sesoi = 0.01 * b1.sd195NUM.update(sesoi=float(sesoi), tost_p=float(max(1 - norm.cdf((sesoi - b1.b) / b1.se), 1 - norm.cdf((b1.b + sesoi) / b1.se))))196# monthly bound with Driscoll-Kraay se197se_dk = abs(NUM["b_cpu"] / NUM["tdk_cpu"]); se_m = max(se_dk, NUM["se_cpu"])198ubm = NUM["b_cpu"] + 1.645 * se_m199NUM.update(ub_cpu=float(ubm), dlam10_cpu=float((ubm / 100) / jm.dcr_dlam_exact(b1.sig, 0.02, 0.10, 1 / 12) * 1e4),200 ub_cpu_pct_sd=float(100 * ubm / NUM["sd_dcr25_m"]))201# accuracy of the cumulant approximation202acc = [dict(tau=t, x=x, exact=jm.dcr_dlam_exact(0.11, 0.02, x, t), approx=jm.dcr_dlam_approx(0.11, 0.02, x, t))203 for t in (1 / 12, 0.25, 1.0) for x in (0.02, 0.05, 0.10, 0.20)]204A2 = pd.DataFrame(acc); A2["ratio"] = A2.exact / A2.approx; A2.to_csv(RES / "approximation_accuracy.csv", index=False)205write("tab_approx.tex", "\n".join(f"{r.tau:.3f} & {r.x:.2f} & {r.exact:.4f} & {r.approx:.4f} & {r.ratio:.2f} \\\\" for _, r in A2.iterrows()))206207# ------------------------------------------------------------------ Figures208sh = pd.read_parquet(DER / "daily_shocks.parquet")209ms = pd.read_parquet(DER / "monthly_shocks.parquet")210fig, ax = plt.subplots(2, 1, figsize=(6.5, 4.6), sharex=True)211c = ms.loc["2003-01":"2025-06", ["cpu_index_narrow", "cpu_index_gavriilidis"]]; c.index = c.index.to_timestamp()212ax[0].plot(c.index, c.cpu_index_narrow, lw=1, color="k", label="CPU, Gavriilidis et al. (2026), narrow")213ax[0].plot(c.index, c.cpu_index_gavriilidis, lw=0.9, color="0.4", ls="--", label="CPU, Gavriilidis (2021)")214ax[0].legend(frameon=False, fontsize=7); ax[0].set_ylabel("Index")215mm = sh[["mccc_pol_lvl", "mccc_phy_lvl"]].loc["2003":"2025-06"].resample("ME").mean()216ax[1].plot(mm.index, mm.mccc_pol_lvl, lw=1, color="k", label="MCCC policy/transition topics")217ax[1].plot(mm.index, mm.mccc_phy_lvl, lw=0.9, color="0.4", ls="--", label="MCCC physical topics")218ax[1].legend(frameon=False, fontsize=7); ax[1].set_ylabel("Monthly mean")219for a in ax:220 for d0 in ("2015-12-12", "2017-06-01", "2022-08-16"):221 a.axvline(pd.Timestamp(d0), color="0.8", lw=0.6, ls="--")222fig.savefig(FIG / "fig_climate_indices.pdf"); plt.close(fig)223224# high-minus-low exposure crash-risk spread225pl = daily_panel("1M")226Fm = pl.groupby("ccy").F.first(); hi, lo = Fm[Fm >= Fm.quantile(0.75)].index, Fm[Fm <= Fm.quantile(0.25)].index227sp = (pl[pl.ccy.isin(hi)].groupby("date").cr25.mean() - pl[pl.ccy.isin(lo)].groupby("date").cr25.mean()).resample("ME").mean()228fig, ax = plt.subplots(figsize=(6.5, 2.8))229ax.plot(sp.index, sp.values, color="k", lw=1); ax.axhline(0, color="0.7", lw=0.5)230ax.set_ylabel("Crash-risk spread (vol points)")231ax2 = ax.twinx(); ax2.spines["right"].set_visible(True)232ax2.plot(c.index, np.log(c.cpu_index_narrow), color="0.35", lw=0.9, ls="--"); ax2.set_ylabel("log CPU (dashed)")233fig.savefig(FIG / "fig_spread.pdf"); plt.close(fig)234cm = pd.concat([sp.rename("s"), np.log(c.cpu_index_narrow).resample("ME").last().rename("c")], axis=1).dropna()235NUM.update(spread_mean=float(sp.mean()), corr_spread_cpu_lvl=float(cm.corr().iloc[0, 1]),236 corr_spread_cpu_diff=float(cm.diff().dropna().corr().iloc[0, 1]), hi=list(hi), lo=list(lo))237238Lp = pd.read_csv(RES / "lp_daily.csv")239fig, ax = plt.subplots(1, 2, figsize=(6.5, 2.6), sharey=False)240for a, v, t in zip(ax, ["cr25", "cr10"], [r"$CR^{25}$", r"$CR^{10}$"]):241 q = Lp[Lp.y == v]242 se = np.maximum(q.se_pol, q.se2_pol)243 a.fill_between(q.h, q.b_pol - 1.96 * se, q.b_pol + 1.96 * se, color="0.85")244 a.plot(q.h, q.b_pol, "k-o", ms=2.5, lw=1); a.axhline(0, color="0.5", lw=0.5); a.axvline(-0.5, color="0.7", lw=0.5, ls="--")245 a.set_title(t, fontsize=9); a.set_xlabel("Trading days from the shock")246ax[0].set_ylabel("Cumulative response (vol points)")247fig.savefig(FIG / "fig_lp.pdf"); plt.close(fig)248q = Lp[(Lp.y == "cr25")]249NUM.update(lp_max_b=float(q.b_pol.max()), lp_max_h=int(q.h[q.b_pol.idxmax()]),250 lp_max_t=float((q.b_pol / np.maximum(q.se_pol, q.se2_pol)).max()))251252xs_ = np.linspace(0.03, 0.30, 28)253fig, ax = plt.subplots(figsize=(4.6, 3.0))254for (ten, tau), ls in zip((("1M", 1 / 12), ("1Y", 1.0)), ("-", "--")):255 r = B[B.tenor == ten].iloc[0]256 y = [(r.ub / 100) / jm.dcr_dlam_exact(r.sig, 0.02, x, tau) * 1e4 for x in xs_]257 ax.plot(100 * xs_, y, "k" + ls, lw=1, label=f"{ten} options")258ax.set_yscale("log"); ax.set_xlabel("Depreciation caused by the event (%)")259ax.set_ylabel("Upper bound on intensity response (bp per year)"); ax.legend(frameon=False)260fig.savefig(FIG / "fig_bound.pdf"); plt.close(fig)261262json.dump(NUM, open(RES / "numbers.json", "w"), indent=1)263print(json.dumps(NUM, indent=1))264print(B.round(4).to_string())265266# ------------------------------------------------------------------ LaTeX macros for numbers quoted in the text267ten = daily_panel("1M").sort_values(["ccy", "date"])268sd10 = (ten.groupby("ccy").cr25.shift(-10) - ten.groupby("ccy").cr25.shift(1)).std()269NUM["lp_pct_sd10"] = float(100 * NUM["lp_max_b"] / sd10)270H2 = pd.read_csv(RES / "h2_butterfly.csv").set_index("y")271mac = {272 "Nobs": f"{NUM['n_obs']:,}".replace(",", "{,}"), "Nccy": str(NUM["n_ccy"]), "Ndays": f"{NUM['n_days']:,}".replace(",", "{,}"),273 "bpol": f"{NUM['b_pol']:.4f}", "sepol": f"{NUM['se_pol']:.4f}", "ubpol": f"{NUM['ub_1m']:.4f}", "ubpct": f"{NUM['ub_pct_sd']:.2f}",274 "mdepct": f"{NUM['mde_pct_sd']:.2f}", "dlamten": f"{NUM['dlam10_1m']:.1f}",275 "dlamfive": f"{NUM['dlam5_1m']:.0f}", "dlamtwenty": f"{NUM['dlam20_1m']:.1f}", "boilfx": f"{NUM['b_oil_fx']:.3f}",276 "toilfx": f"{NUM['t_oil_fx']:.1f}", "toilcr": f"{NUM['tdk_oil_cr']:.1f}", "bcpu": f"{NUM['b_cpu']:.4f}", "secpu": f"{NUM['se_cpu']:.4f}",277 "tdkcpu": f"{NUM['tdk_cpu']:.2f}", "ubcpu": f"{NUM['ub_cpu']:.4f}", "ubcpupct": f"{NUM['ub_cpu_pct_sd']:.2f}",278 "dlamcpu": f"{NUM['dlam10_cpu']:.0f}", "spxb": f"{NUM['spx_b']:.3f}", "spxse": f"{NUM['spx_se']:.3f}", "spxsd": f"{NUM['spx_sd']:.2f}",279 "spxntests": str(NUM["spx_ntests"]), "spxsig": f"{100*NUM['spx_share_sig']:.1f}", "lpmaxb": f"{NUM['lp_max_b']:.4f}",280 "lpmaxt": f"{NUM['lp_max_t']:.2f}", "lppct": f"{NUM['lp_pct_sd10']:.2f}", "corrlvl": f"{NUM['corr_spread_cpu_lvl']:.2f}",281 "corrdiff": f"{NUM['corr_spread_cpu_diff']:.2f}", "meancr": f"{NUM['mean_cr25']:.2f}", "meanatm": f"{NUM['mean_atm']:.1f}",282 "corrnetxrents": f"{NUM['corr_netx_rents']:.2f}", "sdcr": f"{NUM['sd_dcr25']:.3f}",283 "bhtwo": f"{H2.b_pol['d_bf10']:.4f}", "thtwo": f"{H2.t_pol['d_bf10']:.2f}",284}285(TAB.parent / "numbers.tex").write_text("\n".join(f"\\newcommand{{\\{k}}}{{{v}}}" for k, v in mac.items()) + "\n")286json.dump(NUM, open(RES / "numbers.json", "w"), indent=1)287print(mac)288cpu = ms.loc["2006-01":"2025-06", "cpu_index_narrow"]; print("CPU max months:", cpu.nlargest(5).round(0).to_dict())289