sammchardy / python-binance

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

Limit Market Order Cannot Submit SIDE_BUY or SIDE_SELL: Parameter 'timeInForce' sent when not required #1171

Open Lukemtesta opened 2 years ago

Lukemtesta commented 2 years ago

Python version: 3.8.2 Python-binance version: 1.0.15

The code is stable for fiat-altcoin pairs and tested for both limit maker and limit orders. No problems. Today I discovered I have an issue with some USDT pairs.

Looking through the bug reports, it looks like this was originally an issue with market orders, however, you can see here we are sending a limit maker and encounter the same problem.

Same situation when executing bot SIDE_BUY and SIDE_SELL.

Please advise for next steps, this is blocking me at the moment.

Regards, Luke

Code

'''
  Make a buy order to execute 

  \return order struct above for open order
  '''
  def execute_buy_order(self, i_source_ticker, i_target_ticker, i_quantity, i_price, i_post_only = True): 

      type = ORDER_TYPE_LIMIT_MAKER if i_post_only else ORDER_TYPE_LIMIT

      print(i_source_ticker, i_target_ticker, i_quantity, i_price, i_post_only, type)

      pair = i_source_ticker + i_target_ticker

// offending line - Works for USD pairs. Specifically problematic with USDT
// Note: including timeInForce=TIME_IN_FORCE_GTC makes no difference to the output.
      order = self.get_client().create_order(
          symbol=pair,
          side=SIDE_BUY,
          type=type,
          quantity=i_quantity,
          price=str(i_price))

      return Order.make_from_new_order(order)

Logs

BTC USDT 0.00046 46320.35 True LIMIT_MAKER

2022-04-01 17:49:43,149 - logger(\general\wrappers\base_exchange_client.py) - Exception:  (<class 'binance.exceptions.BinanceAPIException'>, BinanceAPIException(<Response [400]>, 400, '{"code":-1106,"msg":"Parameter \'timeInForce\' sent when not required."}'), <traceback object at 0x00000275E1A71B40>) Traceback (most recent call last):
  File "C:\Users\pc\Documents\programming\tbmv2\general\wrappers\base_exchange_client.py", line 516, in iceberg_fnc_order
    order = i_order_function(i_source_ticker, i_target_ticker, i_order_quantity, 1.0, i_post_only = i_post_only)
  File "C:\Users\pc\Documents\programming\tbmv2\general\wrappers\base_exchange_client.py", line 302, in make_buy_post_order
    order = self.execute_buy_order(i_source_ticker, i_target_ticker, synthetic_order_size, i_order_price, i_post_only = i_post_only)
  File "C:\Users\pc\Documents\programming\tbmv2\general\wrappers\binance_exchange_client.py", line 370, in execute_buy_order
    order = self.get_client().create_order(
  File "C:\Users\pc\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 1385, in create_order
    return self._post('order', True, data=params)
  File "C:\Users\pc\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 374, in _post
    return self._request_api('post', path, signed, version, **kwargs)
  File "C:\Users\pc\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 334, in _request_api
    return self._request(method, uri, signed, **kwargs)
  File "C:\Users\pc\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 315, in _request
    return self._handle_response(self.response)
  File "C:\Users\pc\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 324, in _handle_response
    raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1106): Parameter 'timeInForce' sent when not required