mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 08:18:07 +00:00
Refactor triggerType handling in order placement logic
- Updated the triggerType assignment in placeStopLossOrder and related functions to default to "STOP_LOSS" instead of conditionally setting it based on the order side. - This change simplifies the logic for stop market orders across the order coordinator and GRVT exchange gateway, ensuring consistent behavior.
This commit is contained in:
@@ -296,7 +296,7 @@ export async function placeStopLossOrder(
|
||||
timeInForce: "GTC",
|
||||
reduceOnly: true,
|
||||
closePosition: true,
|
||||
triggerType: side === "BUY" ? "TAKE_PROFIT" : "STOP_LOSS",
|
||||
triggerType: "STOP_LOSS",
|
||||
});
|
||||
pendings[type] = String(order.orderId);
|
||||
log("stop", `挂止损单: ${side} STOP_MARKET @ ${normalizedStop}`);
|
||||
|
||||
@@ -1337,7 +1337,7 @@ function buildUnsignedOrder(params: {
|
||||
|
||||
function buildTriggerMetadata(params: CreateOrderParams): GrvtUnsignedOrder["metadata"]["trigger"] | undefined {
|
||||
if (params.type === "STOP_MARKET") {
|
||||
const triggerType = params.triggerType ?? (params.side === "BUY" ? "TAKE_PROFIT" : "STOP_LOSS");
|
||||
const triggerType = params.triggerType ?? "STOP_LOSS";
|
||||
const stopPrice = params.stopPrice ?? params.activationPrice;
|
||||
if (!stopPrice) {
|
||||
throw new Error("GRVT stop orders require a stopPrice or activationPrice");
|
||||
|
||||
@@ -62,7 +62,7 @@ export async function createStopOrder(intent: StopOrderIntent): Promise<AsterOrd
|
||||
quantity: intent.quantity,
|
||||
stopPrice: intent.stopPrice,
|
||||
timeInForce: intent.timeInForce ?? "GTC",
|
||||
triggerType: intent.triggerType ?? (intent.side === "BUY" ? "TAKE_PROFIT" : "STOP_LOSS"),
|
||||
triggerType: intent.triggerType ?? "STOP_LOSS",
|
||||
closePosition: toStringBoolean(intent.closePosition ?? true),
|
||||
reduceOnly: toStringBoolean(intent.reduceOnly ?? true),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user