I am able to create a LONG Position with TP and SL connected with the position doing that:
order = client.futures_create_order(
symbol=symbol,
side=SIDE_BUY,
positionSide = "LONG",
type=ORDER_TYPE_MARKET,
quantity=quantity,
)
stop_loss = client.futures_create_order(
symbol=symbol,
side='SELL',
type='STOP_MARKET',
quantity = quantity,
positionSide = "LONG",
stopPrice = stop_market,
closePosition = True
)
order_take = client.futures_create_order(
symbol=symbol,
side='SELL',
type='TAKE_PROFIT_MARKET',
quantity = quantity,
positionSide = "LONG",
stopPrice = take_profit,
closePosition = True
)
But with that similar code I am not able to create a SHORT Position:
order = client.futures_create_order(
symbol=symbol,
side=SIDE_SELL,
positionSide = "SHORT",
type=ORDER_TYPE_MARKET,
quantity=quantity,
)
stop_loss = client.futures_create_order(
symbol=symbol,
side='SELL',
type='STOP_MARKET',
quantity = quantity,
positionSide = "SHORT",
stopPrice = stop_market,
closePosition = True
)
order_take = client.futures_create_order(
symbol=symbol,
side='SELL',
type='TAKE_PROFIT_MARKET',
quantity = quantity,
positionSide = "SHORT",
stopPrice = take_profit,
closePosition = True
)
I am receiving this error:
APIError(code=-1128): Combination of optional parameters invalid.
How can I solve that? Maybe I am missing something?