From 51e0ce2bea91fabdf2b63ce582d141f3c4ddd4e3 Mon Sep 17 00:00:00 2001 From: discountry Date: Wed, 8 Oct 2025 04:48:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=BD=91=E6=A0=BC?= =?UTF-8?q?=E5=BC=95=E6=93=8E=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=92=A4=E5=8D=95=E6=9C=AA=E5=AE=8C=E6=88=90=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=92=A4=E5=8D=95=E4=B8=8E=E6=96=B0=E8=AE=A2=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/strategy/grid-engine.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/strategy/grid-engine.ts b/src/strategy/grid-engine.ts index 1c028ca..f9a3eed 100644 --- a/src/strategy/grid-engine.ts +++ b/src/strategy/grid-engine.ts @@ -477,6 +477,12 @@ export class GridEngine { } private async syncGridSimple(price: number): Promise { + // 启动撤单未完成前,禁止铺网/下单,避免新单被启动撤单冲掉造成“消失待判定” + if (!this.startupCancelDone) { + this.log("info", "启动撤单未完成,等待后再部网"); + this.lastUpdated = this.now(); + return; + } // --- 0) If there is an existing net position, enforce "exit-first" before any ENTRY --- const hasNetLong = this.position.positionAmt > EPSILON; const hasNetShort = this.position.positionAmt < -EPSILON; @@ -1172,6 +1178,15 @@ export class GridEngine { this.log("error", `启动撤单失败: ${extractMessage(error)}`); } finally { this.startupCancelDone = true; + // 清理本地判定/抑制状态,避免被启动撤单冲掉的新单在本地留下“待判定”残留 + this.prevActiveIds.clear(); + this.orderIntentById.clear(); + this.awaitingByLevel.clear(); + this.pendingKeyUntil.clear(); + this.pendingLongLevels.clear(); + this.pendingShortLevels.clear(); + this.closeKeyBySourceLevel.clear(); + this.immediateCloseToPlace = []; } }