mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
fix stoploss
This commit is contained in:
@@ -84,6 +84,7 @@ export class OffsetMakerEngine {
|
|||||||
private lastSpotWallet = 0;
|
private lastSpotWallet = 0;
|
||||||
private spotKlineUp: boolean | null = null;
|
private spotKlineUp: boolean | null = null;
|
||||||
private lastSpotBuyGuardLogged = false;
|
private lastSpotBuyGuardLogged = false;
|
||||||
|
private lastSpotStopSkipped = false;
|
||||||
|
|
||||||
private timer: ReturnType<typeof setInterval> | null = null;
|
private timer: ReturnType<typeof setInterval> | null = null;
|
||||||
private processing = false;
|
private processing = false;
|
||||||
@@ -774,7 +775,19 @@ export class OffsetMakerEngine {
|
|||||||
// For spot: use balance-derived size; if loss exceeds threshold, market sell to exit.
|
// For spot: use balance-derived size; if loss exceeds threshold, market sell to exit.
|
||||||
if (this.marketType === "spot") {
|
if (this.marketType === "spot") {
|
||||||
const absPosition = Math.abs(position.positionAmt);
|
const absPosition = Math.abs(position.positionAmt);
|
||||||
if (absPosition < EPS) return;
|
if (absPosition < EPS) {
|
||||||
|
this.lastSpotStopSkipped = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const minStopQty = Number.isFinite(this.minBaseAmount) ? this.minBaseAmount! : null;
|
||||||
|
if (minStopQty != null && minStopQty > 0 && absPosition + EPS < minStopQty) {
|
||||||
|
if (!this.lastSpotStopSkipped) {
|
||||||
|
this.tradeLog.push("info", "现货持仓低于最小平仓数量,跳过止损检查");
|
||||||
|
this.lastSpotStopSkipped = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.lastSpotStopSkipped = false;
|
||||||
const pnl = computePositionPnl(position, bidPrice, askPrice);
|
const pnl = computePositionPnl(position, bidPrice, askPrice);
|
||||||
const triggerStop = shouldStopLoss(position, bidPrice, askPrice, this.config.lossLimit);
|
const triggerStop = shouldStopLoss(position, bidPrice, askPrice, this.config.lossLimit);
|
||||||
if (!triggerStop) return;
|
if (!triggerStop) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user