Board: show entry/last price + uPnL $ and % on open positions

So you can confirm the bought price next to the unrealized P&L.

Profit-lock tiers verified out-of-sample (lock_mid: 8:3,15:9,25:18,40:30 on the
prior-low trail) — test avgR 0.127 vs 0.123 baseline, win 55% vs 46%, not
overfit; already the .env default. The flashy lock_only_mid (+0.40R in-sample)
was rejected as overfit (collapsed to 0.187 test).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
momentum devandClaude Opus 4.8 committed 2026-06-17 16:12:04 -04:00
1 parent 9b3697be98
commit 476d30e3d1
1 file changed
+16 -2
+16 -2
View File
@@ -500,18 +500,32 @@ def _render_board(con):
pos_ev = con.execute("SELECT payload_json FROM events WHERE event_type='account_positions_updated' "
"ORDER BY timestamp DESC LIMIT 1").fetchall()
pt = Table(title="open positions", box=box.SIMPLE)
pt.add_column("symbol"); pt.add_column("qty", justify="right"); pt.add_column("uPnL", justify="right")
for c in ("symbol", "qty", "entry", "last", "uPnL $", "uPnL %"):
pt.add_column(c, justify="left" if c == "symbol" else "right")
if pos_ev:
for p in (json.loads(pos_ev[0][0]).get("positions") or []):
# the sync stores it as 'unrealized_pnl'; fall back to 'unrealized_pl'
upl = p.get("unrealized_pnl")
if upl is None:
upl = p.get("unrealized_pl")
entry = p.get("avg_entry_price")
last = p.get("current_price")
pct = p.get("unrealized_pnl_pct")
try:
upl_str = f"[{'green' if float(upl) >= 0 else 'red'}]{float(upl):+.0f}[/]"
except (TypeError, ValueError):
upl_str = "-"
pt.add_row(str(p.get("symbol")), str(p.get("quantity") or p.get("qty") or ""), upl_str)
try:
pct_str = f"[{'green' if float(pct) >= 0 else 'red'}]{float(pct) * 100:+.1f}%[/]"
except (TypeError, ValueError):
pct_str = "-"
pt.add_row(
str(p.get("symbol")),
str(p.get("quantity") or p.get("qty") or ""),
f"{float(entry):.2f}" if entry not in (None, "") else "-",
f"{float(last):.2f}" if last not in (None, "") else "-",
upl_str, pct_str,
)
risk = con.execute("SELECT timestamp, message FROM events WHERE event_type='risk_rule_triggered' "
"ORDER BY timestamp DESC LIMIT 4").fetchall()