fix: Dashboard cycle coherence — scoring_run_id linkage + cycle-scoped cards
- Backend: get_status() now resolves scoring_run_id by querying trade_entry_prices within the cycle time window, fixing the mismatch between cycle run_id and the id actually written to trades - Dashboard: Trades du cycle filters by scoring_run_id (no stale fallback) - Dashboard: Pattern du cycle shows only patterns added in last cycle (created_at >= started_at), renamed from Top Patterns - Dashboard: Dernier Cycle now shows 4 stats (patterns/scorés/loggés/fermés) + IA commentary snippet - Dashboard: P&L simulated mode bottom half shows open/closed/capital/profit - Dashboard: Régime Macro shows top 4 scenario score bars Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1090,6 +1090,25 @@ def get_status() -> Dict[str, Any]:
|
||||
recent = get_cycle_runs(limit=1)
|
||||
last = recent[0] if recent else None
|
||||
|
||||
# Enrich last_cycle with the scoring_run_id used for trade_entry_prices
|
||||
if last:
|
||||
try:
|
||||
from services.database import get_conn
|
||||
_conn = get_conn()
|
||||
started = (last.get("started_at") or "").replace(" ", "T")
|
||||
completed = last.get("completed_at") or ""
|
||||
if started and completed:
|
||||
row = _conn.execute(
|
||||
"SELECT run_id FROM trade_entry_prices WHERE run_id >= ? AND run_id <= ?"
|
||||
" ORDER BY run_id DESC LIMIT 1",
|
||||
(started, completed),
|
||||
).fetchone()
|
||||
if row:
|
||||
last = dict(last)
|
||||
last["scoring_run_id"] = row["run_id"]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return {
|
||||
**_current_status,
|
||||
"enabled": enabled,
|
||||
|
||||
Reference in New Issue
Block a user