From a81fd613943c20871bb8300ae162fb7fc2a74924 Mon Sep 17 00:00:00 2001 From: anor Date: Wed, 11 Mar 2026 05:49:34 +1000 Subject: [PATCH] =?UTF-8?q?feat:=20exp26g=20=E2=80=94=20deep=20analysis=20?= =?UTF-8?q?+=20bugfix:=20training=20=D0=B1=D0=B5=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B7=D0=BD=D0=BE,=20ATR=20=D0=BB=D1=83=D1=87=D1=88?= =?UTF-8?q?=D0=B5=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v1: обнаружил что random weights = trained (баг: zeros init). v2 fix: Xavier random init, корректное сравнение предикторов. Результат: обучение не помогает (Δ = -0.005 to -0.075). ATR и price range бьют модель у 4/5 активов. Co-Authored-By: Claude Opus 4.6 --- experiments/exp26_ablation/formula_deep.py | 436 +++++++++++++++ experiments/exp26_ablation/formula_deep_v2.py | 469 ++++++++++++++++ .../results_exp26g_deep_20260311_054353.json | 512 +++++++++++++++++ ...esults_exp26g_deep_v2_20260311_054857.json | 524 ++++++++++++++++++ 4 files changed, 1941 insertions(+) create mode 100644 experiments/exp26_ablation/formula_deep.py create mode 100644 experiments/exp26_ablation/formula_deep_v2.py create mode 100644 experiments/exp26_ablation/results/results_exp26g_deep_20260311_054353.json create mode 100644 experiments/exp26_ablation/results/results_exp26g_deep_v2_20260311_054857.json diff --git a/experiments/exp26_ablation/formula_deep.py b/experiments/exp26_ablation/formula_deep.py new file mode 100644 index 0000000..74804a8 --- /dev/null +++ b/experiments/exp26_ablation/formula_deep.py @@ -0,0 +1,436 @@ +"""Exp26g: Deep analysis of Remizov formula edge. + +Three tests: + 1. OOS STABILITY: Is r=0.15 stable across time, or concentrated in one period? + 2. RANDOM WEIGHTS: Does untrained network give same edge? (architecture vs learning) + 3. SIMPLER ALTERNATIVES: Does ATR percentile filter give same edge without neural net? +""" +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src")) +sys.path.insert(0, str(Path(__file__).parent.parent)) + +import numpy as np +import torch + +from remizov_trader.core import model as model_mod, signals, risk +from remizov_trader.core.net import EnhancedRemizovNet +from common.dataset import load_or_fetch +from common.metrics import save_results + +TRAIN_RATIO = 0.3 +STOP_SCALE = 0.5 +STOP_MULT = 2.0 +LOOKAHEAD = 30 +SHIFT = 7 + +ASSETS = [ + {"ticker": "BTC-USD", "ws": 64, "K": 3}, + {"ticker": "ETH-USD", "ws": 96, "K": 2}, + {"ticker": "ADA-USD", "ws": 64, "K": 3}, + {"ticker": "DOGE-USD", "ws": 48, "K": 3}, + {"ticker": "SOL-USD", "ws": 96, "K": 3}, +] + + +def _train_model(prices, ws, trained=True, seed=42): + data = signals.prepare_windows(prices, ws, SHIFT) + n_train = max(int(len(data) * TRAIN_RATIO), 20) + torch.manual_seed(seed) + np.random.seed(seed) + mdl = EnhancedRemizovNet(grid_size=ws, n_steps=20, total_time=0.5, + dx=1.0 / ws, use_sde=True) + if trained: + model_mod.train(mdl, + np.array([d["norm_input"] for d in data[:n_train]]), + np.array([d["norm_target"] for d in data[:n_train]]), + 200, 0.003) + return mdl, data, n_train + + +def _get_predictions(prices, mdl, data, n_train, ws, K): + """Get pred_amp_atr and actual_amp_atr for test data.""" + test_data = data[n_train:] + rows = [] + for d in test_data: + idx = d["price_idx"] + if idx + LOOKAHEAD >= len(prices) or idx < ws + K + 1: + continue + w = prices[idx - ws - K: idx - K].copy() + mu, std = w.mean(), w.std() + if std < 1e-10: + continue + pred = model_mod.predict(mdl, (w - mu) / std) + pred_new = pred[-SHIFT:] + pred_dir = signals.get_direction(pred_new, K) + if pred_dir is None: + continue + pred_denorm = pred_new * std + mu + pred_amp = float(np.max(pred_denorm) - np.min(pred_denorm)) + atr = risk.compute_atr(prices, idx) + if atr <= 0: + continue + future_end = min(idx + SHIFT, len(prices)) + future = prices[idx:future_end] + if len(future) < 2: + continue + actual_amp = float(np.max(future) - np.min(future)) + rows.append({ + "idx": idx, "pred_amp_atr": pred_amp / atr, + "actual_amp_atr": actual_amp / atr, "atr": atr, + }) + return rows + + +def _corr(a, b): + with np.errstate(invalid="ignore"): + r = np.corrcoef(a, b)[0, 1] + return 0 if np.isnan(r) else float(r) + + +# ═══════════════════════════════════════════════════════════════ +# TEST 1: OOS STABILITY — Rolling window correlation +# ═══════════════════════════════════════════════════════════════ +def test_stability(prices, ws, K): + """Split test period into chunks, compute r per chunk.""" + mdl, data, n_train = _train_model(prices, ws) + rows = _get_predictions(prices, mdl, data, n_train, ws, K) + if len(rows) < 40: + return {} + + n = len(rows) + # Split into 4 quarters + chunk_size = n // 4 + quarters = [] + for i in range(4): + start = i * chunk_size + end = (i + 1) * chunk_size if i < 3 else n + chunk = rows[start:end] + pred_a = np.array([r["pred_amp_atr"] for r in chunk]) + actual_a = np.array([r["actual_amp_atr"] for r in chunk]) + r = _corr(pred_a, actual_a) + quarters.append({ + "quarter": f"Q{i+1}", + "r": round(r, 3), + "n": len(chunk), + "idx_range": f"{chunk[0]['idx']}-{chunk[-1]['idx']}", + }) + + # Rolling window (window = n//5, step = n//10) + win = max(n // 5, 30) + step = max(n // 10, 15) + rolling = [] + for start in range(0, n - win, step): + chunk = rows[start:start + win] + pred_a = np.array([r["pred_amp_atr"] for r in chunk]) + actual_a = np.array([r["actual_amp_atr"] for r in chunk]) + r = _corr(pred_a, actual_a) + rolling.append(round(r, 3)) + + # Overall + all_pred = np.array([r["pred_amp_atr"] for r in rows]) + all_actual = np.array([r["actual_amp_atr"] for r in rows]) + r_all = _corr(all_pred, all_actual) + + return { + "r_overall": round(r_all, 3), + "quarters": quarters, + "rolling_r": rolling, + "rolling_mean": round(float(np.mean(rolling)), 3), + "rolling_std": round(float(np.std(rolling)), 3), + "rolling_min": round(float(np.min(rolling)), 3), + "rolling_max": round(float(np.max(rolling)), 3), + "pct_positive": round(float(np.mean(np.array(rolling) > 0) * 100), 1), + "n": n, + } + + +# ═══════════════════════════════════════════════════════════════ +# TEST 2: RANDOM WEIGHTS — Untrained vs Trained network +# ═══════════════════════════════════════════════════════════════ +def test_random_weights(prices, ws, K): + """Compare trained model vs untrained (random weights) vs multiple random seeds.""" + # Trained model + mdl_trained, data, n_train = _train_model(prices, ws, trained=True) + rows_trained = _get_predictions(prices, mdl_trained, data, n_train, ws, K) + if len(rows_trained) < 20: + return {} + pred_t = np.array([r["pred_amp_atr"] for r in rows_trained]) + actual_t = np.array([r["actual_amp_atr"] for r in rows_trained]) + r_trained = _corr(pred_t, actual_t) + + # Untrained model (random weights, seed=42) + mdl_random, _, _ = _train_model(prices, ws, trained=False, seed=42) + rows_random = _get_predictions(prices, mdl_random, data, n_train, ws, K) + if rows_random: + pred_r = np.array([r["pred_amp_atr"] for r in rows_random]) + actual_r = np.array([r["actual_amp_atr"] for r in rows_random]) + r_untrained = _corr(pred_r, actual_r) + else: + r_untrained = 0 + + # Multiple random seeds (untrained) + random_rs = [] + for seed in range(10): + mdl_rnd, _, _ = _train_model(prices, ws, trained=False, seed=seed * 7 + 13) + rows_rnd = _get_predictions(prices, mdl_rnd, data, n_train, ws, K) + if rows_rnd: + p = np.array([r["pred_amp_atr"] for r in rows_rnd]) + a = np.array([r["actual_amp_atr"] for r in rows_rnd]) + random_rs.append(_corr(p, a)) + + # Partially trained (50 epochs instead of 200) + torch.manual_seed(42) + np.random.seed(42) + mdl_partial = EnhancedRemizovNet(grid_size=ws, n_steps=20, total_time=0.5, + dx=1.0 / ws, use_sde=True) + model_mod.train(mdl_partial, + np.array([d["norm_input"] for d in data[:n_train]]), + np.array([d["norm_target"] for d in data[:n_train]]), + 50, 0.003) + rows_partial = _get_predictions(prices, mdl_partial, data, n_train, ws, K) + if rows_partial: + p = np.array([r["pred_amp_atr"] for r in rows_partial]) + a = np.array([r["actual_amp_atr"] for r in rows_partial]) + r_partial = _corr(p, a) + else: + r_partial = 0 + + return { + "r_trained": round(r_trained, 3), + "r_untrained": round(r_untrained, 3), + "r_partial_50ep": round(r_partial, 3), + "random_seeds_mean": round(float(np.mean(random_rs)), 3) if random_rs else 0, + "random_seeds_std": round(float(np.std(random_rs)), 3) if random_rs else 0, + "random_seeds_max": round(float(np.max(random_rs)), 3) if random_rs else 0, + "training_adds_value": r_trained > (np.mean(random_rs) + np.std(random_rs)) if random_rs else False, + "n_trained": len(rows_trained), + "n_untrained": len(rows_random) if rows_random else 0, + } + + +# ═══════════════════════════════════════════════════════════════ +# TEST 3: SIMPLER ALTERNATIVES — ATR percentile vs neural net +# ═══════════════════════════════════════════════════════════════ +def test_simpler(prices, ws, K): + """Compare Remizov amplitude prediction vs simple ATR-based alternatives.""" + mdl, data, n_train = _train_model(prices, ws) + rows = _get_predictions(prices, mdl, data, n_train, ws, K) + if len(rows) < 40: + return {} + + # For each signal point, compute alternative "amplitude predictors" + model_preds = [] + atr_preds = [] # raw ATR + atr_pct_preds = [] # ATR percentile (rank in recent history) + range_preds = [] # recent price range + vol_preds = [] # recent returns volatility + actuals = [] + + for r in rows: + idx = r["idx"] + atr = r["atr"] + + # ATR percentile: where does current ATR rank in last 100 ATRs? + atrs_hist = [] + for j in range(max(14, idx - 100), idx): + a = risk.compute_atr(prices, j) + if a > 0: + atrs_hist.append(a) + if len(atrs_hist) < 10: + continue + atr_pct = sum(1 for a in atrs_hist if a <= atr) / len(atrs_hist) + + # Recent range (last ws bars) + recent = prices[max(0, idx - ws):idx] + recent_range = (np.max(recent) - np.min(recent)) / np.mean(recent) if len(recent) > 1 else 0 + + # Recent returns volatility + if len(recent) > 2: + returns = np.diff(recent) / recent[:-1] + ret_vol = float(np.std(returns)) + else: + ret_vol = 0 + + model_preds.append(r["pred_amp_atr"]) + atr_preds.append(atr) + atr_pct_preds.append(atr_pct) + range_preds.append(recent_range) + vol_preds.append(ret_vol) + actuals.append(r["actual_amp_atr"]) + + model_a = np.array(model_preds) + atr_a = np.array(atr_preds) + atr_pct_a = np.array(atr_pct_preds) + range_a = np.array(range_preds) + vol_a = np.array(vol_preds) + actual_a = np.array(actuals) + + # Correlations with actual amplitude + r_model = _corr(model_a, actual_a) + r_atr = _corr(atr_a, actual_a) + r_atr_pct = _corr(atr_pct_a, actual_a) + r_range = _corr(range_a, actual_a) + r_vol = _corr(vol_a, actual_a) + + # Q4/Q1 ratio for each predictor + def q4q1(pred, actual): + pcts = np.percentile(pred, [25, 75]) + q1 = actual[pred <= pcts[0]] + q4 = actual[pred >= pcts[1]] + if len(q1) == 0 or np.mean(q1) == 0: + return 0 + return float(np.mean(q4) / np.mean(q1)) + + # Combined: model + ATR percentile + combined = model_a * atr_pct_a + r_combined = _corr(combined, actual_a) + + results = { + "predictors": [ + {"name": "Remizov model", "r": round(r_model, 3), + "q4q1": round(q4q1(model_a, actual_a), 2)}, + {"name": "Raw ATR", "r": round(r_atr, 3), + "q4q1": round(q4q1(atr_a, actual_a), 2)}, + {"name": "ATR percentile", "r": round(r_atr_pct, 3), + "q4q1": round(q4q1(atr_pct_a, actual_a), 2)}, + {"name": "Price range(ws)", "r": round(r_range, 3), + "q4q1": round(q4q1(range_a, actual_a), 2)}, + {"name": "Returns vol", "r": round(r_vol, 3), + "q4q1": round(q4q1(vol_a, actual_a), 2)}, + {"name": "Model×ATR_pct", "r": round(r_combined, 3), + "q4q1": round(q4q1(combined, actual_a), 2)}, + ], + "model_beats_all_simple": r_model > max(r_atr, r_atr_pct, r_range, r_vol), + "best_simple": max( + [("ATR", r_atr), ("ATR_pct", r_atr_pct), + ("range", r_range), ("vol", r_vol)], + key=lambda x: x[1]), + "n": len(model_preds), + } + return results + + +def main(): + results_dir = Path(__file__).parent / "results" + print("=" * 80) + print("EXP26g: DEEP ANALYSIS OF REMIZOV FORMULA EDGE") + print("=" * 80) + print("Tests: 1.OOS Stability 2.Random Weights 3.Simpler Alternatives\n") + + dataset = load_or_fetch("default") + all_results = [] + + for a in ASSETS: + ticker = a["ticker"] + if ticker not in dataset: + continue + prices = dataset[ticker]["prices"] + ws, K = a["ws"], a["K"] + + print(f"\n{'═' * 80}") + print(f" {ticker} (ws={ws}, K={K})") + print(f"{'═' * 80}") + + # ── TEST 1: Stability ── + print(f"\n ── TEST 1: OOS STABILITY ──") + t1 = test_stability(prices, ws, K) + if t1: + print(f" Overall r: {t1['r_overall']}") + for q in t1["quarters"]: + marker = " ✓" if q["r"] > 0.05 else (" ✗" if q["r"] < -0.05 else "") + print(f" {q['quarter']}: r={q['r']:+.3f} (N={q['n']}){marker}") + print(f" Rolling: mean={t1['rolling_mean']:+.3f} ± {t1['rolling_std']:.3f} " + f"[{t1['rolling_min']:+.3f}, {t1['rolling_max']:+.3f}]") + print(f" % windows with r>0: {t1['pct_positive']:.0f}%") + + # ── TEST 2: Random Weights ── + print(f"\n ── TEST 2: RANDOM WEIGHTS vs TRAINED ──") + t2 = test_random_weights(prices, ws, K) + if t2: + print(f" Trained (200 ep): r={t2['r_trained']:+.3f}") + print(f" Partial (50 ep): r={t2['r_partial_50ep']:+.3f}") + print(f" Untrained (seed=42): r={t2['r_untrained']:+.3f}") + print(f" Random seeds (10x): r={t2['random_seeds_mean']:+.3f} " + f"± {t2['random_seeds_std']:.3f} " + f"(max={t2['random_seeds_max']:+.3f})") + verdict = "YES" if t2["training_adds_value"] else "NO" + print(f" → Training adds value: {verdict}") + + # ── TEST 3: Simpler Alternatives ── + print(f"\n ── TEST 3: SIMPLER ALTERNATIVES ──") + t3 = test_simpler(prices, ws, K) + if t3: + print(f" {'Predictor':<20s} {'r':>6s} {'Q4/Q1':>6s}") + print(f" {'-' * 35}") + for p in t3["predictors"]: + best = " ← BEST" if p["r"] == max(x["r"] for x in t3["predictors"]) else "" + print(f" {p['name']:<20s} {p['r']:>+5.3f} {p['q4q1']:>5.2f}x{best}") + beats = "YES" if t3["model_beats_all_simple"] else "NO" + print(f" → Model beats all simple: {beats}") + print(f" Best simple: {t3['best_simple'][0]} (r={t3['best_simple'][1]:+.3f})") + + result = {"ticker": ticker, "ws": ws, "K": K} + if t1: + result["stability"] = t1 + if t2: + result["random_weights"] = t2 + if t3: + result["simpler"] = t3 + all_results.append(result) + + # ── CROSS-ASSET SUMMARY ── + print(f"\n{'═' * 80}") + print("CROSS-ASSET SUMMARY") + print(f"{'═' * 80}") + + print(f"\n STABILITY:") + print(f" {'Asset':<10s} {'r_all':>6s} {'Q1':>6s} {'Q2':>6s} {'Q3':>6s} {'Q4':>6s} " + f"{'%pos':>5s} {'roll_std':>8s}") + print(f" {'-' * 55}") + for r in all_results: + if "stability" not in r: + continue + s = r["stability"] + qs = [q["r"] for q in s["quarters"]] + print(f" {r['ticker']:<10s} {s['r_overall']:>+5.3f} " + f"{qs[0]:>+5.3f} {qs[1]:>+5.3f} {qs[2]:>+5.3f} {qs[3]:>+5.3f} " + f"{s['pct_positive']:>4.0f}% {s['rolling_std']:>7.3f}") + + print(f"\n RANDOM WEIGHTS:") + print(f" {'Asset':<10s} {'Trained':>8s} {'Untrained':>10s} {'Rnd mean':>9s} " + f"{'Rnd max':>8s} {'Adds value':>11s}") + print(f" {'-' * 60}") + for r in all_results: + if "random_weights" not in r: + continue + w = r["random_weights"] + print(f" {r['ticker']:<10s} {w['r_trained']:>+7.3f} " + f"{w['r_untrained']:>+9.3f} {w['random_seeds_mean']:>+8.3f} " + f"{w['random_seeds_max']:>+7.3f} " + f"{'YES' if w['training_adds_value'] else 'NO':>11s}") + + print(f"\n SIMPLER ALTERNATIVES:") + print(f" {'Asset':<10s} {'Model':>6s} {'ATR':>6s} {'ATR%':>6s} {'Range':>6s} " + f"{'RetVol':>6s} {'M×ATR%':>7s} {'Beats':>6s}") + print(f" {'-' * 55}") + for r in all_results: + if "simpler" not in r: + continue + p = {x["name"]: x["r"] for x in r["simpler"]["predictors"]} + print(f" {r['ticker']:<10s} " + f"{p.get('Remizov model', 0):>+5.3f} " + f"{p.get('Raw ATR', 0):>+5.3f} " + f"{p.get('ATR percentile', 0):>+5.3f} " + f"{p.get('Price range(ws)', 0):>+5.3f} " + f"{p.get('Returns vol', 0):>+5.3f} " + f"{p.get('Model×ATR_pct', 0):>+6.3f} " + f"{'YES' if r['simpler']['model_beats_all_simple'] else 'NO':>6s}") + + path = save_results({"results": all_results}, results_dir, "exp26g_deep") + print(f"\nSaved: {path}") + + +if __name__ == "__main__": + main() diff --git a/experiments/exp26_ablation/formula_deep_v2.py b/experiments/exp26_ablation/formula_deep_v2.py new file mode 100644 index 0000000..8d478e3 --- /dev/null +++ b/experiments/exp26_ablation/formula_deep_v2.py @@ -0,0 +1,469 @@ +"""Exp26g v2: Deep analysis — fixed bugs from v1. + +Bugs fixed: + 1. Random weights were identical (zeros init, seed doesn't matter) + → Now uses Xavier/Kaiming random init + 2. Simpler alternatives compared against normalized target (actual/ATR) + while using raw ATR as predictor → spurious negative correlation + → Now uses raw actual_amp for fair comparison + 3. Added Gaussian blur baseline (what untrained net actually does) +""" +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src")) +sys.path.insert(0, str(Path(__file__).parent.parent)) + +import numpy as np +import torch +import torch.nn as nn + +from remizov_trader.core import model as model_mod, signals, risk +from remizov_trader.core.net import EnhancedRemizovNet +from common.dataset import load_or_fetch +from common.metrics import save_results + +TRAIN_RATIO = 0.3 +STOP_SCALE = 0.5 +STOP_MULT = 2.0 +LOOKAHEAD = 30 +SHIFT = 7 + +ASSETS = [ + {"ticker": "BTC-USD", "ws": 64, "K": 3}, + {"ticker": "ETH-USD", "ws": 96, "K": 2}, + {"ticker": "ADA-USD", "ws": 64, "K": 3}, + {"ticker": "DOGE-USD", "ws": 48, "K": 3}, + {"ticker": "SOL-USD", "ws": 96, "K": 3}, +] + + +def _train_model(prices, ws): + data = signals.prepare_windows(prices, ws, SHIFT) + n_train = max(int(len(data) * TRAIN_RATIO), 20) + torch.manual_seed(42) + np.random.seed(42) + mdl = EnhancedRemizovNet(grid_size=ws, n_steps=20, total_time=0.5, + dx=1.0 / ws, use_sde=True) + model_mod.train(mdl, + np.array([d["norm_input"] for d in data[:n_train]]), + np.array([d["norm_target"] for d in data[:n_train]]), + 200, 0.003) + return mdl, data, n_train + + +def _randomize_weights(mdl, seed): + """Actually randomize model weights (not zeros!).""" + torch.manual_seed(seed) + for name, param in mdl.named_parameters(): + if param.dim() >= 2: + nn.init.xavier_normal_(param) + else: + nn.init.normal_(param, mean=0, std=0.5) + + +def _get_amplitude_data(prices, mdl, data, n_train, ws, K): + """Get pred_amp and actual_amp (both raw and normalized).""" + test_data = data[n_train:] + rows = [] + for d in test_data: + idx = d["price_idx"] + if idx + LOOKAHEAD >= len(prices) or idx < ws + K + 1: + continue + w = prices[idx - ws - K: idx - K].copy() + mu, std = w.mean(), w.std() + if std < 1e-10: + continue + pred = model_mod.predict(mdl, (w - mu) / std) + pred_new = pred[-SHIFT:] + pred_dir = signals.get_direction(pred_new, K) + if pred_dir is None: + continue + pred_denorm = pred_new * std + mu + pred_amp = float(np.max(pred_denorm) - np.min(pred_denorm)) + atr = risk.compute_atr(prices, idx) + if atr <= 0: + continue + future_end = min(idx + SHIFT, len(prices)) + future = prices[idx:future_end] + if len(future) < 2: + continue + actual_amp = float(np.max(future) - np.min(future)) + rows.append({ + "idx": idx, + "pred_amp": pred_amp, + "pred_amp_atr": pred_amp / atr, + "actual_amp": actual_amp, + "actual_amp_atr": actual_amp / atr, + "atr": atr, + "std": std, + }) + return rows + + +def _corr(a, b): + with np.errstate(invalid="ignore"): + r = np.corrcoef(a, b)[0, 1] + return 0 if np.isnan(r) else float(r) + + +def _gaussian_blur_amplitude(prices, idx, ws, K): + """What the untrained network does: Gaussian blur of input window.""" + w = prices[idx - ws - K: idx - K].copy() + mu, std = w.mean(), w.std() + if std < 1e-10: + return None + norm = (w - mu) / std + # Gaussian blur with sigma proportional to sqrt(total_time * a_init) + # a_init = softplus(0) = ln(2) ≈ 0.693 + # sigma^2 = 4 * tau * a * (pi*k)^2 summed over 20 steps + # Effective: just apply Gaussian filter + from scipy.ndimage import gaussian_filter1d + # Total diffusion time: n_steps * tau * a = 20 * 0.025 * 0.693 ≈ 0.347 + # sigma in grid units: sqrt(2 * 0.347) / dx ≈ sqrt(0.694) * ws ≈ 0.83 * ws + # But this is in Fourier space, effective sigma ≈ sqrt(total_time * a) / dx + sigma_grid = np.sqrt(0.5 * 0.693) * 2 # empirical approximation + blurred = gaussian_filter1d(norm, sigma=sigma_grid) + blurred_denorm = blurred[-SHIFT:] * std + mu + amp = float(np.max(blurred_denorm) - np.min(blurred_denorm)) + return amp + + +# ═══════════════════════════════════════════════════════════════ +# TEST 1: OOS STABILITY (same as v1 — no bug) +# ═══════════════════════════════════════════════════════════════ +def test_stability(prices, ws, K): + mdl, data, n_train = _train_model(prices, ws) + rows = _get_amplitude_data(prices, mdl, data, n_train, ws, K) + if len(rows) < 40: + return {} + + n = len(rows) + chunk_size = n // 4 + quarters = [] + for i in range(4): + start = i * chunk_size + end = (i + 1) * chunk_size if i < 3 else n + chunk = rows[start:end] + pred_a = np.array([r["pred_amp_atr"] for r in chunk]) + actual_a = np.array([r["actual_amp_atr"] for r in chunk]) + r = _corr(pred_a, actual_a) + quarters.append({"quarter": f"Q{i+1}", "r": round(r, 3), "n": len(chunk)}) + + win = max(n // 5, 30) + step = max(n // 10, 15) + rolling = [] + for start in range(0, n - win, step): + chunk = rows[start:start + win] + pred_a = np.array([r["pred_amp_atr"] for r in chunk]) + actual_a = np.array([r["actual_amp_atr"] for r in chunk]) + rolling.append(_corr(pred_a, actual_a)) + + return { + "quarters": quarters, + "rolling_mean": round(float(np.mean(rolling)), 3), + "rolling_std": round(float(np.std(rolling)), 3), + "pct_positive": round(float(np.mean(np.array(rolling) > 0) * 100), 1), + } + + +# ═══════════════════════════════════════════════════════════════ +# TEST 2: RANDOM WEIGHTS — Fixed: actual random init +# ═══════════════════════════════════════════════════════════════ +def test_random_weights(prices, ws, K): + # Trained model + mdl_trained, data, n_train = _train_model(prices, ws) + rows_trained = _get_amplitude_data(prices, mdl_trained, data, n_train, ws, K) + if len(rows_trained) < 20: + return {} + pred_t = np.array([r["pred_amp_atr"] for r in rows_trained]) + actual_t = np.array([r["actual_amp_atr"] for r in rows_trained]) + r_trained = _corr(pred_t, actual_t) + + # Untrained (zeros init — what v1 tested) + torch.manual_seed(42) + mdl_zeros = EnhancedRemizovNet(grid_size=ws, n_steps=20, total_time=0.5, + dx=1.0 / ws, use_sde=True) + rows_zeros = _get_amplitude_data(prices, mdl_zeros, data, n_train, ws, K) + r_zeros = _corr( + np.array([r["pred_amp_atr"] for r in rows_zeros]), + np.array([r["actual_amp_atr"] for r in rows_zeros]) + ) if rows_zeros else 0 + + # Actually random weights (10 seeds with Xavier init) + random_rs = [] + for seed in range(10): + mdl_rnd = EnhancedRemizovNet(grid_size=ws, n_steps=20, total_time=0.5, + dx=1.0 / ws, use_sde=True) + _randomize_weights(mdl_rnd, seed * 7 + 13) + rows_rnd = _get_amplitude_data(prices, mdl_rnd, data, n_train, ws, K) + if rows_rnd: + p = np.array([r["pred_amp_atr"] for r in rows_rnd]) + a = np.array([r["actual_amp_atr"] for r in rows_rnd]) + random_rs.append(_corr(p, a)) + + # Gaussian blur baseline + blur_amps = [] + actual_for_blur = [] + for d in data[n_train:]: + idx = d["price_idx"] + if idx + LOOKAHEAD >= len(prices) or idx < ws + K + 1: + continue + atr = risk.compute_atr(prices, idx) + if atr <= 0: + continue + ba = _gaussian_blur_amplitude(prices, idx, ws, K) + if ba is None: + continue + future_end = min(idx + SHIFT, len(prices)) + future = prices[idx:future_end] + if len(future) < 2: + continue + actual_amp = float(np.max(future) - np.min(future)) + blur_amps.append(ba / atr) + actual_for_blur.append(actual_amp / atr) + r_blur = _corr(np.array(blur_amps), np.array(actual_for_blur)) if blur_amps else 0 + + return { + "r_trained": round(r_trained, 3), + "r_zeros_init": round(r_zeros, 3), + "r_blur": round(r_blur, 3), + "r_random_mean": round(float(np.mean(random_rs)), 3) if random_rs else 0, + "r_random_std": round(float(np.std(random_rs)), 3) if random_rs else 0, + "r_random_min": round(float(np.min(random_rs)), 3) if random_rs else 0, + "r_random_max": round(float(np.max(random_rs)), 3) if random_rs else 0, + "training_vs_zeros": round(r_trained - r_zeros, 3), + "training_vs_random": round(r_trained - float(np.mean(random_rs)), 3) if random_rs else 0, + } + + +# ═══════════════════════════════════════════════════════════════ +# TEST 3: SIMPLER ALTERNATIVES — Fixed: fair comparison +# ═══════════════════════════════════════════════════════════════ +def test_simpler(prices, ws, K): + mdl, data, n_train = _train_model(prices, ws) + rows = _get_amplitude_data(prices, mdl, data, n_train, ws, K) + if len(rows) < 40: + return {} + + model_preds_raw = [] # pred_amp (raw $) + model_preds_norm = [] # pred_amp / ATR + atr_vals = [] + atr_pct_vals = [] + range_vals = [] + vol_vals = [] + input_amp_vals = [] # amplitude of input window (simplest baseline!) + actual_raw = [] # actual_amp (raw $) + actual_norm = [] # actual_amp / ATR + + for r in rows: + idx = r["idx"] + # ATR percentile + atrs_hist = [] + for j in range(max(14, idx - 100), idx): + a = risk.compute_atr(prices, j) + if a > 0: + atrs_hist.append(a) + if len(atrs_hist) < 10: + continue + atr_pct = sum(1 for a in atrs_hist if a <= r["atr"]) / len(atrs_hist) + + # Price range of input window + win = prices[max(0, idx - ws):idx] + price_range = float(np.max(win) - np.min(win)) if len(win) > 1 else 0 + + # Returns volatility + if len(win) > 2: + returns = np.diff(win) / win[:-1] + ret_vol = float(np.std(returns)) + else: + ret_vol = 0 + + # Input window amplitude (simplest: just measure how "jumpy" input was) + input_amp = float(np.max(win[-SHIFT:]) - np.min(win[-SHIFT:])) if len(win) >= SHIFT else 0 + + model_preds_raw.append(r["pred_amp"]) + model_preds_norm.append(r["pred_amp_atr"]) + atr_vals.append(r["atr"]) + atr_pct_vals.append(atr_pct) + range_vals.append(price_range) + vol_vals.append(ret_vol) + input_amp_vals.append(input_amp) + actual_raw.append(r["actual_amp"]) + actual_norm.append(r["actual_amp_atr"]) + + # Convert to arrays + model_raw = np.array(model_preds_raw) + model_norm = np.array(model_preds_norm) + atr_a = np.array(atr_vals) + atr_pct_a = np.array(atr_pct_vals) + range_a = np.array(range_vals) + vol_a = np.array(vol_vals) + input_amp_a = np.array(input_amp_vals) + act_raw = np.array(actual_raw) + act_norm = np.array(actual_norm) + + # FAIR COMPARISON: use raw actual_amp as target + # Normalize each predictor to same scale (doesn't affect correlation) + results_raw = { + "target": "actual_amp (raw $)", + "predictors": [ + {"name": "Remizov pred_amp", "r": round(_corr(model_raw, act_raw), 3)}, + {"name": "ATR (raw)", "r": round(_corr(atr_a, act_raw), 3)}, + {"name": "ATR percentile", "r": round(_corr(atr_pct_a, act_raw), 3)}, + {"name": "Price range(ws)", "r": round(_corr(range_a, act_raw), 3)}, + {"name": "Returns vol", "r": round(_corr(vol_a, act_raw), 3)}, + {"name": "Input amp(shift)", "r": round(_corr(input_amp_a, act_raw), 3)}, + ], + } + + # ALSO: normalized comparison (actual_amp/ATR as target, all predictors /ATR) + # Model is already /ATR; normalize others too + range_norm = range_a / atr_a + vol_norm = vol_a / atr_a + input_amp_norm = input_amp_a / atr_a + + results_norm = { + "target": "actual_amp / ATR (normalized)", + "predictors": [ + {"name": "Remizov pred/ATR", "r": round(_corr(model_norm, act_norm), 3)}, + {"name": "ATR percentile", "r": round(_corr(atr_pct_a, act_norm), 3)}, + {"name": "Range/ATR", "r": round(_corr(range_norm, act_norm), 3)}, + {"name": "RetVol/ATR", "r": round(_corr(vol_norm, act_norm), 3)}, + {"name": "InputAmp/ATR", "r": round(_corr(input_amp_norm, act_norm), 3)}, + ], + } + + # Best predictor + all_preds = results_raw["predictors"] + results_norm["predictors"] + best = max(all_preds, key=lambda x: x["r"]) + + return { + "raw_target": results_raw, + "norm_target": results_norm, + "best_overall": best, + "n": len(model_raw), + } + + +def main(): + results_dir = Path(__file__).parent / "results" + print("=" * 80) + print("EXP26g v2: DEEP ANALYSIS — FIXED BUGS") + print("=" * 80) + print("Fixes: 1.Random init 2.Fair predictor comparison 3.Blur baseline\n") + + dataset = load_or_fetch("default") + all_results = [] + + for a in ASSETS: + ticker = a["ticker"] + if ticker not in dataset: + continue + prices = dataset[ticker]["prices"] + ws, K = a["ws"], a["K"] + + print(f"\n{'═' * 80}") + print(f" {ticker} (ws={ws}, K={K})") + print(f"{'═' * 80}") + + # ── TEST 1: Stability ── + print(f"\n ── TEST 1: OOS STABILITY ──") + t1 = test_stability(prices, ws, K) + if t1: + for q in t1["quarters"]: + marker = " ✓" if q["r"] > 0.05 else (" ✗" if q["r"] < -0.05 else "") + print(f" {q['quarter']}: r={q['r']:+.3f} (N={q['n']}){marker}") + print(f" Rolling: mean={t1['rolling_mean']:+.3f} ± {t1['rolling_std']:.3f}") + print(f" % windows r>0: {t1['pct_positive']:.0f}%") + + # ── TEST 2: Random Weights ── + print(f"\n ── TEST 2: TRAINED vs ZEROS vs RANDOM WEIGHTS ──") + t2 = test_random_weights(prices, ws, K) + if t2: + print(f" Trained (200 ep): r={t2['r_trained']:+.3f}") + print(f" Zeros init (default): r={t2['r_zeros_init']:+.3f}") + print(f" Gaussian blur: r={t2['r_blur']:+.3f}") + print(f" Random Xavier (10x): r={t2['r_random_mean']:+.3f} " + f"± {t2['r_random_std']:.3f} " + f"[{t2['r_random_min']:+.3f}, {t2['r_random_max']:+.3f}]") + print(f" Training Δ vs zeros: {t2['training_vs_zeros']:+.3f}") + print(f" Training Δ vs random: {t2['training_vs_random']:+.3f}") + if t2['training_vs_zeros'] > 0.02: + print(f" → Training HELPS (+{t2['training_vs_zeros']:.3f})") + elif t2['training_vs_zeros'] < -0.02: + print(f" → Training HURTS ({t2['training_vs_zeros']:+.3f})") + else: + print(f" → Training has NO EFFECT") + + # ── TEST 3: Simpler Alternatives ── + print(f"\n ── TEST 3: SIMPLER ALTERNATIVES (fair comparison) ──") + t3 = test_simpler(prices, ws, K) + if t3: + print(f" RAW target (actual_amp in $):") + for p in t3["raw_target"]["predictors"]: + print(f" {p['name']:<22s} r={p['r']:+.3f}") + + print(f" NORMALIZED target (actual_amp / ATR):") + for p in t3["norm_target"]["predictors"]: + print(f" {p['name']:<22s} r={p['r']:+.3f}") + + print(f" Best overall: {t3['best_overall']['name']} " + f"(r={t3['best_overall']['r']:+.3f})") + + result = {"ticker": ticker, "ws": ws, "K": K} + if t1: + result["stability"] = t1 + if t2: + result["random_weights"] = t2 + if t3: + result["simpler"] = t3 + all_results.append(result) + + # ── CROSS-ASSET SUMMARY ── + print(f"\n{'═' * 80}") + print("CROSS-ASSET SUMMARY") + print(f"{'═' * 80}") + + print(f"\n STABILITY (% rolling windows with r>0):") + for r in all_results: + if "stability" in r: + s = r["stability"] + qs = " ".join(f"{q['r']:+.3f}" for q in s["quarters"]) + print(f" {r['ticker']:<10s} Q1-4: {qs} | {s['pct_positive']:.0f}% positive") + + print(f"\n RANDOM WEIGHTS (does training help?):") + print(f" {'Asset':<10s} {'Trained':>8s} {'Zeros':>7s} {'Blur':>7s} " + f"{'Rnd±std':>12s} {'Δ train':>8s}") + print(f" {'-' * 55}") + for r in all_results: + if "random_weights" not in r: + continue + w = r["random_weights"] + print(f" {r['ticker']:<10s} {w['r_trained']:>+7.3f} " + f"{w['r_zeros_init']:>+6.3f} {w['r_blur']:>+6.3f} " + f"{w['r_random_mean']:>+5.3f}±{w['r_random_std']:.3f} " + f"{w['training_vs_zeros']:>+7.3f}") + + print(f"\n SIMPLER ALTERNATIVES (r with raw actual_amp):") + print(f" {'Asset':<10s} {'Model':>7s} {'ATR':>7s} {'ATR%':>7s} " + f"{'Range':>7s} {'RetVol':>7s} {'InAmp':>7s}") + print(f" {'-' * 50}") + for r in all_results: + if "simpler" not in r: + continue + p = {x["name"]: x["r"] for x in r["simpler"]["raw_target"]["predictors"]} + print(f" {r['ticker']:<10s} " + f"{p.get('Remizov pred_amp', 0):>+6.3f} " + f"{p.get('ATR (raw)', 0):>+6.3f} " + f"{p.get('ATR percentile', 0):>+6.3f} " + f"{p.get('Price range(ws)', 0):>+6.3f} " + f"{p.get('Returns vol', 0):>+6.3f} " + f"{p.get('Input amp(shift)', 0):>+6.3f}") + + path = save_results({"results": all_results}, results_dir, "exp26g_deep_v2") + print(f"\nSaved: {path}") + + +if __name__ == "__main__": + main() diff --git a/experiments/exp26_ablation/results/results_exp26g_deep_20260311_054353.json b/experiments/exp26_ablation/results/results_exp26g_deep_20260311_054353.json new file mode 100644 index 0000000..45685ab --- /dev/null +++ b/experiments/exp26_ablation/results/results_exp26g_deep_20260311_054353.json @@ -0,0 +1,512 @@ +{ + "results": [ + { + "ticker": "BTC-USD", + "ws": 64, + "K": 3, + "stability": { + "r_overall": 0.184, + "quarters": [ + { + "quarter": "Q1", + "r": 0.34, + "n": 147, + "idx_range": "1842-2864" + }, + { + "quarter": "Q2", + "r": 0.082, + "n": 147, + "idx_range": "2871-3893" + }, + { + "quarter": "Q3", + "r": 0.011, + "n": 147, + "idx_range": "3900-4922" + }, + { + "quarter": "Q4", + "r": 0.279, + "n": 149, + "idx_range": "4929-5965" + } + ], + "rolling_r": [ + 0.332, + 0.158, + 0.219, + 0.175, + -0.13, + -0.034, + 0.235, + 0.339 + ], + "rolling_mean": 0.162, + "rolling_std": 0.155, + "rolling_min": -0.13, + "rolling_max": 0.339, + "pct_positive": 75.0, + "n": 590 + }, + "random_weights": { + "r_trained": 0.184, + "r_untrained": 0.19, + "r_partial_50ep": 0.187, + "random_seeds_mean": 0.19, + "random_seeds_std": 0.0, + "random_seeds_max": 0.19, + "training_adds_value": "False", + "n_trained": 590, + "n_untrained": 590 + }, + "simpler": { + "predictors": [ + { + "name": "Remizov model", + "r": 0.184, + "q4q1": 1.35 + }, + { + "name": "Raw ATR", + "r": -0.374, + "q4q1": 0.43 + }, + { + "name": "ATR percentile", + "r": -0.377, + "q4q1": 0.47 + }, + { + "name": "Price range(ws)", + "r": -0.152, + "q4q1": 0.7 + }, + { + "name": "Returns vol", + "r": -0.177, + "q4q1": 0.62 + }, + { + "name": "Model\u00d7ATR_pct", + "r": -0.132, + "q4q1": 0.64 + } + ], + "model_beats_all_simple": true, + "best_simple": [ + "range", + -0.1524435614426429 + ], + "n": 590 + } + }, + { + "ticker": "ETH-USD", + "ws": 96, + "K": 2, + "stability": { + "r_overall": 0.128, + "quarters": [ + { + "quarter": "Q1", + "r": 0.175, + "n": 296, + "idx_range": "3666-5731" + }, + { + "quarter": "Q2", + "r": 0.088, + "n": 296, + "idx_range": "5738-7803" + }, + { + "quarter": "Q3", + "r": 0.062, + "n": 296, + "idx_range": "7810-9875" + }, + { + "quarter": "Q4", + "r": 0.162, + "n": 299, + "idx_range": "9882-11968" + } + ], + "rolling_r": [ + 0.159, + 0.204, + 0.139, + 0.067, + 0.02, + 0.041, + 0.128, + 0.118, + 0.141 + ], + "rolling_mean": 0.113, + "rolling_std": 0.056, + "rolling_min": 0.02, + "rolling_max": 0.204, + "pct_positive": 100.0, + "n": 1187 + }, + "random_weights": { + "r_trained": 0.128, + "r_untrained": 0.164, + "r_partial_50ep": 0.15, + "random_seeds_mean": 0.164, + "random_seeds_std": 0.0, + "random_seeds_max": 0.164, + "training_adds_value": "False", + "n_trained": 1187, + "n_untrained": 1186 + }, + "simpler": { + "predictors": [ + { + "name": "Remizov model", + "r": 0.128, + "q4q1": 1.27 + }, + { + "name": "Raw ATR", + "r": -0.287, + "q4q1": 0.5 + }, + { + "name": "ATR percentile", + "r": -0.286, + "q4q1": 0.5 + }, + { + "name": "Price range(ws)", + "r": -0.106, + "q4q1": 0.72 + }, + { + "name": "Returns vol", + "r": -0.133, + "q4q1": 0.69 + }, + { + "name": "Model\u00d7ATR_pct", + "r": -0.103, + "q4q1": 0.75 + } + ], + "model_beats_all_simple": true, + "best_simple": [ + "range", + -0.10552614238011103 + ], + "n": 1187 + } + }, + { + "ticker": "ADA-USD", + "ws": 64, + "K": 3, + "stability": { + "r_overall": 0.136, + "quarters": [ + { + "quarter": "Q1", + "r": 0.21, + "n": 147, + "idx_range": "1842-2864" + }, + { + "quarter": "Q2", + "r": 0.133, + "n": 147, + "idx_range": "2871-3893" + }, + { + "quarter": "Q3", + "r": 0.104, + "n": 147, + "idx_range": "3900-4922" + }, + { + "quarter": "Q4", + "r": 0.101, + "n": 149, + "idx_range": "4929-5965" + } + ], + "rolling_r": [ + 0.184, + 0.064, + 0.103, + 0.152, + 0.152, + 0.109, + 0.067, + 0.075 + ], + "rolling_mean": 0.113, + "rolling_std": 0.042, + "rolling_min": 0.064, + "rolling_max": 0.184, + "pct_positive": 100.0, + "n": 590 + }, + "random_weights": { + "r_trained": 0.136, + "r_untrained": 0.14, + "r_partial_50ep": 0.13, + "random_seeds_mean": 0.14, + "random_seeds_std": 0.0, + "random_seeds_max": 0.14, + "training_adds_value": "False", + "n_trained": 590, + "n_untrained": 590 + }, + "simpler": { + "predictors": [ + { + "name": "Remizov model", + "r": 0.136, + "q4q1": 1.27 + }, + { + "name": "Raw ATR", + "r": -0.183, + "q4q1": 0.68 + }, + { + "name": "ATR percentile", + "r": -0.261, + "q4q1": 0.59 + }, + { + "name": "Price range(ws)", + "r": -0.116, + "q4q1": 0.78 + }, + { + "name": "Returns vol", + "r": -0.13, + "q4q1": 0.75 + }, + { + "name": "Model\u00d7ATR_pct", + "r": -0.118, + "q4q1": 0.66 + } + ], + "model_beats_all_simple": true, + "best_simple": [ + "range", + -0.11618956247134542 + ], + "n": 590 + } + }, + { + "ticker": "DOGE-USD", + "ws": 48, + "K": 3, + "stability": { + "r_overall": 0.041, + "quarters": [ + { + "quarter": "Q1", + "r": 0.108, + "n": 147, + "idx_range": "1833-2855" + }, + { + "quarter": "Q2", + "r": 0.103, + "n": 147, + "idx_range": "2862-3884" + }, + { + "quarter": "Q3", + "r": -0.075, + "n": 147, + "idx_range": "3891-4913" + }, + { + "quarter": "Q4", + "r": 0.011, + "n": 150, + "idx_range": "4920-5963" + } + ], + "rolling_r": [ + 0.132, + -0.113, + 0.112, + 0.189, + -0.077, + -0.117, + -0.047, + 0.114, + 0.051 + ], + "rolling_mean": 0.027, + "rolling_std": 0.11, + "rolling_min": -0.117, + "rolling_max": 0.189, + "pct_positive": 55.6, + "n": 591 + }, + "random_weights": { + "r_trained": 0.041, + "r_untrained": 0.072, + "r_partial_50ep": 0.071, + "random_seeds_mean": 0.072, + "random_seeds_std": 0.0, + "random_seeds_max": 0.072, + "training_adds_value": "False", + "n_trained": 591, + "n_untrained": 591 + }, + "simpler": { + "predictors": [ + { + "name": "Remizov model", + "r": 0.041, + "q4q1": 0.96 + }, + { + "name": "Raw ATR", + "r": -0.22, + "q4q1": 0.64 + }, + { + "name": "ATR percentile", + "r": -0.285, + "q4q1": 0.59 + }, + { + "name": "Price range(ws)", + "r": -0.163, + "q4q1": 0.66 + }, + { + "name": "Returns vol", + "r": -0.188, + "q4q1": 0.65 + }, + { + "name": "Model\u00d7ATR_pct", + "r": -0.177, + "q4q1": 0.65 + } + ], + "model_beats_all_simple": true, + "best_simple": [ + "range", + -0.16269637607212817 + ], + "n": 591 + } + }, + { + "ticker": "SOL-USD", + "ws": 96, + "K": 3, + "stability": { + "r_overall": 0.169, + "quarters": [ + { + "quarter": "Q1", + "r": 0.258, + "n": 296, + "idx_range": "3666-5731" + }, + { + "quarter": "Q2", + "r": 0.063, + "n": 296, + "idx_range": "5738-7803" + }, + { + "quarter": "Q3", + "r": 0.133, + "n": 296, + "idx_range": "7810-9875" + }, + { + "quarter": "Q4", + "r": 0.221, + "n": 299, + "idx_range": "9882-11968" + } + ], + "rolling_r": [ + 0.243, + 0.219, + 0.125, + 0.064, + 0.057, + 0.152, + 0.154, + 0.108, + 0.238 + ], + "rolling_mean": 0.151, + "rolling_std": 0.066, + "rolling_min": 0.057, + "rolling_max": 0.243, + "pct_positive": 100.0, + "n": 1187 + }, + "random_weights": { + "r_trained": 0.169, + "r_untrained": 0.244, + "r_partial_50ep": 0.219, + "random_seeds_mean": 0.244, + "random_seeds_std": 0.0, + "random_seeds_max": 0.244, + "training_adds_value": "False", + "n_trained": 1187, + "n_untrained": 1187 + }, + "simpler": { + "predictors": [ + { + "name": "Remizov model", + "r": 0.169, + "q4q1": 1.3 + }, + { + "name": "Raw ATR", + "r": -0.246, + "q4q1": 0.56 + }, + { + "name": "ATR percentile", + "r": -0.293, + "q4q1": 0.55 + }, + { + "name": "Price range(ws)", + "r": -0.068, + "q4q1": 0.86 + }, + { + "name": "Returns vol", + "r": -0.1, + "q4q1": 0.81 + }, + { + "name": "Model\u00d7ATR_pct", + "r": -0.114, + "q4q1": 0.72 + } + ], + "model_beats_all_simple": true, + "best_simple": [ + "range", + -0.06814042908773785 + ], + "n": 1187 + } + } + ] +} \ No newline at end of file diff --git a/experiments/exp26_ablation/results/results_exp26g_deep_v2_20260311_054857.json b/experiments/exp26_ablation/results/results_exp26g_deep_v2_20260311_054857.json new file mode 100644 index 0000000..47dc6c8 --- /dev/null +++ b/experiments/exp26_ablation/results/results_exp26g_deep_v2_20260311_054857.json @@ -0,0 +1,524 @@ +{ + "results": [ + { + "ticker": "BTC-USD", + "ws": 64, + "K": 3, + "stability": { + "quarters": [ + { + "quarter": "Q1", + "r": 0.34, + "n": 147 + }, + { + "quarter": "Q2", + "r": 0.082, + "n": 147 + }, + { + "quarter": "Q3", + "r": 0.011, + "n": 147 + }, + { + "quarter": "Q4", + "r": 0.279, + "n": 149 + } + ], + "rolling_mean": 0.162, + "rolling_std": 0.155, + "pct_positive": 75.0 + }, + "random_weights": { + "r_trained": 0.184, + "r_zeros_init": 0.19, + "r_blur": -0.033, + "r_random_mean": 0.191, + "r_random_std": 0.015, + "r_random_min": 0.169, + "r_random_max": 0.222, + "training_vs_zeros": -0.005, + "training_vs_random": -0.006 + }, + "simpler": { + "raw_target": { + "target": "actual_amp (raw $)", + "predictors": [ + { + "name": "Remizov pred_amp", + "r": 0.241 + }, + { + "name": "ATR (raw)", + "r": 0.203 + }, + { + "name": "ATR percentile", + "r": 0.095 + }, + { + "name": "Price range(ws)", + "r": 0.271 + }, + { + "name": "Returns vol", + "r": 0.105 + }, + { + "name": "Input amp(shift)", + "r": 0.179 + } + ] + }, + "norm_target": { + "target": "actual_amp / ATR (normalized)", + "predictors": [ + { + "name": "Remizov pred/ATR", + "r": 0.184 + }, + { + "name": "ATR percentile", + "r": -0.377 + }, + { + "name": "Range/ATR", + "r": 0.36 + }, + { + "name": "RetVol/ATR", + "r": 0.37 + }, + { + "name": "InputAmp/ATR", + "r": 0.059 + } + ] + }, + "best_overall": { + "name": "RetVol/ATR", + "r": 0.37 + }, + "n": 590 + } + }, + { + "ticker": "ETH-USD", + "ws": 96, + "K": 2, + "stability": { + "quarters": [ + { + "quarter": "Q1", + "r": 0.175, + "n": 296 + }, + { + "quarter": "Q2", + "r": 0.088, + "n": 296 + }, + { + "quarter": "Q3", + "r": 0.062, + "n": 296 + }, + { + "quarter": "Q4", + "r": 0.162, + "n": 299 + } + ], + "rolling_mean": 0.113, + "rolling_std": 0.056, + "pct_positive": 100.0 + }, + "random_weights": { + "r_trained": 0.128, + "r_zeros_init": 0.164, + "r_blur": 0.004, + "r_random_mean": 0.156, + "r_random_std": 0.027, + "r_random_min": 0.115, + "r_random_max": 0.193, + "training_vs_zeros": -0.036, + "training_vs_random": -0.028 + }, + "simpler": { + "raw_target": { + "target": "actual_amp (raw $)", + "predictors": [ + { + "name": "Remizov pred_amp", + "r": 0.198 + }, + { + "name": "ATR (raw)", + "r": 0.289 + }, + { + "name": "ATR percentile", + "r": 0.141 + }, + { + "name": "Price range(ws)", + "r": 0.296 + }, + { + "name": "Returns vol", + "r": 0.101 + }, + { + "name": "Input amp(shift)", + "r": 0.21 + } + ] + }, + "norm_target": { + "target": "actual_amp / ATR (normalized)", + "predictors": [ + { + "name": "Remizov pred/ATR", + "r": 0.128 + }, + { + "name": "ATR percentile", + "r": -0.286 + }, + { + "name": "Range/ATR", + "r": 0.29 + }, + { + "name": "RetVol/ATR", + "r": 0.286 + }, + { + "name": "InputAmp/ATR", + "r": -0.013 + } + ] + }, + "best_overall": { + "name": "Price range(ws)", + "r": 0.296 + }, + "n": 1187 + } + }, + { + "ticker": "ADA-USD", + "ws": 64, + "K": 3, + "stability": { + "quarters": [ + { + "quarter": "Q1", + "r": 0.21, + "n": 147 + }, + { + "quarter": "Q2", + "r": 0.133, + "n": 147 + }, + { + "quarter": "Q3", + "r": 0.104, + "n": 147 + }, + { + "quarter": "Q4", + "r": 0.101, + "n": 149 + } + ], + "rolling_mean": 0.113, + "rolling_std": 0.042, + "pct_positive": 100.0 + }, + "random_weights": { + "r_trained": 0.136, + "r_zeros_init": 0.14, + "r_blur": 0.007, + "r_random_mean": 0.134, + "r_random_std": 0.013, + "r_random_min": 0.108, + "r_random_max": 0.16, + "training_vs_zeros": -0.004, + "training_vs_random": 0.002 + }, + "simpler": { + "raw_target": { + "target": "actual_amp (raw $)", + "predictors": [ + { + "name": "Remizov pred_amp", + "r": 0.376 + }, + { + "name": "ATR (raw)", + "r": 0.457 + }, + { + "name": "ATR percentile", + "r": 0.127 + }, + { + "name": "Price range(ws)", + "r": 0.464 + }, + { + "name": "Returns vol", + "r": 0.339 + }, + { + "name": "Input amp(shift)", + "r": 0.402 + } + ] + }, + "norm_target": { + "target": "actual_amp / ATR (normalized)", + "predictors": [ + { + "name": "Remizov pred/ATR", + "r": 0.136 + }, + { + "name": "ATR percentile", + "r": -0.261 + }, + { + "name": "Range/ATR", + "r": 0.226 + }, + { + "name": "RetVol/ATR", + "r": 0.224 + }, + { + "name": "InputAmp/ATR", + "r": 0.078 + } + ] + }, + "best_overall": { + "name": "Price range(ws)", + "r": 0.464 + }, + "n": 590 + } + }, + { + "ticker": "DOGE-USD", + "ws": 48, + "K": 3, + "stability": { + "quarters": [ + { + "quarter": "Q1", + "r": 0.108, + "n": 147 + }, + { + "quarter": "Q2", + "r": 0.103, + "n": 147 + }, + { + "quarter": "Q3", + "r": -0.075, + "n": 147 + }, + { + "quarter": "Q4", + "r": 0.011, + "n": 150 + } + ], + "rolling_mean": 0.027, + "rolling_std": 0.11, + "pct_positive": 55.6 + }, + "random_weights": { + "r_trained": 0.041, + "r_zeros_init": 0.072, + "r_blur": 0.059, + "r_random_mean": 0.049, + "r_random_std": 0.036, + "r_random_min": -0.014, + "r_random_max": 0.075, + "training_vs_zeros": -0.031, + "training_vs_random": -0.007 + }, + "simpler": { + "raw_target": { + "target": "actual_amp (raw $)", + "predictors": [ + { + "name": "Remizov pred_amp", + "r": 0.36 + }, + { + "name": "ATR (raw)", + "r": 0.501 + }, + { + "name": "ATR percentile", + "r": 0.154 + }, + { + "name": "Price range(ws)", + "r": 0.494 + }, + { + "name": "Returns vol", + "r": 0.335 + }, + { + "name": "Input amp(shift)", + "r": 0.506 + } + ] + }, + "norm_target": { + "target": "actual_amp / ATR (normalized)", + "predictors": [ + { + "name": "Remizov pred/ATR", + "r": 0.041 + }, + { + "name": "ATR percentile", + "r": -0.285 + }, + { + "name": "Range/ATR", + "r": 0.168 + }, + { + "name": "RetVol/ATR", + "r": 0.21 + }, + { + "name": "InputAmp/ATR", + "r": 0.103 + } + ] + }, + "best_overall": { + "name": "Input amp(shift)", + "r": 0.506 + }, + "n": 591 + } + }, + { + "ticker": "SOL-USD", + "ws": 96, + "K": 3, + "stability": { + "quarters": [ + { + "quarter": "Q1", + "r": 0.258, + "n": 296 + }, + { + "quarter": "Q2", + "r": 0.063, + "n": 296 + }, + { + "quarter": "Q3", + "r": 0.133, + "n": 296 + }, + { + "quarter": "Q4", + "r": 0.221, + "n": 299 + } + ], + "rolling_mean": 0.151, + "rolling_std": 0.066, + "pct_positive": 100.0 + }, + "random_weights": { + "r_trained": 0.169, + "r_zeros_init": 0.244, + "r_blur": 0.024, + "r_random_mean": 0.227, + "r_random_std": 0.069, + "r_random_min": 0.099, + "r_random_max": 0.316, + "training_vs_zeros": -0.075, + "training_vs_random": -0.058 + }, + "simpler": { + "raw_target": { + "target": "actual_amp (raw $)", + "predictors": [ + { + "name": "Remizov pred_amp", + "r": 0.337 + }, + { + "name": "ATR (raw)", + "r": 0.455 + }, + { + "name": "ATR percentile", + "r": 0.137 + }, + { + "name": "Price range(ws)", + "r": 0.462 + }, + { + "name": "Returns vol", + "r": 0.223 + }, + { + "name": "Input amp(shift)", + "r": 0.365 + } + ] + }, + "norm_target": { + "target": "actual_amp / ATR (normalized)", + "predictors": [ + { + "name": "Remizov pred/ATR", + "r": 0.169 + }, + { + "name": "ATR percentile", + "r": -0.293 + }, + { + "name": "Range/ATR", + "r": 0.394 + }, + { + "name": "RetVol/ATR", + "r": 0.366 + }, + { + "name": "InputAmp/ATR", + "r": -0.011 + } + ] + }, + "best_overall": { + "name": "Price range(ws)", + "r": 0.462 + }, + "n": 1187 + } + } + ] +} \ No newline at end of file