mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
增强趋势引擎逻辑,优化止损处理,添加返回结果对象以指示平仓状态,提升交易策略的可追踪性和稳定性。
This commit is contained in:
@@ -579,6 +579,7 @@ export class TrendEngine {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (derivedLoss || snapshotLoss) {
|
if (derivedLoss || snapshotLoss) {
|
||||||
|
const result = { closed: false, pnl };
|
||||||
try {
|
try {
|
||||||
if (this.openOrders.length > 0) {
|
if (this.openOrders.length > 0) {
|
||||||
const orderIdList = this.openOrders.map((order) => order.orderId);
|
const orderIdList = this.openOrders.map((order) => order.orderId);
|
||||||
@@ -636,6 +637,7 @@ export class TrendEngine {
|
|||||||
},
|
},
|
||||||
{ qtyStep: this.config.qtyStep }
|
{ qtyStep: this.config.qtyStep }
|
||||||
);
|
);
|
||||||
|
result.closed = true;
|
||||||
this.tradeLog.push("close", `止损平仓: ${direction === "long" ? "SELL" : "BUY"}`);
|
this.tradeLog.push("close", `止损平仓: ${direction === "long" ? "SELL" : "BUY"}`);
|
||||||
// 记录止损时间以便短期内抑制再次入场
|
// 记录止损时间以便短期内抑制再次入场
|
||||||
this.lastStopLossAt = Date.now();
|
this.lastStopLossAt = Date.now();
|
||||||
@@ -645,8 +647,9 @@ export class TrendEngine {
|
|||||||
} else {
|
} else {
|
||||||
this.tradeLog.push("error", `止损平仓失败: ${String(err)}`);
|
this.tradeLog.push("error", `止损平仓失败: ${String(err)}`);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return { closed: true, pnl };
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { closed: false, pnl };
|
return { closed: false, pnl };
|
||||||
|
|||||||
Reference in New Issue
Block a user