From 852cc2f319dfb119f9751d167bede2c171d9e064 Mon Sep 17 00:00:00 2001 From: HelloByeAll <53550140+HelloByeAll@users.noreply.github.com> Date: Fri, 24 Jul 2026 21:12:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E:=20=E5=9C=A8=E5=9B=9E?= =?UTF-8?q?=E6=B5=8B=E5=87=80=E5=80=BC=E5=9B=BE=E5=8F=A0=E5=8A=A0=E4=BB=93?= =?UTF-8?q?=E4=BD=8D=E6=9B=B2=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backtest/charts/StrategyNavChart.tsx | 58 ++++++++++++++++--- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/backtest/charts/StrategyNavChart.tsx b/frontend/src/pages/backtest/charts/StrategyNavChart.tsx index 30a998b..06c4fdf 100644 --- a/frontend/src/pages/backtest/charts/StrategyNavChart.tsx +++ b/frontend/src/pages/backtest/charts/StrategyNavChart.tsx @@ -25,6 +25,18 @@ export function StrategyNavChart({ result }: Props) { const benchmarkValues = dates.map(d => benchmarkByDate.get(d) ?? null) const hasBenchmark = benchmarkValues.some(v => v != null) const ddValues = result.drawdown_curve.map(r => r.value * 100) + const positionValues = result.equity_curve.map(r => { + if (r.exposure != null) return r.exposure * 100 + if (r.cash != null && r.value > 0) { + return Math.max(0, Math.min(100, (1 - r.cash / r.value) * 100)) + } + return null + }) + const hasPosition = positionValues.some(v => v != null) + const navColor = '#3b82f6' + const benchmarkColor = '#64748b' + const drawdownColor = '#f04438' + const positionColor = '#f59e0b' return { animation: false, @@ -91,6 +103,15 @@ export function StrategyNavChart({ result }: Props) { splitLine: { lineStyle: { color: ct.grid } }, axisLine: { show: false }, }, + ...(hasPosition ? [{ + type: 'value', + gridIndex: 0, + min: 0, + max: 100, + show: false, + splitLine: { show: false }, + axisLine: { show: false }, + }] : []), ], dataZoom: [ { @@ -127,10 +148,11 @@ export function StrategyNavChart({ result }: Props) { if (p.value == null) continue const isDrawdown = p.seriesName === '回撤' const isBenchmark = p.seriesName === '同期上证指数' + const isPosition = p.seriesName === '仓位' html += `