mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 08:18:07 +00:00
feat: 优化平仓逻辑,确保正确处理订单数量并提示交易所关闭整个仓位
This commit is contained in:
@@ -338,12 +338,16 @@ export async function marketClose(
|
||||
if (isOperating(locks, type)) 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 = {
|
||||
symbol,
|
||||
side,
|
||||
type,
|
||||
quantity: roundQtyDownToStep(quantity, qtyStep),
|
||||
quantity: safeQty,
|
||||
reduceOnly: "true",
|
||||
// Hint exchanges (like Paradex) to close the whole position and tolerate omitted size
|
||||
closePosition: "true",
|
||||
};
|
||||
await deduplicateOrders(adapter, symbol, openOrders, locks, timers, pendings, type, side, log);
|
||||
lockOperating(locks, timers, pendings, type, log);
|
||||
|
||||
Reference in New Issue
Block a user