I got “Order would immediately trigger.” for the TRAILING_STOP_MARKET
order when the activate price is lower than the latest. This is expected in the one-way mode. However, my Futures account is set in the hedging mode. Below is my Python code.
mark_price = float(um_futures_client.mark_price(symbol=SYMBOL)['markPrice'])
short_take_price = round(mark_price * 0.9, 2)
order = {
'symbol': 'ETHUSDT',
'side': 'SELL',
'positionSide': 'SHORT',
'type': 'TRAILING_STOP_MARKET',
'quantity': 0.001,
'activationPrice': short_take_price,
'callbackRate': 0.5,
# 'priceProtect': True,
}
print(um_futures_client.new_order(**order))
The document mentions:
- For
TRAILING_STOP_MARKET
, if you got such error code.
{"code": -2021, "msg": "Order would immediately trigger."}
means that the parameters you send do not meet the following requirements:
- BUY:
activationPrice
should be smaller than latest price.- SELL:
activationPrice
should be larger than latest price.
I think this is not true for the hedging mode.
I tried to increase the activate price to the value higher than the latest price.
mark_price = float(um_futures_client.mark_price(symbol=SYMBOL)['markPrice'])
short_take_price = round(mark_price * 1.1, 2)
order = {
'symbol': 'ETHUSDT',
'side': 'SELL',
'positionSide': 'SHORT',
'type': 'TRAILING_STOP_MARKET',
'quantity': 0.001,
'activationPrice': short_take_price,
'callbackRate': 0.5,
# 'priceProtect': True,
}
print(um_futures_client.new_order(**order))
The API call was successful:
{
'symbol': 'ETHUSDT',
'status': 'NEW',
'price': '0',
'avgPrice': '0.00000',
'origQty': '0.001',
'executedQty': '0',
'cumQty': '0',
'activatePrice': '1947.97',
'priceRate': '0.5',
'cumQuote': '0',
'timeInForce': 'GTC',
'type': 'TRAILING_STOP_MARKET',
'reduceOnly': False,
'closePosition': False,
'side': 'SELL',
'positionSide': 'SHORT',
'stopPrice': '0',
'workingType': 'CONTRACT_PRICE',
'priceProtect': False,
'origType': 'TRAILING_STOP_MARKET',
'updateTime': 1680030668505
}
However, the new order shown in my app was “Open Short” instead of “Close Short”.