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
if (!isClosePosition && typeof (this.exchange as any).amountToPrecision === "function" && Number.isFinite(Number(amount))) {
// Quantize to exchange precision if helper is available (safe for STOP orders)
if (typeof (this.exchange as any).amountToPrecision === "function" && Number.isFinite(Number(amount))) {
amount = Number((this.exchange as any).amountToPrecision(symbol, amount));
}
} catch (_normalizeError) {
@@ -596,9 +596,9 @@ export class ParadexGateway {
try {
const isClosePosition = (extraParams as any).closePosition === true;
// When closePosition is true, many exchanges (incl. Paradex) accept omitting amount
// and will close the entire position. Passing a larger min amount may violate reduceOnly.
const amountArg: any = isClosePosition ? undefined : amount;
// Only omit amount for MARKET close-position orders; STOP requires explicit size
const shouldOmitAmount = isClosePosition && type === "market";
const amountArg: any = shouldOmitAmount ? undefined : amount;
const order = (await this.exchange.createOrder(
symbol,
type,