mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
feat: 优化Paradex网关的订单金额处理逻辑,确保在平仓时仅对市场订单省略金额参数
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user