From 047571921ec778e1a4a5110a88fe5a4794279fbb Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Tue, 5 May 2026 03:23:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E5=90=AF=E6=97=B6=E6=9F=A5?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E6=89=80=E9=AA=8C=E8=AF=81=E6=8C=81=E4=BB=93?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=EF=BC=8C=E5=B9=BD=E7=81=B5?= =?UTF-8?q?=E4=BB=93=E4=BD=8D=E8=87=AA=E5=8A=A8=E6=A0=87=E8=AE=B0=20closed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- trader.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/trader.go b/trader.go index 2ccb314..2ce78f7 100644 --- a/trader.go +++ b/trader.go @@ -1977,6 +1977,21 @@ func (t *Trader) restoreOpenPositions() { } } pos.DBTradeID = tr.ID + + // Verify position still exists on exchange — if not, mark as closed + posMissing := false + if t.bitget != nil && (pos.LongLeg.Exchange == ExBitget || pos.ShortLeg.Exchange == ExBitget) { + bgSymbol := tr.Coin + "USDT" + if bgSize, _ := t.bitget.CheckPosition(bgSymbol); bgSize <= 0 { + log.Printf("[Trader] Trade %d (%s): Bitget position not found on exchange, marking as closed", tr.ID, tr.Coin) + posMissing = true + } + } + if posMissing { + t.db.SetTradeStatus(tr.ID, "closed") + continue + } + t.positions[tr.Coin] = pos // Prevent immediate re-trading of the same coin t.lastTradeTime[tr.Coin] = tr.OpenedAt