You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Trying to use create_oco_order I get an error about aboveType, more precisely:
File "/lib/python3.13/site-packages/binance/client.py", line 84, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1102): Mandatory parameter 'aboveType' was not sent, was empty/null, or malformed.
The strange thing is that the python version does not include the parameter that the error talks about, as we can see from the client.py implementation
def create_oco_order(self, **params):
"""Send in a new OCO order
https://binance-docs.github.io/apidocs/spot/en/#new-order-list-oco-trade
:param symbol: required
:type symbol: str
:param listClientOrderId: A unique id for the list order. Automatically generated if not sent.
:type listClientOrderId: str
:param side: required
:type side: str
:param quantity: required
:type quantity: decimal
:param limitClientOrderId: A unique id for the limit order. Automatically generated if not sent.
:type limitClientOrderId: str
:param price: required
:type price: str
:param limitIcebergQty: Used to make the LIMIT_MAKER leg an iceberg order.
:type limitIcebergQty: decimal
:param stopClientOrderId: A unique id for the stop order. Automatically generated if not sent.
:type stopClientOrderId: str
:param stopPrice: required
:type stopPrice: str
:param stopLimitPrice: If provided, stopLimitTimeInForce is required.
:type stopLimitPrice: str
:param stopIcebergQty: Used with STOP_LOSS_LIMIT leg to make an iceberg order.
:type stopIcebergQty: decimal
:param stopLimitTimeInForce: Valid values are GTC/FOK/IOC.
:type stopLimitTimeInForce: str
:param newOrderRespType: Set the response JSON. ACK, RESULT, or FULL; default: RESULT.
:type newOrderRespType: str
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
Instead, looking for API documentation, the parameter is correctly indicated here
To Reproduce
client = Client(api_key, api_secret)
oco_order = self.client.create_oco_order(
symbol=self.symbol,
side=Client.SIDE_SELL,
quantity=quantity,
price=str(profit_price), # Limit price for profit-taking
stopPrice=str(stop_price), # Stop price for loss prevention
stopLimitPrice=str(stop_limit_price), # Stop-limit sell price
stopLimitTimeInForce="GTC" # Good Till Cancelled
)
Expected behavior
The order cannot be placed, it just crashes because of the missing parameter
Environment (please complete the following information):
I figured out what was happening... my call was using parameters from a previous version. The comment in the source code wasn't aligned with the latest version of the API from Binance, so I trusted it and I thought there was a problem in the actual call, which is not true, with the proper parameters the OCO works just fine
The working call is (in my case)
oco_order = self.client.create_oco_order(
symbol=symbol,
side=Client.SIDE_SELL,
quantity=quatity,
abovePrice=str(round(profit_price,2)), # Limit price for profit-taking
belowPrice=str(round(stop_price,2)), # Stop price for loss prevention
belowStopPrice=str(round(stop_limit_price,2)), # Stop-limit sell price
belowTimeInForce="GTC", # Good Till Cancelled
aboveType="LIMIT_MAKER",
belowType="STOP_LOSS_LIMIT"
)
Describe the bug
Trying to use create_oco_order I get an error about aboveType, more precisely:
File "/lib/python3.13/site-packages/binance/client.py", line 84, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1102): Mandatory parameter 'aboveType' was not sent, was empty/null, or malformed.
The strange thing is that the python version does not include the parameter that the error talks about, as we can see from the
client.py
implementationInstead, looking for API documentation, the parameter is correctly indicated here
To Reproduce
Expected behavior
The order cannot be placed, it just crashes because of the missing parameter
Environment (please complete the following information):
Logs
here
The text was updated successfully, but these errors were encountered: