feat(dashboard): mostra i disaster-SL attivi nella sezione LIVE
Lo shadow espone i bracket disaster-SL aperti (open_orders filtrati per label DISASTER_LABEL,
centralizzata in deribit.py): asset, stop price, size. La sezione LIVE li mostra
("disaster-SL attivi (-30%): ..." o "nessuno (flat)"). Test 28/28.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
-1
@@ -11,7 +11,7 @@ import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from src.backtest.harness import load
|
||||
from src.live.deribit import INSTRUMENT, DeribitRead, build_rebalance_order
|
||||
from src.live.deribit import DISASTER_LABEL, INSTRUMENT, DeribitRead, build_rebalance_order
|
||||
from src.strategies.trend_portfolio import CANONICAL, TrendPortfolio, resample_1d
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
||||
@@ -155,11 +155,25 @@ def shadow_report(offline: bool = False, equity_override: float | None = None) -
|
||||
live_trades.sort(key=lambda r: r["ts"], reverse=True)
|
||||
live_trades = live_trades[:12]
|
||||
|
||||
disaster_sls = []
|
||||
if client is not None:
|
||||
for a in ASSETS:
|
||||
try:
|
||||
for o in client.open_orders(INSTRUMENT[a]):
|
||||
if (o.get("label") or "") == DISASTER_LABEL:
|
||||
disaster_sls.append(dict(
|
||||
asset=a, instrument=INSTRUMENT[a],
|
||||
amount=float(o.get("amount") or 0),
|
||||
stop=float(o.get("trigger_price") or o.get("stop_price") or o.get("price") or 0)))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return dict(
|
||||
last_data=str(pd.Timestamp(last_ts, unit="ms", tz="UTC").date()),
|
||||
online=(client is not None and marks_src.get("BTC") == "mainnet"),
|
||||
real_equity=real_eq, equity=equity, eq_basis=eq_basis,
|
||||
pos_src=pos_src, assets=assets, orders=orders, live_trades=live_trades,
|
||||
disaster_sls=disaster_sls,
|
||||
flat=all(abs(targets[a]) < 1e-9 for a in ASSETS),
|
||||
paper_aligned=(paper_ts == last_ts),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user