diff --git a/api/main.py b/api/main.py
index fbfb4fd..d51a100 100644
--- a/api/main.py
+++ b/api/main.py
@@ -9,6 +9,7 @@ GET /api/approval-queue pending approvals only
GET /api/criteria?symbol=XYZ per-criterion pass/fail breakdown
GET /api/bars?symbol=XYZ[&minutes=60] recent 1-min bars for a sparkline
GET /api/chart?symbol=XYZ[&hours=24] 24h candles + fill markers + entry/stop/target levels
+GET /api/decisions[?symbol=&limit=&date=] entry_gate_evaluated decision receipts (plan 014)
GET /static/vendor/... vendored JS libs (e.g. Lightweight Charts)
POST /api/trading/approvals/approve {"order_id": ..., "approved_by"?: ...}
POST /api/trading/approvals/reject {"order_id": ..., "reason"?: ...}
@@ -47,6 +48,7 @@ from storage.projections import (
query_catalyst_feed,
query_daily_performance,
query_fills_feed,
+ query_gate_receipts,
query_armed_triggers,
query_equity_curve,
query_order_lifecycle_snapshot,
@@ -89,6 +91,19 @@ def _eastern_session_date():
return datetime.now(ZoneInfo("America/New_York")).date()
+def _to_epoch_et(ts) -> int:
+ """Naive US/Eastern timestamp (datetime or ISO string) -> UTC epoch seconds.
+
+ Event timestamps (and ``minute_bars``) are stored naive-ET; both /api/chart
+ (plan 013) and /api/decisions (plan 014) hand the browser epoch seconds so
+ Lightweight Charts — and the JS merging the two marker sets — never does
+ timezone math."""
+ from zoneinfo import ZoneInfo
+
+ dt = ts if isinstance(ts, datetime) else datetime.fromisoformat(str(ts))
+ return int(dt.replace(tzinfo=ZoneInfo("America/New_York")).timestamp())
+
+
def _available_dates(store) -> list[str]:
"""Distinct session dates with account data — populates the date picker so
you can switch from LIVE to review a past day."""
@@ -384,11 +399,7 @@ class DashboardState:
cutoff_et = now_et - timedelta(hours=hours)
cutoff_naive = cutoff_et.replace(tzinfo=None) # naive ET, matches storage
cutoff_epoch = int(cutoff_et.timestamp())
-
- def to_epoch(naive_et_ts) -> int:
- dt = naive_et_ts if isinstance(naive_et_ts, datetime) \
- else datetime.fromisoformat(str(naive_et_ts))
- return int(dt.replace(tzinfo=et).timestamp())
+ to_epoch = _to_epoch_et
with self._lock:
try:
@@ -464,6 +475,23 @@ class DashboardState:
return {"symbol": symbol, "bars": bars, "markers": markers, "levels": levels}
+ def decisions(self, symbol: str | None = None, limit: int = 100,
+ for_date: str | None = None) -> list[dict]:
+ """Live decision-trace feed (plan 014): entry_gate_evaluated receipts
+ with a server-computed ``epoch`` per row (naive-ET storage; the chart
+ overlay and the panel never do timezone math client-side)."""
+ with self._lock:
+ store = self.open_store()
+ try:
+ rows = query_gate_receipts(store, symbol=symbol, limit=limit,
+ for_date=for_date)
+ finally:
+ store.close()
+ for row in rows:
+ ts = row.get("timestamp")
+ row["epoch"] = _to_epoch_et(ts) if ts else None
+ return rows
+
def _with_service(self, fn):
if self.execution_service is None:
return None
@@ -666,6 +694,13 @@ class DashboardHandler(BaseHTTPRequestHandler):
symbol = (q.get("symbol") or [""])[0]
hours = int((q.get("hours") or ["24"])[0])
self._send_json(self.state.chart(symbol, hours))
+ elif route == "/api/decisions":
+ q = self._query()
+ symbol = (q.get("symbol") or [""])[0] or None
+ limit = min(int((q.get("limit") or ["100"])[0]), 500)
+ d = (q.get("date") or [""])[0] or None
+ self._send_json({"decisions":
+ self.state.decisions(symbol=symbol, limit=limit, for_date=d)})
elif route == "/api/attribution":
# per-component stage ratings (research/attribution.py); computed on
# demand — a handful of indexed event queries, fine per click
diff --git a/api/static/dashboard.html b/api/static/dashboard.html
index a58b64b..7edc271 100644
--- a/api/static/dashboard.html
+++ b/api/static/dashboard.html
@@ -238,6 +238,13 @@
.crit.fail { color: #c9a98a; }
.crit.skip { color: var(--muted); }
+ /* Decision Trace panel (plan 014) — per-gate chips + filterable receipt rows */
+ .dec-row { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-bottom: 1px solid #151a26; font: 500 12px var(--mono); flex-wrap: wrap; }
+ .dec-row:last-child { border-bottom: none; }
+ .gate-chip { display: inline-block; font: 600 10px var(--mono); padding: 2px 7px; border-radius: 4px; margin: 1px 2px; }
+ .gate-chip.pass { background: #12362a; color: var(--green); }
+ .gate-chip.fail { background: #38221a; color: var(--red); }
+
/* risk preview chip */
.risk { font: 500 11px var(--mono); color: var(--muted); }
.risk b { color: var(--text); font-weight: 600; }
@@ -559,6 +566,12 @@
Component Attribution per-stage ratings: discovery → signals (early vs late) → gates → execution → P&L · loads on open