sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
6.01k stars 2.2k forks source link

Error with STOP_LOSS_LIMIT Order Types #1236

Open alphazwest opened 2 years ago

alphazwest commented 2 years ago

I am trying to place a new order of type STOP_LOSS_LIMIT as follows:

client.create_order( symbol="ABCXYZ", side="SELL", type="STOP_LOSS_LIMIT", timeInForce="GTC", quantity=1.5, price=123.456, stop_price=123.123 )

I get the following error message:

binance.exceptions.BinanceAPIException: APIError(code=-1104): Not all sent parameters were read; read '8' parameter(s) but was sent '9'. Upon deeper inspection, the following API parameters are being sent by this library:

{ 'symbol': 'ABCXYZ', 'side': 'SELL', 'type': 'STOP_LOSS_LIMIT', 'timeInForce': 'GTC', 'quantity': 1.5, 'price': 123.123, 'stop_price': 123.456, 'timestamp': valid_unix_timestamp_int, 'signature': '64-char hexadecimal string' }

There are clearly 9 parameters being passed, as indicated by the error message. However, the ones specified by my application are essential and I can only guess which one the API is complaining about.

Regular BUY/SELL orders work w/o issue.

Full Stack Trace, with last entry to the logger first:

DEBUG:urllib3.connectionpool:https://api.binance.us:443 "POST /api/v3/order HTTP/1.1" 400 97
Traceback (most recent call last):
  File "myfile.py", line 444, in create_stop_limit_order
    order = client.create_order(
  File ".\venv\lib\site-packages\binance\client.py", line 1397, in create_order
    return self._post('order', True, data=params)
  File ".\venv\lib\site-packages\binance\client.py", line 374, in _post
    return self._request_api('post', path, signed, version, **kwargs)
  File ".\venv\lib\site-packages\binance\client.py", line 334, in _request_api
    return self._request(method, uri, signed, **kwargs)
  File ".\venv\lib\site-packages\binance\client.py", line 315, in _request
    return self._handle_response(self.response)
  File ".\venv\lib\site-packages\binance\client.py", line 324, in _handle_response
    raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1104): Not all sent parameters were read; read '8' parameter(s) but was sent '9'.

Environment (please complete the following information):

halfelf commented 2 years ago

stopPrice, not stop_price