From db52152ef9421da331ff9bdf88d8bf9403e3453f Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Sun, 3 May 2026 19:22:35 +0800 Subject: [PATCH] fix: stop-loss on spread reversal + current spread sign (#3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add explicit stop-loss when diffPct < -0.02 (价差反转,止损平仓) instead of relying on the convergence threshold to catch reversals - Dashboard currentSpread now direction-aware for HL→BG positions - Trade detail modal with clickable rows (previous commit partial) Before: reversals would exit via with wrong reason '价差收敛'. After: dedicated < -0.02 check with correct reason. --- trader.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/trader.go b/trader.go index fd3e9f9..ef1fc23 100644 --- a/trader.go +++ b/trader.go @@ -454,6 +454,12 @@ func (t *Trader) checkExit(pos *ArbPosition, bgP, hlP, diffPct float64, notifier exitReason = "价差收敛,止盈平仓" } + // Stop-loss: spread reversed (went negative) + if diffPct < -0.02 { + shouldExit = true + exitReason = "价差反转,止损平仓" + } + if elapsed > 30*time.Minute { shouldExit = true exitReason = "超时平仓"