mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
feat: 更新订单协调器和 GRVT 适配器逻辑,添加止损单的 reduceOnly 和 closePosition 参数,修改默认价格触发器为 LAST
This commit is contained in:
@@ -238,6 +238,7 @@ export async function placeStopLossOrder(
|
|||||||
side,
|
side,
|
||||||
type,
|
type,
|
||||||
stopPrice: roundDownToTick(stopPrice, priceTick),
|
stopPrice: roundDownToTick(stopPrice, priceTick),
|
||||||
|
reduceOnly: "true",
|
||||||
closePosition: "true",
|
closePosition: "true",
|
||||||
timeInForce: "GTC",
|
timeInForce: "GTC",
|
||||||
quantity: roundQtyDownToStep(quantity, qtyStep),
|
quantity: roundQtyDownToStep(quantity, qtyStep),
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ const ENVIRONMENT_ALIASES: Record<string, keyof typeof ENVIRONMENT_HOSTS> = {
|
|||||||
production: "prod",
|
production: "prod",
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_MARK_PRICE_TRIGGER = "MARK";
|
const DEFAULT_MARK_PRICE_TRIGGER = "LAST";
|
||||||
const DEFAULT_TIME_IN_FORCE: GrvtTimeInForce = "GOOD_TILL_TIME";
|
const DEFAULT_TIME_IN_FORCE: GrvtTimeInForce = "GOOD_TILL_TIME";
|
||||||
const TRAILING_NOT_SUPPORTED_ERROR =
|
const TRAILING_NOT_SUPPORTED_ERROR =
|
||||||
"GRVT exchange adapter does not yet support trailing stop orders";
|
"GRVT exchange adapter does not yet support trailing stop orders";
|
||||||
@@ -1097,12 +1097,16 @@ function mapOrder(order: IOrder, symbol: string): AsterOrder {
|
|||||||
const avgFillPrice = Array.isArray(state?.avg_fill_price)
|
const avgFillPrice = Array.isArray(state?.avg_fill_price)
|
||||||
? state?.avg_fill_price?.[0] ?? undefined
|
? state?.avg_fill_price?.[0] ?? undefined
|
||||||
: state?.avg_fill_price ?? undefined;
|
: state?.avg_fill_price ?? undefined;
|
||||||
|
const hasTrigger = Boolean(trigger?.tpsl?.trigger_price);
|
||||||
|
const derivedType = hasTrigger
|
||||||
|
? (order.is_market ? "STOP_MARKET" : "LIMIT")
|
||||||
|
: (order.is_market ? "MARKET" : "LIMIT");
|
||||||
return {
|
return {
|
||||||
orderId: order.order_id ?? metadata?.client_order_id ?? cryptoRandomId(),
|
orderId: order.order_id ?? metadata?.client_order_id ?? cryptoRandomId(),
|
||||||
clientOrderId: metadata?.client_order_id ?? "",
|
clientOrderId: metadata?.client_order_id ?? "",
|
||||||
symbol,
|
symbol,
|
||||||
side: leg?.is_buying_asset ? "BUY" : "SELL",
|
side: leg?.is_buying_asset ? "BUY" : "SELL",
|
||||||
type: order.is_market ? "MARKET" : "LIMIT",
|
type: derivedType,
|
||||||
status: state?.status ?? "NEW",
|
status: state?.status ?? "NEW",
|
||||||
price: leg?.limit_price ?? "0",
|
price: leg?.limit_price ?? "0",
|
||||||
origQty: leg?.size ?? "0",
|
origQty: leg?.size ?? "0",
|
||||||
|
|||||||
Reference in New Issue
Block a user