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:
discountry
2026-02-01 11:15:00 +08:00
parent 1fb6d3d62d
commit 8d79ace8b3
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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}`);
+1 -1
View File
@@ -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");
+1 -1
View File
@@ -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),
},