From dd63d1495674c68ecd45fbfd6a9cf593f429283a Mon Sep 17 00:00:00 2001 From: daijingyang Date: Sat, 30 May 2026 13:01:16 +0800 Subject: [PATCH] fix(notifier): correct position snapshot P&L sign and remove duplicate + prefix `sign="+"` combined with `pnl:>+8,.0f` produced `++8.0%` and `+$ +39` for winners; losers rendered `$ -1` with no leading sign before `$`. Co-Authored-By: Claude Sonnet 4.6 --- src/notifier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notifier.py b/src/notifier.py index c46e2a6..34f429c 100644 --- a/src/notifier.py +++ b/src/notifier.py @@ -672,8 +672,8 @@ def _append_position_snapshot(lines: list[str], total_value: float | None) -> No def _row_line(r: tuple) -> str: sym, qty, avg, curr, mv, pnl = r pct = ((curr / avg - 1) * 100) if avg else 0 - sign = "+" if pnl >= 0 else "" - return f" {sym:<6} {sign}${pnl:>+8,.0f} ({sign}{pct:+.1f}%)" + sign = "+" if pnl >= 0 else "-" + return f" {sym:<6} {sign}${abs(pnl):>8,.0f} ({pct:+.1f}%)" # r[5] is positions.unrealized_pnl. SQLite allows NULL on that # column (broker race / stale snapshot can leave it unset for a