Per-strategy equity curves + $100K paper capital

Paper trader now tracks individual equity history per strategy
(strategy_equity dict with deque per strategy). Metrics file
exports per-strategy data for dashboard rendering.

Dashboard paper chart upgraded to 7 overlaid area series:
- Each strategy gets its own colored curve (green, blue, purple, etc.)
- 300px height for better visibility of multiple lines
- Color palette distinguishes strategies at a glance

$100K total capital: $10K per strategy × 7 + $30K reserve.

Exeria Charts evaluated: excellent library (Benzinga award winner,
Canvas/WebGL, exchange connectors) but requires npm+bundler —
not suitable for single-file dashboard. Lightweight-charts
remains the right choice for our architecture.
This commit is contained in:
ramseshk
2026-08-04 04:37:27 +00:00
parent 7a5fdf2f8d
commit 1ece7ec7c6
2 changed files with 33 additions and 4 deletions
+5
View File
@@ -83,6 +83,7 @@ STRATEGIES = {
trades_log: list[dict] = []
equity_history: list[dict] = []
strategy_equity: dict = {name: deque(maxlen=300) for name in STRATEGIES}
btc_prices: deque = deque(maxlen=120)
eth_prices: deque = deque(maxlen=120)
funding_rates: deque = deque(maxlen=100)
@@ -258,6 +259,8 @@ def simulate_fill(name: str, side: str, coin: str, price: float):
cfg["trades_today"] += 1
cfg["pnl_pct"] = cfg["pnl"] / cfg["allocation"] * 100
# Track per-strategy equity
strategy_equity[name].append({"t": time.time(), "v": cfg["allocation"] + cfg["pnl"]})
# ═══════════════════════ A-S Spread Capture ═══════════════════════
@@ -312,6 +315,7 @@ def simulate_avellaneda(btc_bid, btc_ask):
cfg["fee_paid"] += fee
cfg["trades_today"] += 1
cfg["pnl_pct"] = cfg["pnl"] / cfg["allocation"] * 100
strategy_equity["Avellaneda-Stoikov"].append({"t": time.time(), "v": cfg["allocation"] + cfg["pnl"]})
# ═══════════════════════ Metrics ═══════════════════════
@@ -332,6 +336,7 @@ def write_metrics():
"total_pnl_pct": total_pnl_pct,
"reserve": RESERVE,
"equity_history": equity_history[-600:],
"strategy_equity": {k: list(v)[-300:] for k, v in strategy_equity.items()},
"strategies": STRATEGIES,
"trades": trades_log[-200:],
"status": "running",