initial: import DOLPHIN baseline 2026-04-21 from dolphinng5_predict working tree
Includes core prod + GREEN/BLUE subsystems: - prod/ (BLUE harness, configs, scripts, docs) - nautilus_dolphin/ (GREEN Nautilus-native impl + dvae/ preserved) - adaptive_exit/ (AEM engine + models/bucket_assignments.pkl) - Observability/ (EsoF advisor, TUI, dashboards) - external_factors/ (EsoF producer) - mc_forewarning_qlabs_fork/ (MC regime/envelope) Excludes runtime caches, logs, backups, and reproducible artifacts per .gitignore.
This commit is contained in:
71
nautilus_dolphin/dvae/test_bronze_daily_dd.py
Executable file
71
nautilus_dolphin/dvae/test_bronze_daily_dd.py
Executable file
@@ -0,0 +1,71 @@
|
||||
"""BRONZE baseline with DAILY equity curve DD (same method as test_dliq_fix_verify.py).
|
||||
Expected: ROI=88.55%, DD=15.05%, T=2155
|
||||
"""
|
||||
import sys, time, math
|
||||
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
|
||||
_HERE = Path(__file__).resolve().parent
|
||||
sys.path.insert(0, str(_HERE.parent))
|
||||
|
||||
from exp_shared import ENGINE_KWARGS, MC_BASE_CFG, load_data, load_forewarner
|
||||
from nautilus_dolphin.nautilus.esf_alpha_orchestrator import NDAlphaEngine
|
||||
from nautilus_dolphin.nautilus.adaptive_circuit_breaker import AdaptiveCircuitBreaker
|
||||
|
||||
|
||||
def main():
|
||||
print("Loading data (gold method: float64, 2-file seg-based vol_p60)...")
|
||||
d = load_data()
|
||||
fw = load_forewarner()
|
||||
print()
|
||||
|
||||
kw = ENGINE_KWARGS.copy()
|
||||
eng = NDAlphaEngine(**kw)
|
||||
acb = AdaptiveCircuitBreaker()
|
||||
acb.preload_w750(d['date_strings'])
|
||||
eng.set_ob_engine(d['ob_eng'])
|
||||
eng.set_acb(acb)
|
||||
if fw is not None:
|
||||
eng.set_mc_forewarner(fw, MC_BASE_CFG)
|
||||
eng.set_esoteric_hazard_multiplier(0.0)
|
||||
|
||||
print(f" base_max_leverage = {eng.base_max_leverage}")
|
||||
|
||||
t0 = time.time()
|
||||
daily_caps = []
|
||||
for pf_file in d['parquet_files']:
|
||||
ds = pf_file.stem
|
||||
df, acols, dvol = d['pq_data'][ds]
|
||||
vol_ok = np.where(np.isfinite(dvol), dvol > d['vol_p60'], False)
|
||||
eng.process_day(ds, df, acols, vol_regime_ok=vol_ok)
|
||||
daily_caps.append(eng.capital)
|
||||
|
||||
tr = eng.trade_history
|
||||
n = len(tr)
|
||||
roi = (eng.capital - 25000.0) / 25000.0 * 100.0
|
||||
peak, max_dd = 25000.0, 0.0
|
||||
for cap in daily_caps:
|
||||
peak = max(peak, cap)
|
||||
max_dd = max(max_dd, (peak - cap) / peak * 100.0)
|
||||
|
||||
def _abs(t):
|
||||
return t.pnl_absolute if hasattr(t, 'pnl_absolute') else t.pnl_pct * 250.0
|
||||
wins = [t for t in tr if _abs(t) > 0]
|
||||
losses = [t for t in tr if _abs(t) <= 0]
|
||||
pf = sum(_abs(t) for t in wins) / max(abs(sum(_abs(t) for t in losses)), 1e-9)
|
||||
wr = len(wins) / n * 100.0 if n > 0 else 0.0
|
||||
|
||||
print(f" ROI={roi:+.2f}% T={n} DD={max_dd:.2f}% PF={pf:.4f} WR={wr:.1f}% ({time.time()-t0:.0f}s)")
|
||||
print()
|
||||
print(f"BRONZE TARGET: ROI=88.55% T=2155 DD=15.05%")
|
||||
roi_ok = abs(roi - 88.55) < 1.0
|
||||
dd_ok = abs(max_dd - 15.05) < 0.5
|
||||
t_ok = n == 2155
|
||||
print(f"ROI match: {'PASS' if roi_ok else 'FAIL'} (diff={roi-88.55:+.2f}pp)")
|
||||
print(f"DD match: {'PASS' if dd_ok else 'FAIL'} (diff={max_dd-15.05:+.2f}pp)")
|
||||
print(f"T match: {'PASS' if t_ok else 'FAIL'} (got {n})")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user