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

binance.exceptions.BinanceAPIException: APIError(code=-1013): Market is closed. #1329

Open Unixbx opened 1 year ago

Unixbx commented 1 year ago

Hi

I have a problem with the trading bot, as it shows me a message not at first, but after it makes trades. For example, today the bot entered into four deals in which the buy condition was met, and closed two deals in which the sell condition was met. Then it entered into another deal, after which the following error message appeared to me:

Traceback (most recent call last): File "C:\Users\Administrator\Desktop\bt_kamel\bot_naclosev_3.py", line 118, in order = client.create_order( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\client.py", line 1447, in create_order return self._post('order', True, data=params) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\client.py", line 417, in _post return self._request_api('post', path, signed, version, kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\client.py", line 377, in _request_api return self._request(method, uri, signed, kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\client.py", line 358, in _request return self._handle_response(self.response) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\client.py", line 367, in _handle_response raise BinanceAPIException(response, response.status_code, response.text) binance.exceptions.BinanceAPIException: APIError(code=-1013): Market is closed.

PJV0043 commented 11 months ago

Update your bot's code to handle this specific exception (BinanceAPIException with code -1013) and implement a retry mechanism, where the bot waits for a predetermined time before retrying the trade. This can help in situations where the market closes temporarily or undergoes maintenance.