feat: exp26i — 5 финальных тестов: simple rules, significance, regimes, arch, WF
Только DOGE статзначим (P=98%, CI=[+0.03,+1.52]). PDE лучше MLP/Linear для ADA/DOGE, Linear лучше для BTC/ETH/SOL. DOGE стабилен в walk-forward (3/3 фолда +). ADA нестабилен. ATR>70pct бьёт модель для BTC/ETH. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,635 @@
|
||||
"""Exp26i: Comprehensive final tests.
|
||||
|
||||
5 tests:
|
||||
1. SIMPLE RULE REPLACEMENT: ATR/Range filter + trailing stop (no neural net)
|
||||
2. PNL SIGNIFICANCE: Bootstrap CI for per-trade PnL
|
||||
3. MARKET REGIMES: Bull/Bear/Flat performance
|
||||
4. ARCHITECTURE COMPARISON: MLP / Linear / PDE
|
||||
5. WALK-FORWARD: Retrain every N bars
|
||||
"""
|
||||
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
|
||||
N_BOOTSTRAP = 2000
|
||||
|
||||
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 _sim_trail(prices, idx, direction, stop_dist):
|
||||
entry = prices[idx]
|
||||
best = entry
|
||||
stop = entry - direction * stop_dist
|
||||
for i in range(1, LOOKAHEAD + 1):
|
||||
if idx + i >= len(prices):
|
||||
break
|
||||
p = prices[idx + i]
|
||||
best, stop = risk.update_trailing_stop(p, best, stop, stop_dist, direction)
|
||||
if risk.is_stopped(p, stop, direction):
|
||||
return (p - entry) / entry * direction
|
||||
last = prices[min(idx + LOOKAHEAD, len(prices) - 1)]
|
||||
return (last - entry) / entry * direction
|
||||
|
||||
|
||||
def _train_remizov(prices, ws, train_indices=None):
|
||||
data = signals.prepare_windows(prices, ws, SHIFT)
|
||||
if train_indices is None:
|
||||
n_train = max(int(len(data) * TRAIN_RATIO), 20)
|
||||
train_data = data[:n_train]
|
||||
else:
|
||||
train_data = [d for d in data if d["price_idx"] in train_indices]
|
||||
if len(train_data) < 10:
|
||||
train_data = data[: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 train_data]),
|
||||
np.array([d["norm_target"] for d in train_data]),
|
||||
200, 0.003)
|
||||
return mdl, data
|
||||
|
||||
|
||||
def _get_model_trades(prices, mdl, data, n_train, ws, K):
|
||||
"""Get trades from Remizov model with production filters."""
|
||||
test_data = data[n_train:]
|
||||
trades = []
|
||||
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
|
||||
confirm = prices[idx - K:idx].copy()
|
||||
corr, confirmed = signals.check_shape_confirmation(
|
||||
pred_new, confirm, mu, std, K, 0.5)
|
||||
confidence = abs(corr) * (pred_amp / atr)
|
||||
|
||||
stop_dist = max(atr * STOP_MULT * STOP_SCALE, prices[idx] * 0.005)
|
||||
pnl = _sim_trail(prices, idx, pred_dir, stop_dist)
|
||||
|
||||
trades.append({
|
||||
"idx": idx, "pnl": pnl * 100, "pred_dir": pred_dir,
|
||||
"confidence": confidence, "confirmed": confirmed,
|
||||
"atr": atr, "pred_amp_atr": pred_amp / atr,
|
||||
})
|
||||
return trades
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# TEST 1: SIMPLE RULE REPLACEMENT
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
def test_simple_rule(prices, ws, K, model_trades):
|
||||
"""Replace neural net with simple ATR/Range-based entry rules."""
|
||||
# Get test period from model trades
|
||||
if not model_trades:
|
||||
return {}
|
||||
idx_min = min(t["idx"] for t in model_trades)
|
||||
idx_max = max(t["idx"] for t in model_trades)
|
||||
|
||||
strategies = {}
|
||||
|
||||
# Strategy A: Enter every SHIFT bars (periodic), always long, trailing stop
|
||||
trades_periodic = []
|
||||
for idx in range(idx_min, idx_max, SHIFT):
|
||||
if idx + LOOKAHEAD >= len(prices) or idx < ws:
|
||||
continue
|
||||
atr = risk.compute_atr(prices, idx)
|
||||
if atr <= 0:
|
||||
continue
|
||||
stop_dist = max(atr * STOP_MULT * STOP_SCALE, prices[idx] * 0.005)
|
||||
pnl = _sim_trail(prices, idx, 1, stop_dist)
|
||||
trades_periodic.append(pnl * 100)
|
||||
strategies["periodic_long"] = trades_periodic
|
||||
|
||||
# Strategy B: Enter when ATR percentile > 70% (high vol expected)
|
||||
trades_atr_high = []
|
||||
for idx in range(idx_min, idx_max, SHIFT):
|
||||
if idx + LOOKAHEAD >= len(prices) or idx < ws:
|
||||
continue
|
||||
atr = risk.compute_atr(prices, idx)
|
||||
if atr <= 0:
|
||||
continue
|
||||
atrs_hist = [risk.compute_atr(prices, j) for j in range(max(14, idx - 100), idx)]
|
||||
atrs_hist = [a for a in atrs_hist if a > 0]
|
||||
if len(atrs_hist) < 10:
|
||||
continue
|
||||
atr_pct = sum(1 for a in atrs_hist if a <= atr) / len(atrs_hist)
|
||||
if atr_pct < 0.7:
|
||||
continue
|
||||
stop_dist = max(atr * STOP_MULT * STOP_SCALE, prices[idx] * 0.005)
|
||||
pnl = _sim_trail(prices, idx, 1, stop_dist)
|
||||
trades_atr_high.append(pnl * 100)
|
||||
strategies["atr_high_70pct"] = trades_atr_high
|
||||
|
||||
# Strategy C: Enter when recent range > 1.5 ATR (breakout-like)
|
||||
trades_range = []
|
||||
for idx in range(idx_min, idx_max, SHIFT):
|
||||
if idx + LOOKAHEAD >= len(prices) or idx < ws:
|
||||
continue
|
||||
atr = risk.compute_atr(prices, idx)
|
||||
if atr <= 0:
|
||||
continue
|
||||
win = prices[max(0, idx - ws):idx]
|
||||
price_range = float(np.max(win) - np.min(win))
|
||||
if price_range / atr < 1.5:
|
||||
continue
|
||||
# Direction: last K bars trend
|
||||
trend = 1 if prices[idx - 1] > prices[idx - K - 1] else -1
|
||||
stop_dist = max(atr * STOP_MULT * STOP_SCALE, prices[idx] * 0.005)
|
||||
pnl = _sim_trail(prices, idx, trend, stop_dist)
|
||||
trades_range.append(pnl * 100)
|
||||
strategies["range_breakout"] = trades_range
|
||||
|
||||
# Strategy D: Enter when ret_vol > median (momentum-like), trend direction
|
||||
ret_vols = []
|
||||
for idx in range(idx_min, idx_max, SHIFT):
|
||||
if idx < ws or idx + LOOKAHEAD >= len(prices):
|
||||
continue
|
||||
win = prices[max(0, idx - ws):idx]
|
||||
if len(win) > 2:
|
||||
returns = np.diff(win) / win[:-1]
|
||||
ret_vols.append((idx, float(np.std(returns))))
|
||||
if ret_vols:
|
||||
median_vol = np.median([v for _, v in ret_vols])
|
||||
trades_vol = []
|
||||
for idx, vol in ret_vols:
|
||||
if vol < median_vol:
|
||||
continue
|
||||
atr = risk.compute_atr(prices, idx)
|
||||
if atr <= 0:
|
||||
continue
|
||||
trend = 1 if prices[idx - 1] > prices[idx - K - 1] else -1
|
||||
stop_dist = max(atr * STOP_MULT * STOP_SCALE, prices[idx] * 0.005)
|
||||
pnl = _sim_trail(prices, idx, trend, stop_dist)
|
||||
trades_vol.append(pnl * 100)
|
||||
strategies["vol_momentum"] = trades_vol
|
||||
|
||||
# Model trades for comparison
|
||||
model_all = [t["pnl"] for t in model_trades]
|
||||
model_conf = [t["pnl"] for t in model_trades
|
||||
if t["confirmed"] and t["confidence"] >= 1.5]
|
||||
|
||||
result = {"model_all": _trade_stats(model_all, "Model (all)"),
|
||||
"model_conf": _trade_stats(model_conf, "Model (conf≥1.5)")}
|
||||
for name, trades in strategies.items():
|
||||
result[name] = _trade_stats(trades, name)
|
||||
return result
|
||||
|
||||
|
||||
def _trade_stats(pnls, label):
|
||||
if not pnls:
|
||||
return {"label": label, "n": 0, "pnl": 0, "wr": 0, "total": 0}
|
||||
a = np.array(pnls)
|
||||
return {
|
||||
"label": label, "n": len(a),
|
||||
"pnl": round(float(np.mean(a)), 3),
|
||||
"wr": round(float(np.mean(a > 0) * 100), 1),
|
||||
"total": round(float(np.sum(a)), 1),
|
||||
}
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# TEST 2: PNL SIGNIFICANCE — Bootstrap CI
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
def test_significance(model_trades):
|
||||
"""Bootstrap CI for per-trade PnL."""
|
||||
if not model_trades:
|
||||
return {}
|
||||
|
||||
all_pnl = np.array([t["pnl"] for t in model_trades])
|
||||
conf_pnl = np.array([t["pnl"] for t in model_trades
|
||||
if t["confirmed"] and t["confidence"] >= 1.5])
|
||||
|
||||
def _bootstrap_ci(arr):
|
||||
if len(arr) < 5:
|
||||
return {"mean": 0, "ci_lo": 0, "ci_hi": 0, "p_positive": 0}
|
||||
np.random.seed(42)
|
||||
means = []
|
||||
for _ in range(N_BOOTSTRAP):
|
||||
sample = np.random.choice(arr, size=len(arr), replace=True)
|
||||
means.append(np.mean(sample))
|
||||
means = np.array(means)
|
||||
return {
|
||||
"mean": round(float(np.mean(arr)), 3),
|
||||
"ci_lo": round(float(np.percentile(means, 2.5)), 3),
|
||||
"ci_hi": round(float(np.percentile(means, 97.5)), 3),
|
||||
"p_positive": round(float(np.mean(means > 0) * 100), 1),
|
||||
"n": len(arr),
|
||||
}
|
||||
|
||||
return {
|
||||
"all_trades": _bootstrap_ci(all_pnl),
|
||||
"conf_trades": _bootstrap_ci(conf_pnl),
|
||||
}
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# TEST 3: MARKET REGIMES — Bull/Bear/Flat
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
def test_regimes(prices, model_trades):
|
||||
"""Split trades by market regime at entry."""
|
||||
if not model_trades:
|
||||
return {}
|
||||
|
||||
regime_trades = {"bull": [], "bear": [], "flat": []}
|
||||
lookback = 50 # bars to determine regime
|
||||
|
||||
for t in model_trades:
|
||||
idx = t["idx"]
|
||||
if idx < lookback:
|
||||
continue
|
||||
# Regime = price change over lookback
|
||||
change = (prices[idx] - prices[idx - lookback]) / prices[idx - lookback]
|
||||
if change > 0.03:
|
||||
regime = "bull"
|
||||
elif change < -0.03:
|
||||
regime = "bear"
|
||||
else:
|
||||
regime = "flat"
|
||||
regime_trades[regime].append(t)
|
||||
|
||||
result = {}
|
||||
for regime, trades in regime_trades.items():
|
||||
all_pnl = [t["pnl"] for t in trades]
|
||||
conf_pnl = [t["pnl"] for t in trades
|
||||
if t["confirmed"] and t["confidence"] >= 1.5]
|
||||
result[regime] = {
|
||||
"n_all": len(all_pnl),
|
||||
"pnl_all": round(float(np.mean(all_pnl)), 3) if all_pnl else 0,
|
||||
"wr_all": round(float(np.mean(np.array(all_pnl) > 0) * 100), 1) if all_pnl else 0,
|
||||
"n_conf": len(conf_pnl),
|
||||
"pnl_conf": round(float(np.mean(conf_pnl)), 3) if conf_pnl else 0,
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# TEST 4: ARCHITECTURE COMPARISON
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
class SimpleMLP(nn.Module):
|
||||
def __init__(self, grid_size):
|
||||
super().__init__()
|
||||
self.net = nn.Sequential(
|
||||
nn.Linear(grid_size, 128), nn.ReLU(),
|
||||
nn.Linear(128, 64), nn.ReLU(),
|
||||
nn.Linear(64, grid_size),
|
||||
)
|
||||
|
||||
def forward(self, x, stochastic=True):
|
||||
return self.net(x)
|
||||
|
||||
|
||||
class LinearModel(nn.Module):
|
||||
def __init__(self, grid_size):
|
||||
super().__init__()
|
||||
self.linear = nn.Linear(grid_size, grid_size)
|
||||
|
||||
def forward(self, x, stochastic=True):
|
||||
return self.linear(x)
|
||||
|
||||
|
||||
def test_architectures(prices, ws, K):
|
||||
"""Compare PDE vs MLP vs Linear for amplitude prediction."""
|
||||
data = signals.prepare_windows(prices, ws, SHIFT)
|
||||
n_train = max(int(len(data) * TRAIN_RATIO), 20)
|
||||
train_x = np.array([d["norm_input"] for d in data[:n_train]])
|
||||
train_y = np.array([d["norm_target"] for d in data[:n_train]])
|
||||
|
||||
models = {}
|
||||
|
||||
# PDE (Remizov)
|
||||
torch.manual_seed(42)
|
||||
np.random.seed(42)
|
||||
mdl_pde = EnhancedRemizovNet(grid_size=ws, n_steps=20, total_time=0.5,
|
||||
dx=1.0 / ws, use_sde=True)
|
||||
model_mod.train(mdl_pde, train_x, train_y, 200, 0.003)
|
||||
models["PDE"] = mdl_pde
|
||||
|
||||
# MLP
|
||||
torch.manual_seed(42)
|
||||
mdl_mlp = SimpleMLP(ws)
|
||||
model_mod.train(mdl_mlp, train_x, train_y, 200, 0.003)
|
||||
models["MLP"] = mdl_mlp
|
||||
|
||||
# Linear
|
||||
torch.manual_seed(42)
|
||||
mdl_lin = LinearModel(ws)
|
||||
model_mod.train(mdl_lin, train_x, train_y, 200, 0.003)
|
||||
models["Linear"] = mdl_lin
|
||||
|
||||
results = {}
|
||||
for name, mdl in models.items():
|
||||
trades = _get_model_trades(prices, mdl, data, n_train, ws, K)
|
||||
all_pnl = [t["pnl"] for t in trades]
|
||||
conf_trades = [t for t in trades
|
||||
if t["confirmed"] and t["confidence"] >= 1.5]
|
||||
conf_pnl = [t["pnl"] for t in conf_trades]
|
||||
|
||||
# Amplitude correlation
|
||||
pred_amps = [t["pred_amp_atr"] for t in trades]
|
||||
# Get actual amplitudes
|
||||
actual_amps = []
|
||||
for t in trades:
|
||||
idx = t["idx"]
|
||||
future_end = min(idx + SHIFT, len(prices))
|
||||
future = prices[idx:future_end]
|
||||
if len(future) >= 2 and t["atr"] > 0:
|
||||
actual_amps.append(float(np.max(future) - np.min(future)) / t["atr"])
|
||||
else:
|
||||
actual_amps.append(0)
|
||||
|
||||
with np.errstate(invalid="ignore"):
|
||||
r_amp = np.corrcoef(pred_amps, actual_amps)[0, 1]
|
||||
if np.isnan(r_amp):
|
||||
r_amp = 0
|
||||
|
||||
results[name] = {
|
||||
"n_all": len(all_pnl),
|
||||
"pnl_all": round(float(np.mean(all_pnl)), 3) if all_pnl else 0,
|
||||
"n_conf": len(conf_pnl),
|
||||
"pnl_conf": round(float(np.mean(conf_pnl)), 3) if conf_pnl else 0,
|
||||
"r_amp": round(float(r_amp), 3),
|
||||
}
|
||||
|
||||
return results
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# TEST 5: WALK-FORWARD VALIDATION
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
def test_walk_forward(prices, ws, K):
|
||||
"""Retrain every chunk_size bars, test on next chunk."""
|
||||
data = signals.prepare_windows(prices, ws, SHIFT)
|
||||
n = len(data)
|
||||
chunk_size = n // 5 # 5 folds
|
||||
train_size = chunk_size * 2 # train on 2 chunks
|
||||
|
||||
all_trades = []
|
||||
fold_results = []
|
||||
|
||||
for fold in range(3): # 3 test folds (folds 2,3,4)
|
||||
train_end = (fold + 2) * chunk_size
|
||||
test_start = train_end
|
||||
test_end = min(test_start + chunk_size, n)
|
||||
|
||||
if test_end <= test_start:
|
||||
break
|
||||
|
||||
train_data = data[max(0, train_end - train_size):train_end]
|
||||
if len(train_data) < 20:
|
||||
continue
|
||||
|
||||
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 train_data]),
|
||||
np.array([d["norm_target"] for d in train_data]),
|
||||
200, 0.003)
|
||||
|
||||
# Test on next chunk
|
||||
test_data = data[test_start:test_end]
|
||||
fold_trades = []
|
||||
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
|
||||
confirm = prices[idx - K:idx].copy()
|
||||
corr, confirmed = signals.check_shape_confirmation(
|
||||
pred_new, confirm, mu, std, K, 0.5)
|
||||
confidence = abs(corr) * (pred_amp / atr)
|
||||
stop_dist = max(atr * STOP_MULT * STOP_SCALE, prices[idx] * 0.005)
|
||||
pnl = _sim_trail(prices, idx, pred_dir, stop_dist)
|
||||
fold_trades.append({
|
||||
"pnl": pnl * 100, "confidence": confidence, "confirmed": confirmed,
|
||||
})
|
||||
|
||||
all_pnl = [t["pnl"] for t in fold_trades]
|
||||
conf_pnl = [t["pnl"] for t in fold_trades
|
||||
if t["confirmed"] and t["confidence"] >= 1.5]
|
||||
fold_results.append({
|
||||
"fold": fold, "n_all": len(all_pnl),
|
||||
"pnl_all": round(float(np.mean(all_pnl)), 3) if all_pnl else 0,
|
||||
"n_conf": len(conf_pnl),
|
||||
"pnl_conf": round(float(np.mean(conf_pnl)), 3) if conf_pnl else 0,
|
||||
})
|
||||
all_trades.extend(fold_trades)
|
||||
|
||||
# Overall walk-forward stats
|
||||
wf_all = [t["pnl"] for t in all_trades]
|
||||
wf_conf = [t["pnl"] for t in all_trades
|
||||
if t["confirmed"] and t["confidence"] >= 1.5]
|
||||
|
||||
return {
|
||||
"folds": fold_results,
|
||||
"overall_pnl_all": round(float(np.mean(wf_all)), 3) if wf_all else 0,
|
||||
"overall_pnl_conf": round(float(np.mean(wf_conf)), 3) if wf_conf else 0,
|
||||
"overall_n_conf": len(wf_conf),
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
results_dir = Path(__file__).parent / "results"
|
||||
print("=" * 80)
|
||||
print("EXP26i: COMPREHENSIVE FINAL TESTS")
|
||||
print("=" * 80)
|
||||
|
||||
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}, {len(prices)} prices)")
|
||||
print(f"{'═' * 80}")
|
||||
|
||||
# Get model trades first (shared across tests)
|
||||
print(f" Training Remizov model...", end=" ", flush=True)
|
||||
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)
|
||||
model_trades = _get_model_trades(prices, mdl, data, n_train, ws, K)
|
||||
print(f"{len(model_trades)} trades")
|
||||
|
||||
# ── TEST 1 ──
|
||||
print(f"\n ── TEST 1: SIMPLE RULE REPLACEMENT ──")
|
||||
t1 = test_simple_rule(prices, ws, K, model_trades)
|
||||
for key in ["model_all", "model_conf", "periodic_long",
|
||||
"atr_high_70pct", "range_breakout", "vol_momentum"]:
|
||||
if key in t1:
|
||||
s = t1[key]
|
||||
print(f" {s['label']:<22s} N={s['n']:4d} "
|
||||
f"PnL={s['pnl']:+.3f}% WR={s['wr']:.1f}% "
|
||||
f"Total={s['total']:+.1f}%")
|
||||
|
||||
# ── TEST 2 ──
|
||||
print(f"\n ── TEST 2: PNL SIGNIFICANCE (bootstrap) ──")
|
||||
t2 = test_significance(model_trades)
|
||||
for key in ["all_trades", "conf_trades"]:
|
||||
s = t2.get(key, {})
|
||||
if s and s.get("n", 0) > 0:
|
||||
sig = "✓" if s["ci_lo"] > 0 else "✗"
|
||||
print(f" {key:<12s}: mean={s['mean']:+.3f}% "
|
||||
f"95% CI=[{s['ci_lo']:+.3f}, {s['ci_hi']:+.3f}] "
|
||||
f"P(>0)={s['p_positive']:.1f}% {sig} N={s['n']}")
|
||||
|
||||
# ── TEST 3 ──
|
||||
print(f"\n ── TEST 3: MARKET REGIMES ──")
|
||||
t3 = test_regimes(prices, model_trades)
|
||||
for regime in ["bull", "bear", "flat"]:
|
||||
if regime in t3:
|
||||
r = t3[regime]
|
||||
print(f" {regime:<6s}: all N={r['n_all']:3d} PnL={r['pnl_all']:+.3f}% "
|
||||
f"WR={r['wr_all']:.1f}% | "
|
||||
f"conf N={r['n_conf']:3d} PnL={r['pnl_conf']:+.3f}%")
|
||||
|
||||
# ── TEST 4 ──
|
||||
print(f"\n ── TEST 4: ARCHITECTURE COMPARISON ──")
|
||||
t4 = test_architectures(prices, ws, K)
|
||||
print(f" {'Arch':<8s} {'N_all':>5s} {'PnL_all':>8s} "
|
||||
f"{'N_conf':>6s} {'PnL_conf':>9s} {'r_amp':>6s}")
|
||||
print(f" {'-' * 45}")
|
||||
for name in ["PDE", "MLP", "Linear"]:
|
||||
if name in t4:
|
||||
r = t4[name]
|
||||
print(f" {name:<8s} {r['n_all']:>5d} {r['pnl_all']:>+7.3f}% "
|
||||
f"{r['n_conf']:>6d} {r['pnl_conf']:>+8.3f}% "
|
||||
f"{r['r_amp']:>+5.3f}")
|
||||
|
||||
# ── TEST 5 ──
|
||||
print(f"\n ── TEST 5: WALK-FORWARD ──")
|
||||
t5 = test_walk_forward(prices, ws, K)
|
||||
for f_res in t5.get("folds", []):
|
||||
print(f" Fold {f_res['fold']}: all N={f_res['n_all']:3d} "
|
||||
f"PnL={f_res['pnl_all']:+.3f}% | "
|
||||
f"conf N={f_res['n_conf']:3d} PnL={f_res['pnl_conf']:+.3f}%")
|
||||
print(f" Overall WF: PnL_all={t5['overall_pnl_all']:+.3f}% "
|
||||
f"PnL_conf={t5['overall_pnl_conf']:+.3f}% (N={t5['overall_n_conf']})")
|
||||
|
||||
result = {
|
||||
"ticker": ticker, "ws": ws, "K": K,
|
||||
"simple_rule": t1, "significance": t2,
|
||||
"regimes": t3, "architectures": t4, "walk_forward": t5,
|
||||
}
|
||||
all_results.append(result)
|
||||
|
||||
# ── CROSS-ASSET SUMMARY ──
|
||||
print(f"\n{'═' * 80}")
|
||||
print("CROSS-ASSET SUMMARY")
|
||||
print(f"{'═' * 80}")
|
||||
|
||||
print(f"\n TEST 1 — SIMPLE RULE vs MODEL (conf-filtered PnL):")
|
||||
print(f" {'Asset':<10s} {'Model':>8s} {'Periodic':>9s} {'ATR_hi':>8s} "
|
||||
f"{'Range':>8s} {'VolMom':>8s}")
|
||||
print(f" {'-' * 50}")
|
||||
for r in all_results:
|
||||
t = r["simple_rule"]
|
||||
print(f" {r['ticker']:<10s} "
|
||||
f"{t.get('model_conf', {}).get('pnl', 0):>+7.3f}% "
|
||||
f"{t.get('periodic_long', {}).get('pnl', 0):>+8.3f}% "
|
||||
f"{t.get('atr_high_70pct', {}).get('pnl', 0):>+7.3f}% "
|
||||
f"{t.get('range_breakout', {}).get('pnl', 0):>+7.3f}% "
|
||||
f"{t.get('vol_momentum', {}).get('pnl', 0):>+7.3f}%")
|
||||
|
||||
print(f"\n TEST 2 — SIGNIFICANCE (conf-filtered, 95% CI):")
|
||||
for r in all_results:
|
||||
s = r["significance"].get("conf_trades", {})
|
||||
if s and s.get("n", 0) > 0:
|
||||
sig = "SIGNIFICANT" if s["ci_lo"] > 0 else "NOT significant"
|
||||
print(f" {r['ticker']:<10s} {s['mean']:+.3f}% "
|
||||
f"[{s['ci_lo']:+.3f}, {s['ci_hi']:+.3f}] "
|
||||
f"P(>0)={s['p_positive']:.0f}% → {sig}")
|
||||
else:
|
||||
print(f" {r['ticker']:<10s} N/A (no conf trades)")
|
||||
|
||||
print(f"\n TEST 3 — BEST REGIME (conf-filtered):")
|
||||
for r in all_results:
|
||||
best_regime = max(r["regimes"].items(),
|
||||
key=lambda x: x[1].get("pnl_conf", -999))
|
||||
print(f" {r['ticker']:<10s} best={best_regime[0]} "
|
||||
f"PnL={best_regime[1].get('pnl_conf', 0):+.3f}% "
|
||||
f"N={best_regime[1].get('n_conf', 0)}")
|
||||
|
||||
print(f"\n TEST 4 — BEST ARCHITECTURE (conf PnL):")
|
||||
for r in all_results:
|
||||
best = max(r["architectures"].items(),
|
||||
key=lambda x: x[1].get("pnl_conf", -999) if x[1].get("n_conf", 0) > 0 else -999)
|
||||
print(f" {r['ticker']:<10s} best={best[0]} "
|
||||
f"PnL={best[1].get('pnl_conf', 0):+.3f}% "
|
||||
f"(r_amp={best[1].get('r_amp', 0):+.3f})")
|
||||
|
||||
print(f"\n TEST 5 — WALK-FORWARD (conf PnL):")
|
||||
for r in all_results:
|
||||
wf = r["walk_forward"]
|
||||
print(f" {r['ticker']:<10s} PnL={wf['overall_pnl_conf']:+.3f}% "
|
||||
f"N={wf['overall_n_conf']}")
|
||||
|
||||
path = save_results({"results": all_results}, results_dir, "exp26i_comprehensive")
|
||||
print(f"\nSaved: {path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,699 @@
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"ticker": "BTC-USD",
|
||||
"ws": 64,
|
||||
"K": 3,
|
||||
"simple_rule": {
|
||||
"model_all": {
|
||||
"label": "Model (all)",
|
||||
"n": 590,
|
||||
"pnl": 0.061,
|
||||
"wr": 37.6,
|
||||
"total": 36.1
|
||||
},
|
||||
"model_conf": {
|
||||
"label": "Model (conf\u22651.5)",
|
||||
"n": 137,
|
||||
"pnl": 0.111,
|
||||
"wr": 38.7,
|
||||
"total": 15.1
|
||||
},
|
||||
"periodic_long": {
|
||||
"label": "periodic_long",
|
||||
"n": 589,
|
||||
"pnl": 0.15,
|
||||
"wr": 40.1,
|
||||
"total": 88.5
|
||||
},
|
||||
"atr_high_70pct": {
|
||||
"label": "atr_high_70pct",
|
||||
"n": 190,
|
||||
"pnl": 0.172,
|
||||
"wr": 40.0,
|
||||
"total": 32.8
|
||||
},
|
||||
"range_breakout": {
|
||||
"label": "range_breakout",
|
||||
"n": 589,
|
||||
"pnl": 0.016,
|
||||
"wr": 33.8,
|
||||
"total": 9.2
|
||||
},
|
||||
"vol_momentum": {
|
||||
"label": "vol_momentum",
|
||||
"n": 295,
|
||||
"pnl": -0.065,
|
||||
"wr": 31.2,
|
||||
"total": -19.1
|
||||
}
|
||||
},
|
||||
"significance": {
|
||||
"all_trades": {
|
||||
"mean": 0.061,
|
||||
"ci_lo": -0.101,
|
||||
"ci_hi": 0.235,
|
||||
"p_positive": 74.0,
|
||||
"n": 590
|
||||
},
|
||||
"conf_trades": {
|
||||
"mean": 0.111,
|
||||
"ci_lo": -0.214,
|
||||
"ci_hi": 0.437,
|
||||
"p_positive": 73.6,
|
||||
"n": 137
|
||||
}
|
||||
},
|
||||
"regimes": {
|
||||
"bull": {
|
||||
"n_all": 189,
|
||||
"pnl_all": 0.051,
|
||||
"wr_all": 38.6,
|
||||
"n_conf": 55,
|
||||
"pnl_conf": 0.097
|
||||
},
|
||||
"bear": {
|
||||
"n_all": 174,
|
||||
"pnl_all": 0.233,
|
||||
"wr_all": 42.5,
|
||||
"n_conf": 43,
|
||||
"pnl_conf": -0.045
|
||||
},
|
||||
"flat": {
|
||||
"n_all": 227,
|
||||
"pnl_all": -0.062,
|
||||
"wr_all": 33.0,
|
||||
"n_conf": 39,
|
||||
"pnl_conf": 0.301
|
||||
}
|
||||
},
|
||||
"architectures": {
|
||||
"PDE": {
|
||||
"n_all": 590,
|
||||
"pnl_all": 0.061,
|
||||
"n_conf": 137,
|
||||
"pnl_conf": 0.111,
|
||||
"r_amp": 0.184
|
||||
},
|
||||
"MLP": {
|
||||
"n_all": 590,
|
||||
"pnl_all": 0.093,
|
||||
"n_conf": 163,
|
||||
"pnl_conf": 0.07,
|
||||
"r_amp": 0.222
|
||||
},
|
||||
"Linear": {
|
||||
"n_all": 590,
|
||||
"pnl_all": 0.102,
|
||||
"n_conf": 148,
|
||||
"pnl_conf": 0.267,
|
||||
"r_amp": 0.262
|
||||
}
|
||||
},
|
||||
"walk_forward": {
|
||||
"folds": [
|
||||
{
|
||||
"fold": 0,
|
||||
"n_all": 169,
|
||||
"pnl_all": 0.307,
|
||||
"n_conf": 52,
|
||||
"pnl_conf": 0.299
|
||||
},
|
||||
{
|
||||
"fold": 1,
|
||||
"n_all": 169,
|
||||
"pnl_all": 0.099,
|
||||
"n_conf": 39,
|
||||
"pnl_conf": 0.541
|
||||
},
|
||||
{
|
||||
"fold": 2,
|
||||
"n_all": 168,
|
||||
"pnl_all": -0.009,
|
||||
"n_conf": 39,
|
||||
"pnl_conf": -0.21
|
||||
}
|
||||
],
|
||||
"overall_pnl_all": 0.133,
|
||||
"overall_pnl_conf": 0.219,
|
||||
"overall_n_conf": 130
|
||||
}
|
||||
},
|
||||
{
|
||||
"ticker": "ETH-USD",
|
||||
"ws": 96,
|
||||
"K": 2,
|
||||
"simple_rule": {
|
||||
"model_all": {
|
||||
"label": "Model (all)",
|
||||
"n": 1187,
|
||||
"pnl": 0.097,
|
||||
"wr": 37.2,
|
||||
"total": 115.7
|
||||
},
|
||||
"model_conf": {
|
||||
"label": "Model (conf\u22651.5)",
|
||||
"n": 467,
|
||||
"pnl": 0.015,
|
||||
"wr": 37.5,
|
||||
"total": 7.2
|
||||
},
|
||||
"periodic_long": {
|
||||
"label": "periodic_long",
|
||||
"n": 1186,
|
||||
"pnl": 0.091,
|
||||
"wr": 35.5,
|
||||
"total": 107.8
|
||||
},
|
||||
"atr_high_70pct": {
|
||||
"label": "atr_high_70pct",
|
||||
"n": 359,
|
||||
"pnl": 0.345,
|
||||
"wr": 39.0,
|
||||
"total": 123.9
|
||||
},
|
||||
"range_breakout": {
|
||||
"label": "range_breakout",
|
||||
"n": 1186,
|
||||
"pnl": 0.093,
|
||||
"wr": 37.1,
|
||||
"total": 109.7
|
||||
},
|
||||
"vol_momentum": {
|
||||
"label": "vol_momentum",
|
||||
"n": 593,
|
||||
"pnl": -0.059,
|
||||
"wr": 36.3,
|
||||
"total": -35.2
|
||||
}
|
||||
},
|
||||
"significance": {
|
||||
"all_trades": {
|
||||
"mean": 0.097,
|
||||
"ci_lo": -0.036,
|
||||
"ci_hi": 0.235,
|
||||
"p_positive": 91.5,
|
||||
"n": 1187
|
||||
},
|
||||
"conf_trades": {
|
||||
"mean": 0.015,
|
||||
"ci_lo": -0.158,
|
||||
"ci_hi": 0.201,
|
||||
"p_positive": 56.0,
|
||||
"n": 467
|
||||
}
|
||||
},
|
||||
"regimes": {
|
||||
"bull": {
|
||||
"n_all": 345,
|
||||
"pnl_all": -0.067,
|
||||
"wr_all": 36.2,
|
||||
"n_conf": 151,
|
||||
"pnl_conf": 0.048
|
||||
},
|
||||
"bear": {
|
||||
"n_all": 359,
|
||||
"pnl_all": 0.027,
|
||||
"wr_all": 35.7,
|
||||
"n_conf": 138,
|
||||
"pnl_conf": -0.246
|
||||
},
|
||||
"flat": {
|
||||
"n_all": 483,
|
||||
"pnl_all": 0.267,
|
||||
"wr_all": 39.1,
|
||||
"n_conf": 178,
|
||||
"pnl_conf": 0.19
|
||||
}
|
||||
},
|
||||
"architectures": {
|
||||
"PDE": {
|
||||
"n_all": 1187,
|
||||
"pnl_all": 0.097,
|
||||
"n_conf": 467,
|
||||
"pnl_conf": 0.015,
|
||||
"r_amp": 0.128
|
||||
},
|
||||
"MLP": {
|
||||
"n_all": 1187,
|
||||
"pnl_all": 0.058,
|
||||
"n_conf": 525,
|
||||
"pnl_conf": 0.106,
|
||||
"r_amp": 0.236
|
||||
},
|
||||
"Linear": {
|
||||
"n_all": 1187,
|
||||
"pnl_all": 0.05,
|
||||
"n_conf": 450,
|
||||
"pnl_conf": 0.158,
|
||||
"r_amp": 0.24
|
||||
}
|
||||
},
|
||||
"walk_forward": {
|
||||
"folds": [
|
||||
{
|
||||
"fold": 0,
|
||||
"n_all": 340,
|
||||
"pnl_all": 0.154,
|
||||
"n_conf": 152,
|
||||
"pnl_conf": -0.022
|
||||
},
|
||||
{
|
||||
"fold": 1,
|
||||
"n_all": 340,
|
||||
"pnl_all": 0.047,
|
||||
"n_conf": 142,
|
||||
"pnl_conf": 0.095
|
||||
},
|
||||
{
|
||||
"fold": 2,
|
||||
"n_all": 337,
|
||||
"pnl_all": 0.04,
|
||||
"n_conf": 0,
|
||||
"pnl_conf": 0
|
||||
}
|
||||
],
|
||||
"overall_pnl_all": 0.08,
|
||||
"overall_pnl_conf": 0.034,
|
||||
"overall_n_conf": 294
|
||||
}
|
||||
},
|
||||
{
|
||||
"ticker": "ADA-USD",
|
||||
"ws": 64,
|
||||
"K": 3,
|
||||
"simple_rule": {
|
||||
"model_all": {
|
||||
"label": "Model (all)",
|
||||
"n": 590,
|
||||
"pnl": 0.326,
|
||||
"wr": 36.3,
|
||||
"total": 192.6
|
||||
},
|
||||
"model_conf": {
|
||||
"label": "Model (conf\u22651.5)",
|
||||
"n": 139,
|
||||
"pnl": 0.863,
|
||||
"wr": 36.0,
|
||||
"total": 120.0
|
||||
},
|
||||
"periodic_long": {
|
||||
"label": "periodic_long",
|
||||
"n": 589,
|
||||
"pnl": 0.226,
|
||||
"wr": 34.8,
|
||||
"total": 133.3
|
||||
},
|
||||
"atr_high_70pct": {
|
||||
"label": "atr_high_70pct",
|
||||
"n": 179,
|
||||
"pnl": 1.048,
|
||||
"wr": 34.6,
|
||||
"total": 187.5
|
||||
},
|
||||
"range_breakout": {
|
||||
"label": "range_breakout",
|
||||
"n": 589,
|
||||
"pnl": 0.179,
|
||||
"wr": 35.5,
|
||||
"total": 105.4
|
||||
},
|
||||
"vol_momentum": {
|
||||
"label": "vol_momentum",
|
||||
"n": 295,
|
||||
"pnl": 0.344,
|
||||
"wr": 34.2,
|
||||
"total": 101.4
|
||||
}
|
||||
},
|
||||
"significance": {
|
||||
"all_trades": {
|
||||
"mean": 0.326,
|
||||
"ci_lo": -0.154,
|
||||
"ci_hi": 0.858,
|
||||
"p_positive": 91.8,
|
||||
"n": 590
|
||||
},
|
||||
"conf_trades": {
|
||||
"mean": 0.863,
|
||||
"ci_lo": -0.166,
|
||||
"ci_hi": 2.142,
|
||||
"p_positive": 94.5,
|
||||
"n": 139
|
||||
}
|
||||
},
|
||||
"regimes": {
|
||||
"bull": {
|
||||
"n_all": 194,
|
||||
"pnl_all": 0.259,
|
||||
"wr_all": 38.7,
|
||||
"n_conf": 58,
|
||||
"pnl_conf": 0.469
|
||||
},
|
||||
"bear": {
|
||||
"n_all": 264,
|
||||
"pnl_all": 0.625,
|
||||
"wr_all": 34.5,
|
||||
"n_conf": 61,
|
||||
"pnl_conf": 1.579
|
||||
},
|
||||
"flat": {
|
||||
"n_all": 132,
|
||||
"pnl_all": -0.172,
|
||||
"wr_all": 36.4,
|
||||
"n_conf": 20,
|
||||
"pnl_conf": -0.176
|
||||
}
|
||||
},
|
||||
"architectures": {
|
||||
"PDE": {
|
||||
"n_all": 590,
|
||||
"pnl_all": 0.326,
|
||||
"n_conf": 139,
|
||||
"pnl_conf": 0.863,
|
||||
"r_amp": 0.136
|
||||
},
|
||||
"MLP": {
|
||||
"n_all": 590,
|
||||
"pnl_all": 0.311,
|
||||
"n_conf": 201,
|
||||
"pnl_conf": -0.123,
|
||||
"r_amp": 0.131
|
||||
},
|
||||
"Linear": {
|
||||
"n_all": 590,
|
||||
"pnl_all": 0.18,
|
||||
"n_conf": 134,
|
||||
"pnl_conf": -0.323,
|
||||
"r_amp": 0.199
|
||||
}
|
||||
},
|
||||
"walk_forward": {
|
||||
"folds": [
|
||||
{
|
||||
"fold": 0,
|
||||
"n_all": 169,
|
||||
"pnl_all": -0.135,
|
||||
"n_conf": 45,
|
||||
"pnl_conf": 0.111
|
||||
},
|
||||
{
|
||||
"fold": 1,
|
||||
"n_all": 169,
|
||||
"pnl_all": 1.327,
|
||||
"n_conf": 37,
|
||||
"pnl_conf": 1.742
|
||||
},
|
||||
{
|
||||
"fold": 2,
|
||||
"n_all": 168,
|
||||
"pnl_all": -0.246,
|
||||
"n_conf": 43,
|
||||
"pnl_conf": -0.185
|
||||
}
|
||||
],
|
||||
"overall_pnl_all": 0.316,
|
||||
"overall_pnl_conf": 0.492,
|
||||
"overall_n_conf": 125
|
||||
}
|
||||
},
|
||||
{
|
||||
"ticker": "DOGE-USD",
|
||||
"ws": 48,
|
||||
"K": 3,
|
||||
"simple_rule": {
|
||||
"model_all": {
|
||||
"label": "Model (all)",
|
||||
"n": 591,
|
||||
"pnl": 0.254,
|
||||
"wr": 38.4,
|
||||
"total": 150.0
|
||||
},
|
||||
"model_conf": {
|
||||
"label": "Model (conf\u22651.5)",
|
||||
"n": 142,
|
||||
"pnl": 0.745,
|
||||
"wr": 41.5,
|
||||
"total": 105.8
|
||||
},
|
||||
"periodic_long": {
|
||||
"label": "periodic_long",
|
||||
"n": 590,
|
||||
"pnl": 0.407,
|
||||
"wr": 36.6,
|
||||
"total": 240.2
|
||||
},
|
||||
"atr_high_70pct": {
|
||||
"label": "atr_high_70pct",
|
||||
"n": 178,
|
||||
"pnl": 1.013,
|
||||
"wr": 37.6,
|
||||
"total": 180.3
|
||||
},
|
||||
"range_breakout": {
|
||||
"label": "range_breakout",
|
||||
"n": 590,
|
||||
"pnl": 0.38,
|
||||
"wr": 38.1,
|
||||
"total": 224.2
|
||||
},
|
||||
"vol_momentum": {
|
||||
"label": "vol_momentum",
|
||||
"n": 295,
|
||||
"pnl": 0.078,
|
||||
"wr": 36.6,
|
||||
"total": 23.1
|
||||
}
|
||||
},
|
||||
"significance": {
|
||||
"all_trades": {
|
||||
"mean": 0.254,
|
||||
"ci_lo": -0.076,
|
||||
"ci_hi": 0.609,
|
||||
"p_positive": 92.0,
|
||||
"n": 591
|
||||
},
|
||||
"conf_trades": {
|
||||
"mean": 0.745,
|
||||
"ci_lo": 0.031,
|
||||
"ci_hi": 1.515,
|
||||
"p_positive": 98.0,
|
||||
"n": 142
|
||||
}
|
||||
},
|
||||
"regimes": {
|
||||
"bull": {
|
||||
"n_all": 199,
|
||||
"pnl_all": 0.519,
|
||||
"wr_all": 42.7,
|
||||
"n_conf": 60,
|
||||
"pnl_conf": 0.406
|
||||
},
|
||||
"bear": {
|
||||
"n_all": 271,
|
||||
"pnl_all": 0.159,
|
||||
"wr_all": 38.0,
|
||||
"n_conf": 59,
|
||||
"pnl_conf": 1.098
|
||||
},
|
||||
"flat": {
|
||||
"n_all": 121,
|
||||
"pnl_all": 0.029,
|
||||
"wr_all": 32.2,
|
||||
"n_conf": 23,
|
||||
"pnl_conf": 0.726
|
||||
}
|
||||
},
|
||||
"architectures": {
|
||||
"PDE": {
|
||||
"n_all": 591,
|
||||
"pnl_all": 0.254,
|
||||
"n_conf": 142,
|
||||
"pnl_conf": 0.745,
|
||||
"r_amp": 0.041
|
||||
},
|
||||
"MLP": {
|
||||
"n_all": 591,
|
||||
"pnl_all": -0.046,
|
||||
"n_conf": 185,
|
||||
"pnl_conf": 0.411,
|
||||
"r_amp": 0.086
|
||||
},
|
||||
"Linear": {
|
||||
"n_all": 591,
|
||||
"pnl_all": 0.092,
|
||||
"n_conf": 93,
|
||||
"pnl_conf": 0.285,
|
||||
"r_amp": 0.148
|
||||
}
|
||||
},
|
||||
"walk_forward": {
|
||||
"folds": [
|
||||
{
|
||||
"fold": 0,
|
||||
"n_all": 170,
|
||||
"pnl_all": 0.155,
|
||||
"n_conf": 43,
|
||||
"pnl_conf": 1.085
|
||||
},
|
||||
{
|
||||
"fold": 1,
|
||||
"n_all": 170,
|
||||
"pnl_all": 0.338,
|
||||
"n_conf": 50,
|
||||
"pnl_conf": 0.602
|
||||
},
|
||||
{
|
||||
"fold": 2,
|
||||
"n_all": 166,
|
||||
"pnl_all": 0.27,
|
||||
"n_conf": 49,
|
||||
"pnl_conf": 0.524
|
||||
}
|
||||
],
|
||||
"overall_pnl_all": 0.254,
|
||||
"overall_pnl_conf": 0.722,
|
||||
"overall_n_conf": 142
|
||||
}
|
||||
},
|
||||
{
|
||||
"ticker": "SOL-USD",
|
||||
"ws": 96,
|
||||
"K": 3,
|
||||
"simple_rule": {
|
||||
"model_all": {
|
||||
"label": "Model (all)",
|
||||
"n": 1187,
|
||||
"pnl": -0.079,
|
||||
"wr": 36.4,
|
||||
"total": -94.3
|
||||
},
|
||||
"model_conf": {
|
||||
"label": "Model (conf\u22651.5)",
|
||||
"n": 346,
|
||||
"pnl": 0.034,
|
||||
"wr": 40.2,
|
||||
"total": 11.8
|
||||
},
|
||||
"periodic_long": {
|
||||
"label": "periodic_long",
|
||||
"n": 1186,
|
||||
"pnl": -0.078,
|
||||
"wr": 34.5,
|
||||
"total": -92.4
|
||||
},
|
||||
"atr_high_70pct": {
|
||||
"label": "atr_high_70pct",
|
||||
"n": 364,
|
||||
"pnl": -0.275,
|
||||
"wr": 37.1,
|
||||
"total": -100.0
|
||||
},
|
||||
"range_breakout": {
|
||||
"label": "range_breakout",
|
||||
"n": 1186,
|
||||
"pnl": 0.076,
|
||||
"wr": 37.4,
|
||||
"total": 90.7
|
||||
},
|
||||
"vol_momentum": {
|
||||
"label": "vol_momentum",
|
||||
"n": 593,
|
||||
"pnl": -0.073,
|
||||
"wr": 35.4,
|
||||
"total": -43.3
|
||||
}
|
||||
},
|
||||
"significance": {
|
||||
"all_trades": {
|
||||
"mean": -0.079,
|
||||
"ci_lo": -0.212,
|
||||
"ci_hi": 0.061,
|
||||
"p_positive": 12.6,
|
||||
"n": 1187
|
||||
},
|
||||
"conf_trades": {
|
||||
"mean": 0.034,
|
||||
"ci_lo": -0.215,
|
||||
"ci_hi": 0.275,
|
||||
"p_positive": 60.9,
|
||||
"n": 346
|
||||
}
|
||||
},
|
||||
"regimes": {
|
||||
"bull": {
|
||||
"n_all": 409,
|
||||
"pnl_all": -0.117,
|
||||
"wr_all": 35.2,
|
||||
"n_conf": 117,
|
||||
"pnl_conf": 0.165
|
||||
},
|
||||
"bear": {
|
||||
"n_all": 413,
|
||||
"pnl_all": -0.173,
|
||||
"wr_all": 37.3,
|
||||
"n_conf": 126,
|
||||
"pnl_conf": -0.062
|
||||
},
|
||||
"flat": {
|
||||
"n_all": 365,
|
||||
"pnl_all": 0.068,
|
||||
"wr_all": 36.7,
|
||||
"n_conf": 103,
|
||||
"pnl_conf": 0.003
|
||||
}
|
||||
},
|
||||
"architectures": {
|
||||
"PDE": {
|
||||
"n_all": 1187,
|
||||
"pnl_all": -0.079,
|
||||
"n_conf": 346,
|
||||
"pnl_conf": 0.034,
|
||||
"r_amp": 0.169
|
||||
},
|
||||
"MLP": {
|
||||
"n_all": 1187,
|
||||
"pnl_all": -0.103,
|
||||
"n_conf": 316,
|
||||
"pnl_conf": 0.109,
|
||||
"r_amp": 0.198
|
||||
},
|
||||
"Linear": {
|
||||
"n_all": 1187,
|
||||
"pnl_all": -0.055,
|
||||
"n_conf": 252,
|
||||
"pnl_conf": 0.161,
|
||||
"r_amp": 0.294
|
||||
}
|
||||
},
|
||||
"walk_forward": {
|
||||
"folds": [
|
||||
{
|
||||
"fold": 0,
|
||||
"n_all": 340,
|
||||
"pnl_all": -0.266,
|
||||
"n_conf": 100,
|
||||
"pnl_conf": -0.095
|
||||
},
|
||||
{
|
||||
"fold": 1,
|
||||
"n_all": 340,
|
||||
"pnl_all": -0.046,
|
||||
"n_conf": 104,
|
||||
"pnl_conf": 0.073
|
||||
},
|
||||
{
|
||||
"fold": 2,
|
||||
"n_all": 337,
|
||||
"pnl_all": 0.027,
|
||||
"n_conf": 103,
|
||||
"pnl_conf": 0.068
|
||||
}
|
||||
],
|
||||
"overall_pnl_all": -0.095,
|
||||
"overall_pnl_conf": 0.017,
|
||||
"overall_n_conf": 307
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user