Tried to submit the order detailed in params using
response = requests.post(f"{base_url}/sapi/v1/margin/order/otoco", headers=headers, params=params)
It goes through only if the "pendingBelow" data are provided, otherwise I get
Error: 400, {"code":-1102,"msg":"Mandatory parameter 'pendingAboveType|pendingBelowType' was not sent, was empty/null, or malformed."}
I just want a pending limit order. How to I do this or am I forced to provide, say, pendinBelowPrice=0? Also, if I place a similar SELL order, would I need to reverse the info, i.e. instead of adding data for pendingAbove?
params = {
"symbol": "BTCUSDT",
"isIsolated": "FALSE",
"sideEffectType": "MARGIN_BUY",
"workingType": "LIMIT",
"workingSide": "BUY",
"workingPrice": 80000,
"workingQuantity": 0.0002,
"workingTimeInForce": "GTC",
"pendingSide": "SELL",
"pendingQuantity": 0.0002,
"pendingAboveType": "LIMIT_MAKER",
"pendingAbovePrice": 110000,
#"pendingBelowType": "STOP_LOSS_LIMIT",
#"pendingBelowPrice": 70000,
#"pendingBelowStopPrice": 60000,
#"pendingBelowTimeInForce": "GTC",
'timestamp': int(time.time() * 1000),
}
Tried to submit the order detailed in params using
response = requests.post(f"{base_url}/sapi/v1/margin/order/otoco", headers=headers, params=params)
It goes through only if the "pendingBelow" data are provided, otherwise I get
Error: 400, {"code":-1102,"msg":"Mandatory parameter 'pendingAboveType|pendingBelowType' was not sent, was empty/null, or malformed."}
I just want a pending limit order. How to I do this or am I forced to provide, say, pendinBelowPrice=0? Also, if I place a similar SELL order, would I need to reverse the info, i.e. instead of adding data for pendingAbove?
params = {
"symbol": "BTCUSDT",
"isIsolated": "FALSE",
"sideEffectType": "MARGIN_BUY",
"workingType": "LIMIT",
"workingSide": "BUY",
"workingPrice": 80000,
"workingQuantity": 0.0002,
"workingTimeInForce": "GTC",
"pendingSide": "SELL",
"pendingQuantity": 0.0002,
"pendingAboveType": "LIMIT_MAKER",
"pendingAbovePrice": 110000,
#"pendingBelowType": "STOP_LOSS_LIMIT",
#"pendingBelowPrice": 70000,
#"pendingBelowStopPrice": 60000,
#"pendingBelowTimeInForce": "GTC",
'timestamp': int(time.time() * 1000),
}
Share
Improve this question
edited Feb 6 at 7:21
user2635886
asked Feb 6 at 5:03
user2635886user2635886
455 bronze badges
2 Answers
Reset to default 0From the documentation, looks like pendingBelow
is not mandatory only pendingAboveType
is required. However, pendingAboveType
value you provided didn't match the supported value (LIMIT_MAKER
, STOP_LOSS
, and STOP_LOSS_LIMIT
). From your case, I think pendingAboveType
should be LIMIT_MAKER
but instead it was not a supported value (LIMIT
), hence it checks for pendingBelow
data instead
Ok, I found a solution. Instead of an otoco trade, I needed an oto one
response = requests.post(f"{base_url}/sapi/v1/margin/order/oto", headers=headers, params=params)
where there is no need to provide a stop loss. So the params would look like this:
params = {
"symbol": "BTCUSDT",
"isIsolated": "FALSE",
"sideEffectType": "MARGIN_BUY",
"workingType": "LIMIT",
"workingSide": "BUY",
"workingPrice": 80000,
"workingQuantity": 0.0002,
"workingTimeInForce": "GTC",
"pendingType": "LIMIT",
"pendingSide": "SELL",
"pendingQuantity": 0.0002,
"pendingPrice": 110000,
"pendingimeInForce": "GTC",
'timestamp': int(time.time() * 1000),
}
This allows a limit-type as a follow-up order.