From 1a17a4c88edecb267f35b16e62070ee2e4b8308b Mon Sep 17 00:00:00 2001 From: Mathias Date: Fri, 26 Jun 2026 12:11:04 +0200 Subject: [PATCH] fix(eval): export block uses next-period RV target (t+1) to match Python probe Go harness reported 0.42 vs Python 0.36 because export used realized_vol[t] (current) while Python probe used realized_vol[t+1] (next-period). Fix adds t+1 < len(df2) guard and uses iloc[t+1] as target. Go now matches Python: 0.3585. Co-Authored-By: Claude Sonnet 4.6 --- train.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/train.py b/train.py index 9d96406..94ce1f1 100644 --- a/train.py +++ b/train.py @@ -232,10 +232,10 @@ def main(): idx = df2.index[year_mask].tolist() Xs, dates, rvs = [], [], [] for t in idx: - if t - WINDOW >= 0: + if t - WINDOW >= 0 and t + 1 < len(df2): Xs.append(fn2[t - WINDOW:t]) dates.append(str(df2["date"].iloc[t].date())) - rvs.append(float(df2["realized_vol"].iloc[t])) + rvs.append(float(df2["realized_vol"].iloc[t + 1])) if not Xs: return [], [], [] Xa = np.stack(Xs)