fix(metrics): replace inflated PnL formula; drop fake calibration_score
CI/CD / build-and-push (push) Failing after 1m20s
CI/CD / build-and-push (push) Failing after 1m20s
total_pnl now uses edge_net × net_cost instead of (0.5 - entry_price) × shares. The old formula overestimated BUY_NO trades at low entry prices by 3–10× because buying at price 0.158 yields 3164 shares — any exit-at-0.5 assumption produced $1072 PnL on $500 deployed. edge_net × net_cost is bounded by net_cost per trade and uses the model's own signal, giving $122 for the same position. calibration_score is now None (null in API) instead of 1 - 2×|avg_edge|. That formula was not a real calibration: it requires knowing market resolutions (YES=1/NO=0) which we do not store yet. Returning null is more honest than returning 0.0 or a meaningless proxy. Fix 3 will compute it from closed trades. check_promotion_thresholds updated to handle None calibration (null → not ready). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+8
-2
@@ -112,14 +112,20 @@ async def get_summary():
|
||||
"cash_available": max(0.0, paper_bankroll - total_deployed),
|
||||
"legacy_incomplete_count": legacy_count,
|
||||
"reentry_guard_blocks_24h": len(inverted),
|
||||
# Metrics from latest metrics_daily snapshot (computed by MetricsTracker).
|
||||
# total_pnl: estimated unrealized PnL for open trades in the current bot
|
||||
# session — uses edge_net × net_cost (model edge on deployed
|
||||
# capital). Resets to 0 on pod restart until Fix 3 is applied.
|
||||
# calibration_score: null until market resolution data is available
|
||||
# (requires close_price / outcome per closed trade).
|
||||
"total_pnl": latest.get("total_pnl", 0),
|
||||
"win_rate": latest.get("win_rate", 0),
|
||||
"sharpe_ratio": latest.get("sharpe_ratio", 0),
|
||||
"calibration_score": latest.get("calibration_score", 0),
|
||||
"calibration_score": latest.get("calibration_score"), # null if unavailable
|
||||
"promotion_ready": (
|
||||
latest.get("sharpe_ratio", 0) >= 0.5
|
||||
and latest.get("win_rate", 0) >= 0.52
|
||||
and latest.get("calibration_score", 0) >= 0.7
|
||||
and (latest.get("calibration_score") or 0) >= 0.7 # null → not ready
|
||||
and len(all_trades) >= 50
|
||||
),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user