mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
fix slprice
This commit is contained in:
@@ -169,9 +169,6 @@ export async function placeOrder(
|
|||||||
lockOperating(locks, timers, pendings, type, log);
|
lockOperating(locks, timers, pendings, type, log);
|
||||||
try {
|
try {
|
||||||
const closePosition = reduceOnly ? true : undefined;
|
const closePosition = reduceOnly ? true : undefined;
|
||||||
// StandX API: reduce-only 订单不能设置 tp/sl
|
|
||||||
const slPrice = reduceOnly ? undefined : opts?.slPrice;
|
|
||||||
const tpPrice = reduceOnly ? undefined : opts?.tpPrice;
|
|
||||||
const order = await routeLimitOrder({
|
const order = await routeLimitOrder({
|
||||||
adapter,
|
adapter,
|
||||||
symbol,
|
symbol,
|
||||||
@@ -181,8 +178,8 @@ export async function placeOrder(
|
|||||||
timeInForce: reduceOnly ? "GTC" : "GTX",
|
timeInForce: reduceOnly ? "GTC" : "GTX",
|
||||||
reduceOnly: reduceOnly ? true : undefined,
|
reduceOnly: reduceOnly ? true : undefined,
|
||||||
closePosition,
|
closePosition,
|
||||||
slPrice,
|
slPrice: opts?.slPrice,
|
||||||
tpPrice,
|
tpPrice: opts?.tpPrice,
|
||||||
});
|
});
|
||||||
pendings[type] = String(order.orderId);
|
pendings[type] = String(order.orderId);
|
||||||
log("order", `挂限价单: ${side} @ ${priceNum} 数量 ${quantity} reduceOnly=${reduceOnly}${opts?.slPrice ? ` sl=${opts.slPrice}` : ""}`);
|
log("order", `挂限价单: ${side} @ ${priceNum} 数量 ${quantity} reduceOnly=${reduceOnly}${opts?.slPrice ? ` sl=${opts.slPrice}` : ""}`);
|
||||||
|
|||||||
@@ -701,9 +701,13 @@ export class MakerPointsEngine {
|
|||||||
if (!target) continue;
|
if (!target) continue;
|
||||||
if (target.amount < EPS) continue;
|
if (target.amount < EPS) continue;
|
||||||
try {
|
try {
|
||||||
// 计算止损价格:买单在价格下方 $1,卖单在价格上方 $1
|
// reduce-only 订单不能设置 tp/sl,仅开仓单设置止损
|
||||||
const priceNum = Number(target.price);
|
const priceNum = Number(target.price);
|
||||||
const slPrice = target.side === "BUY" ? priceNum - 1 : priceNum + 1;
|
const slPrice = target.reduceOnly
|
||||||
|
? undefined
|
||||||
|
: target.side === "BUY"
|
||||||
|
? priceNum - 1
|
||||||
|
: priceNum + 1;
|
||||||
await placeOrder(
|
await placeOrder(
|
||||||
this.exchange,
|
this.exchange,
|
||||||
this.config.symbol,
|
this.config.symbol,
|
||||||
|
|||||||
Reference in New Issue
Block a user