mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
feat: 更新网格引擎,添加启动撤单未完成时的处理逻辑,优化撤单与新订单的交互
This commit is contained in:
@@ -477,6 +477,12 @@ export class GridEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async syncGridSimple(price: number): Promise<void> {
|
private async syncGridSimple(price: number): Promise<void> {
|
||||||
|
// 启动撤单未完成前,禁止铺网/下单,避免新单被启动撤单冲掉造成“消失待判定”
|
||||||
|
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 ---
|
// --- 0) If there is an existing net position, enforce "exit-first" before any ENTRY ---
|
||||||
const hasNetLong = this.position.positionAmt > EPSILON;
|
const hasNetLong = this.position.positionAmt > EPSILON;
|
||||||
const hasNetShort = this.position.positionAmt < -EPSILON;
|
const hasNetShort = this.position.positionAmt < -EPSILON;
|
||||||
@@ -1172,6 +1178,15 @@ export class GridEngine {
|
|||||||
this.log("error", `启动撤单失败: ${extractMessage(error)}`);
|
this.log("error", `启动撤单失败: ${extractMessage(error)}`);
|
||||||
} finally {
|
} finally {
|
||||||
this.startupCancelDone = true;
|
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 = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user