import numpy as np, sys, datetime as dt sys.stdout.reconfigure(encoding='utf-8',errors='replace') from sklearn.ensemble import HistGradientBoostingClassifier F=np.load("F.npy"); meta=np.load("meta.npy"); y=np.load("lab.npy"); valid=np.load("valid.npy") t=meta[:,0]; hrs=np.load("hrs.npy"); dow=np.load("dow.npy") X=np.column_stack([F,np.sin(2*np.pi*hrs/24),np.cos(2*np.pi*hrs/24),dow]) n=len(y); idx=np.arange(n); H=128 # ---- out-of-sample probabilities via purged walk-forward (never fit on data touching the test window) prob=np.full((n,3),np.nan) bounds=np.linspace(int(n*0.3),n,7).astype(int) fold_of=np.full(n,-1) for f in range(6): te0,te1=bounds[f],bounds[f+1] te=(idx>=te0)&(idx=10: print(f" fold {f}: {int(fm.sum()):4d} trades win {100*wins[fm].mean():5.2f}%") return wr,nT print("=== SEQUENTIAL NON-OVERLAPPING TRADES (26 features + hour/dow, 2:6, h=128) ===") for thr in (0.40,0.45,0.50,0.55,0.60): simulate(thr)