From c5b43364bee5ade002911872a6c1e700cfd3dd51 Mon Sep 17 00:00:00 2001 From: momentum dev Date: Tue, 28 Jul 2026 09:39:48 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20don't=20fabricate=20last=5Fequity=20for?= =?UTF-8?q?=20Tradier=20=E2=80=94=20realized=20P&L=20read=20$0=20forever?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dashboard realized = broker equity delta (equity - last_equity). Tradier balances carry no prior-session-close field and translate_balances echoed current equity, making the delta permanently zero (win rate populated from closed events while dollars showed $0). Absent last_equity now routes the projection to its closed-events fallback. Co-Authored-By: Claude Fable 5 --- tradier_broker/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tradier_broker/client.py b/tradier_broker/client.py index 8406f8f..0a1b788 100644 --- a/tradier_broker/client.py +++ b/tradier_broker/client.py @@ -164,7 +164,13 @@ def translate_balances(b: dict) -> dict: ) return { "equity": _s(b.get("total_equity") or 0), - "last_equity": _s(b.get("total_equity") or 0), + # Tradier has NO prior-session-close equity field. Do NOT fake it with + # current equity: the dashboard's realized P&L is the broker equity + # delta (equity - last_equity), which then reads $0 forever. Absent + # last_equity makes the projection fall back to summing + # position_closed events — honest, and correct now that fills/closes + # are journaled reliably. + "last_equity": None, "cash": _s(b.get("total_cash") or 0), "buying_power": _s(buying_power), "status": "ACTIVE",