feat: 优化Paradex网关的订单金额处理逻辑,确保在平仓时仅对市场订单省略金额参数

This commit is contained in:
discountry
2025-10-08 20:00:08 +08:00
parent dbe8df6934
commit b36c1dce0f
+5 -5
View File
@@ -586,8 +586,8 @@ export class ParadexGateway {
} }
} }
// Quantize to exchange precision if helper is available // Quantize to exchange precision if helper is available (safe for STOP orders)
if (!isClosePosition && typeof (this.exchange as any).amountToPrecision === "function" && Number.isFinite(Number(amount))) { if (typeof (this.exchange as any).amountToPrecision === "function" && Number.isFinite(Number(amount))) {
amount = Number((this.exchange as any).amountToPrecision(symbol, amount)); amount = Number((this.exchange as any).amountToPrecision(symbol, amount));
} }
} catch (_normalizeError) { } catch (_normalizeError) {
@@ -596,9 +596,9 @@ export class ParadexGateway {
try { try {
const isClosePosition = (extraParams as any).closePosition === true; const isClosePosition = (extraParams as any).closePosition === true;
// When closePosition is true, many exchanges (incl. Paradex) accept omitting amount // Only omit amount for MARKET close-position orders; STOP requires explicit size
// and will close the entire position. Passing a larger min amount may violate reduceOnly. const shouldOmitAmount = isClosePosition && type === "market";
const amountArg: any = isClosePosition ? undefined : amount; const amountArg: any = shouldOmitAmount ? undefined : amount;
const order = (await this.exchange.createOrder( const order = (await this.exchange.createOrder(
symbol, symbol,
type, type,