mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
feat: 移除不必要的数量参数,优化止损和市价平仓订单逻辑以确保精确处理
This commit is contained in:
@@ -247,7 +247,7 @@ export async function placeStopLossOrder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const priceTick = opts?.priceTick ?? 0.1;
|
const priceTick = opts?.priceTick ?? 0.1;
|
||||||
const qtyStep = opts?.qtyStep ?? 0.001;
|
|
||||||
const params: CreateOrderParams = {
|
const params: CreateOrderParams = {
|
||||||
symbol,
|
symbol,
|
||||||
side,
|
side,
|
||||||
@@ -255,7 +255,6 @@ export async function placeStopLossOrder(
|
|||||||
stopPrice: roundDownToTick(stopPrice, priceTick),
|
stopPrice: roundDownToTick(stopPrice, priceTick),
|
||||||
closePosition: "true",
|
closePosition: "true",
|
||||||
timeInForce: "GTC",
|
timeInForce: "GTC",
|
||||||
quantity,
|
|
||||||
triggerType: "STOP_LOSS",
|
triggerType: "STOP_LOSS",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -343,16 +342,14 @@ export async function marketClose(
|
|||||||
const type = "MARKET";
|
const type = "MARKET";
|
||||||
if (isOperating(locks, type)) return;
|
if (isOperating(locks, type)) return;
|
||||||
if (!enforceMarkPriceGuard(side, guard?.expectedPrice ?? null, guard, log, "市价平仓")) return;
|
if (!enforceMarkPriceGuard(side, guard?.expectedPrice ?? null, guard, log, "市价平仓")) return;
|
||||||
const qtyStep = opts?.qtyStep ?? 0.001;
|
|
||||||
const roundedQty = roundQtyDownToStep(quantity, qtyStep);
|
|
||||||
const safeQty = roundedQty > 0 ? roundedQty : quantity;
|
|
||||||
const params: CreateOrderParams = {
|
const params: CreateOrderParams = {
|
||||||
symbol,
|
symbol,
|
||||||
side,
|
side,
|
||||||
type,
|
type,
|
||||||
quantity: safeQty,
|
|
||||||
closePosition: "true",
|
closePosition: "true",
|
||||||
};
|
};
|
||||||
|
|
||||||
await deduplicateOrders(adapter, symbol, openOrders, locks, timers, pendings, type, side, log);
|
await deduplicateOrders(adapter, symbol, openOrders, locks, timers, pendings, type, side, log);
|
||||||
lockOperating(locks, timers, pendings, type, log);
|
lockOperating(locks, timers, pendings, type, log);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user