mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
更新 MakerEngine,清理历史挂单并重置状态;修复 getPosition 函数以处理未定义的选项
This commit is contained in:
@@ -227,6 +227,8 @@ export class MakerEngine {
|
|||||||
await this.exchange.cancelAllOrders({ symbol: this.config.symbol });
|
await this.exchange.cancelAllOrders({ symbol: this.config.symbol });
|
||||||
this.pendingCancelOrders.clear();
|
this.pendingCancelOrders.clear();
|
||||||
unlockOperating(this.locks, this.timers, this.pending, "LIMIT");
|
unlockOperating(this.locks, this.timers, this.pending, "LIMIT");
|
||||||
|
this.openOrders = [];
|
||||||
|
this.emitUpdate();
|
||||||
this.tradeLog.push("order", "启动时清理历史挂单");
|
this.tradeLog.push("order", "启动时清理历史挂单");
|
||||||
this.initialOrderResetDone = true;
|
this.initialOrderResetDone = true;
|
||||||
return true;
|
return true;
|
||||||
@@ -234,6 +236,8 @@ export class MakerEngine {
|
|||||||
if (isUnknownOrderError(error)) {
|
if (isUnknownOrderError(error)) {
|
||||||
this.tradeLog.push("order", "历史挂单已消失,跳过启动清理");
|
this.tradeLog.push("order", "历史挂单已消失,跳过启动清理");
|
||||||
this.initialOrderResetDone = true;
|
this.initialOrderResetDone = true;
|
||||||
|
this.openOrders = [];
|
||||||
|
this.emitUpdate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this.tradeLog.push("error", `启动撤单失败: ${String(error)}`);
|
this.tradeLog.push("error", `启动撤单失败: ${String(error)}`);
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ export function getPosition(snapshot: AsterAccountSnapshot | null, symbol: strin
|
|||||||
withExposure.sort((a, b) => Math.abs(Number(b.positionAmt)) - Math.abs(Number(a.positionAmt)))[0] ??
|
withExposure.sort((a, b) => Math.abs(Number(b.positionAmt)) - Math.abs(Number(a.positionAmt)))[0] ??
|
||||||
positions[0];
|
positions[0];
|
||||||
return {
|
return {
|
||||||
positionAmt: Number(selected.positionAmt) || 0,
|
positionAmt: Number(selected?.positionAmt) || 0,
|
||||||
entryPrice: Number(selected.entryPrice) || 0,
|
entryPrice: Number(selected?.entryPrice) || 0,
|
||||||
unrealizedProfit: Number(selected.unrealizedProfit) || 0,
|
unrealizedProfit: Number(selected?.unrealizedProfit) || 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user