From a7dec3fe1438dc62d36a3bc204f6f3be56e59951 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Mar 2026 07:13:52 +0000 Subject: [PATCH] fix: frontend use DB risk_distance + add entry time with ms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Both paper pages now read risk_distance from API (not hardcoded 2.0*0.7*ATR) - Added entry timestamp display (精确到毫秒) in active positions - Applies to both V5.1 and V5.2 paper pages --- frontend/app/paper-v52/page.tsx | 4 ++-- frontend/app/paper/page.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/app/paper-v52/page.tsx b/frontend/app/paper-v52/page.tsx index 62c98a7..b60907a 100644 --- a/frontend/app/paper-v52/page.tsx +++ b/frontend/app/paper-v52/page.tsx @@ -290,8 +290,7 @@ function ActivePositions({ strategy }: { strategy: StrategyFilter }) { const frScore = factors?.funding_rate?.score ?? 0; const liqScore = factors?.liquidation?.score ?? 0; const entry = p.entry_price || 0; - const atr = p.atr_at_entry || 1; - const riskDist = 2.0 * 0.7 * atr; + const riskDist = p.risk_distance || Math.abs(entry - (p.sl_price || entry)) || 1; const fullR = riskDist > 0 ? (p.direction === "LONG" ? (currentPrice - entry) / riskDist : (entry - currentPrice) / riskDist) : 0; const tp1R = riskDist > 0 ? (p.direction === "LONG" ? ((p.tp1_price || 0) - entry) / riskDist : (entry - (p.tp1_price || 0)) / riskDist) : 0; const unrealR = p.tp1_hit ? 0.5 * tp1R + 0.5 * fullR : fullR; @@ -322,6 +321,7 @@ function ActivePositions({ strategy }: { strategy: StrategyFilter }) {
入场: ${fmtPrice(p.entry_price)} + {new Date(p.entry_ts).toLocaleString("zh-CN", {hour12:false, month:"2-digit", day:"2-digit", hour:"2-digit", minute:"2-digit", second:"2-digit", fractionalSecondDigits:3} as any)} 现价: ${currentPrice ? fmtPrice(currentPrice) : "-"} TP1: ${fmtPrice(p.tp1_price)}{p.tp1_hit ? " ✅" : ""} TP2: ${fmtPrice(p.tp2_price)} diff --git a/frontend/app/paper/page.tsx b/frontend/app/paper/page.tsx index ca5eb96..9a73c05 100644 --- a/frontend/app/paper/page.tsx +++ b/frontend/app/paper/page.tsx @@ -226,8 +226,7 @@ function ActivePositions() { const holdMin = Math.round((Date.now() - p.entry_ts) / 60000); const currentPrice = wsPrices[p.symbol] || p.current_price || 0; const entry = p.entry_price || 0; - const atr = p.atr_at_entry || 1; - const riskDist = 2.0 * 0.7 * atr; + const riskDist = p.risk_distance || Math.abs(entry - (p.sl_price || entry)) || 1; // TP1触发后只剩半仓:0.5×TP1锁定 + 0.5×当前浮盈 const fullR = riskDist > 0 ? (p.direction === "LONG" ? (currentPrice - entry) / riskDist : (entry - currentPrice) / riskDist) : 0; const tp1R = riskDist > 0 ? (p.direction === "LONG" ? ((p.tp1_price || 0) - entry) / riskDist : (entry - (p.tp1_price || 0)) / riskDist) : 0; @@ -252,8 +251,9 @@ function ActivePositions() { {holdMin}m
-
+
入场: ${fmtPrice(p.entry_price)} + {new Date(p.entry_ts).toLocaleString("zh-CN", {hour12:false, year:undefined, month:"2-digit", day:"2-digit", hour:"2-digit", minute:"2-digit", second:"2-digit", fractionalSecondDigits:3} as any)} 现价: ${currentPrice ? fmtPrice(currentPrice) : "-"} TP1: ${fmtPrice(p.tp1_price)}{p.tp1_hit ? " ✅" : ""} TP2: ${fmtPrice(p.tp2_price)}