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.
134 lines
5.1 KiB
Python
Executable File
134 lines
5.1 KiB
Python
Executable File
"""
|
|
Boost sweep: find what constant boost+beta gives gold ROI=189.48%.
|
|
Uses actor-style loop, static vol_ok, gidx fix (T=2155 base).
|
|
Tests multiple (boost, beta) pairs to bracket the gold result.
|
|
"""
|
|
import sys, math, pathlib
|
|
import numpy as np
|
|
import pandas as pd
|
|
|
|
sys.path.insert(0, '/mnt/dolphinng5_predict')
|
|
sys.path.insert(0, '/mnt/dolphinng5_predict/nautilus_dolphin')
|
|
|
|
print("Importing...", flush=True)
|
|
from nautilus_dolphin.nautilus.proxy_boost_engine import create_boost_engine
|
|
print("Import done.", flush=True)
|
|
|
|
PARQUET_DIR = pathlib.Path('/mnt/dolphinng5_predict/vbt_cache')
|
|
VOL_P60_INWINDOW = 0.00009868
|
|
INITIAL_CAPITAL = 25000.0
|
|
|
|
ENG_KWARGS = dict(
|
|
max_hold_bars=120, min_irp_alignment=0.45, max_leverage=8.0,
|
|
vel_div_threshold=-0.02, vel_div_extreme=-0.05,
|
|
min_leverage=0.5, leverage_convexity=3.0,
|
|
fraction=0.20, fixed_tp_pct=0.0095, stop_pct=1.0,
|
|
use_direction_confirm=True, dc_lookback_bars=7, dc_min_magnitude_bps=0.75,
|
|
dc_skip_contradicts=True, dc_leverage_boost=1.0, dc_leverage_reduce=0.5,
|
|
use_asset_selection=True, use_sp_fees=True, use_sp_slippage=True,
|
|
sp_maker_entry_rate=0.62, sp_maker_exit_rate=0.50,
|
|
use_ob_edge=True, ob_edge_bps=5.0, ob_confirm_rate=0.40,
|
|
lookback=100, use_alpha_layers=True, use_dynamic_leverage=True, seed=42,
|
|
)
|
|
|
|
def make_engine():
|
|
eng = create_boost_engine(mode='d_liq', initial_capital=INITIAL_CAPITAL, **ENG_KWARGS)
|
|
eng.set_esoteric_hazard_multiplier(0.0)
|
|
return eng
|
|
|
|
def compute_vol_ok(df):
|
|
btc_f = df['BTCUSDT'].values.astype('float64')
|
|
n = len(btc_f)
|
|
vol_ok = np.zeros(n, dtype=bool)
|
|
for j in range(50, n):
|
|
seg = btc_f[max(0, j-50):j]
|
|
diffs = np.diff(seg)
|
|
denom = seg[:-1]
|
|
if np.any(denom == 0):
|
|
continue
|
|
v = float(np.std(diffs / denom))
|
|
if math.isfinite(v) and v > 0:
|
|
vol_ok[j] = v > VOL_P60_INWINDOW
|
|
return vol_ok
|
|
|
|
def run_full(boost, beta):
|
|
"""Run 56-day backtest with constant boost+beta injected each day."""
|
|
eng = make_engine()
|
|
files = sorted(PARQUET_DIR.glob('*.parquet'))
|
|
total_T = 0
|
|
|
|
for pf in files:
|
|
date_str = pf.stem
|
|
df = pd.read_parquet(pf)
|
|
eng.begin_day(date_str)
|
|
eng._day_base_boost = boost
|
|
eng._day_beta = beta
|
|
|
|
data_arr = df.values
|
|
cols = df.columns.tolist()
|
|
vd_idx = cols.index('vel_div') if 'vel_div' in cols else -1
|
|
v50_idx = cols.index('v50_lambda_max_velocity') if 'v50_lambda_max_velocity' in cols else -1
|
|
v750_idx = cols.index('v750_lambda_max_velocity') if 'v750_lambda_max_velocity' in cols else -1
|
|
i50_idx = cols.index('instability_50') if 'instability_50' in cols else -1
|
|
usdt_idxs = [(c, cols.index(c)) for c in cols if c.endswith('USDT')]
|
|
vol_ok = compute_vol_ok(df)
|
|
|
|
for i in range(len(df)):
|
|
row_vals = data_arr[i]
|
|
vd_raw = float(row_vals[vd_idx]) if vd_idx != -1 else float('nan')
|
|
if not math.isfinite(vd_raw):
|
|
eng._global_bar_idx += 1
|
|
continue
|
|
|
|
v750 = float(row_vals[v750_idx]) if v750_idx != -1 and math.isfinite(float(row_vals[v750_idx])) else 0.0
|
|
inst50 = float(row_vals[i50_idx]) if i50_idx != -1 and math.isfinite(float(row_vals[i50_idx])) else 0.0
|
|
v50 = float(row_vals[v50_idx]) if v50_idx != -1 and math.isfinite(float(row_vals[v50_idx])) else 0.0
|
|
prices = {sym: float(row_vals[ci]) for sym, ci in usdt_idxs
|
|
if math.isfinite(float(row_vals[ci])) and float(row_vals[ci]) > 0}
|
|
|
|
prev_pos = eng.position
|
|
if hasattr(eng, 'pre_bar_proxy_update'):
|
|
eng.pre_bar_proxy_update(inst50, v750)
|
|
|
|
eng.step_bar(
|
|
bar_idx=i, vel_div=vd_raw, prices=prices,
|
|
v50_vel=v50, v750_vel=v750,
|
|
vol_regime_ok=bool(vol_ok[i]),
|
|
)
|
|
if prev_pos is not None and eng.position is None:
|
|
total_T += 1
|
|
|
|
eng.end_day()
|
|
|
|
roi = 100 * (eng.capital / INITIAL_CAPITAL - 1)
|
|
return total_T, eng.capital, roi
|
|
|
|
def main():
|
|
print(f"\n{'boost':>6} {'beta':>5} {'T':>5} {'cap':>10} {'ROI%':>8}", flush=True)
|
|
print("-" * 40, flush=True)
|
|
|
|
# Sweep: boost in [1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2] x beta in [0.0, 0.5, 0.8]
|
|
candidates = [
|
|
(1.0, 0.0), # baseline (no ACB)
|
|
(1.0, 0.5), # beta-only (no boost, mid beta)
|
|
(1.0, 0.8), # beta-high only
|
|
(1.5, 0.5), # signals=2 mid-beta
|
|
(1.5, 0.8), # signals=2 high-beta
|
|
(1.7, 0.5), # signals=3 mid-beta
|
|
(1.7, 0.8), # signals=3 high-beta
|
|
(1.8, 0.5), # signals=4 mid-beta
|
|
(1.8, 0.8), # signals=4 high-beta (max likely)
|
|
(2.0, 0.8), # above max
|
|
(2.2, 0.8), # extrapolate
|
|
]
|
|
|
|
for boost, beta in candidates:
|
|
T, cap, roi = run_full(boost, beta)
|
|
marker = ' <-- gold target' if abs(roi - 189.48) < 5 else ''
|
|
print(f"{boost:>6.2f} {beta:>5.1f} {T:>5d} ${cap:>9,.0f} {roi:>7.2f}%{marker}", flush=True)
|
|
|
|
print(f"\nGold target: T=2155, ROI=+189.48%", flush=True)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|