From 88290882f9558a6f0a9b5794353e8c0b069d63d0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Mar 2026 07:08:49 +0000 Subject: [PATCH] fix: add risk_distance to positions API query SQL SELECT was missing risk_distance column, causing fallback to abs(entry-sl) which is wrong after TP1 moves SL to breakeven --- backend/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/main.py b/backend/main.py index 06055a0..38fb6d7 100644 --- a/backend/main.py +++ b/backend/main.py @@ -711,13 +711,13 @@ async def paper_positions( if strategy == "all": rows = await async_fetch( "SELECT id, symbol, direction, score, tier, strategy, entry_price, entry_ts, " - "tp1_price, tp2_price, sl_price, tp1_hit, status, atr_at_entry, score_factors " + "tp1_price, tp2_price, sl_price, tp1_hit, status, atr_at_entry, score_factors, risk_distance " "FROM paper_trades WHERE status IN ('active','tp1_hit') ORDER BY entry_ts DESC" ) else: rows = await async_fetch( "SELECT id, symbol, direction, score, tier, strategy, entry_price, entry_ts, " - "tp1_price, tp2_price, sl_price, tp1_hit, status, atr_at_entry, score_factors " + "tp1_price, tp2_price, sl_price, tp1_hit, status, atr_at_entry, score_factors, risk_distance " "FROM paper_trades WHERE status IN ('active','tp1_hit') AND strategy = $1 ORDER BY entry_ts DESC", strategy, )