LUCIT-Systems-and-Development / unicorn-binance-rest-api

A Python SDK by LUCIT to use the Binance REST API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, us, tr) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-rest-api.docs.lucit.tech
Other
61 stars 17 forks source link

error send create future order #43

Closed leacostae closed 1 year ago

leacostae commented 2 years ago

Version of this library.

unicorn-binance-rest-api 1.5.0

Solution to Issue cannot be found in the documentation or other Issues and also occurs in the latest version of this library.

Hardware?

VPS or other cloud hosting

Operating System?

Windows

Python version?

Python3.7

Installed packages

aiohttp                       3.8.1
aiosignal                     1.2.0
aniso8601                     9.0.1
async-timeout                 4.0.2
asynctest                     0.13.0
attrs                         22.1.0
backports.zoneinfo            0.2.1
certifi                       2022.6.15
cffi                          1.15.1
charset-normalizer            2.1.0
cheroot                       8.6.0
click                         8.1.3
colorama                      0.4.5
cryptography                  37.0.4
dateparser                    1.1.1
Flask                         2.2.2
Flask-RESTful                 0.3.9
frozenlist                    1.3.1
idna                          3.3
importlib-metadata            4.12.0
itsdangerous                  2.1.2
jaraco.functools              3.5.1
Jinja2                        3.1.2
MarkupSafe                    2.1.1
more-itertools                8.14.0
multidict                     6.0.2
numpy                         1.21.6
pandas                        1.3.5
pip                           22.2.2
psutil                        5.9.1
pyasn1                        0.4.8
pyasn1-modules                0.2.8
pycparser                     2.21
pyOpenSSL                     22.0.0
python-binance                1.0.16
python-dateutil               2.8.2
pytz                          2022.2.1
pytz-deprecation-shim         0.1.0.post0
regex                         2022.3.2
requests                      2.28.1
service-identity              21.1.0
setuptools                    47.1.0
six                           1.16.0
typing_extensions             4.3.0
tzdata                        2022.2
tzlocal                       4.2
ujson                         5.4.0
unicorn-binance-rest-api      1.5.0
unicorn-binance-websocket-api 1.41.0
unicorn-fy                    0.12.2
urllib3                       1.26.11
websocket-client              1.3.3
websockets                    10.3
Werkzeug                      2.2.2
yarl                          1.8.1

Logging output

2022-08-31 19:30:18,311 ERROR    PID:4528 TID:4976 [BINANCE_FUTURE_TEST_BOT_BNBBUSD.py:220] ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 710, in urlopen
    chunked=chunked,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1369, in getresponse
    response.begin()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 310, in begin
    version, status, reason = self._read_status()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 279, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 499, in send
    timeout=timeout,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 788, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 710, in urlopen
    chunked=chunked,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1369, in getresponse
    response.begin()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 310, in begin
    version, status, reason = self._read_status()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 279, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\BINANCE_FUTURES_TEST_BOT\BINANCE_FUTURE_TEST_BOT_BNBBUSD.py", line 204, in create_order
    price=price, quantity=qty, timeInForce='GTX')
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\unicorn_binance_rest_api\manager.py", line 5777, in futures_create_order
    return self._request_futures_api('post', 'order', True, data=params)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\unicorn_binance_rest_api\manager.py", line 470, in _request_futures_api
    return self._request(method, uri, signed, True, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\unicorn_binance_rest_api\manager.py", line 449, in _request
    self.response = getattr(self.session, method)(uri, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 547, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Used endpoint?

binance.com-futures

Issue

I am testing a script that buys and sells cryptos on Binance Futures, every morning I check the bot's logs and I find the error described in the issue, I don't know what the reasons were or could be

oliver-zehentleitner commented 1 year ago

There are 3 errors, all related to a lost network connection...

In the file BINANCE_FUTURE_TEST_BOT_BNBBUSD.py on row 220 your script tries something while there is no internet.

You need to catch the exception like:

try:
    ubra = unicorn_binance_rest_api.BinanceRestApiManager(binance_api_key, binance_api_secret)
except requests.exceptions.ConnectionError:
    print("No internet connection!")