Closed kasahh closed 1 year ago
Please provide the corresponding request parameters.
Please provide the corresponding request parameters.
THAT is indeed the problem. I cant tell because the error is random. Most times my bot runs without errors but in a day those errors occurs sometimes thrice or less. I recently logged all the parameters sent for a whole day and using time traced what size params was sent at the time the error was thrown but the size param was fine, just like the others before it.
Which is why i suggested including request parameters in error messages like in Binance. I would have ignored it but the implication is that some orders fail to execute and therefore mess with my algorithm.
Perhaps explaining what these two error messages mean might help me troubleshoot them?
We'll update the error messages recently(this week perhaps) to help you troubleshooting them. For now, from the description above, is there any situation where your size
parameter might NOT be a non-scientific integer?
We'll update the error messages recently(this week perhaps) to help you troubleshooting them. For now, from the description above, is there any situation where your
size
parameter might NOT be a non-scientific integer?
That is great news. Much appreciated.
I am not sure if sometimes the size sent is of a non-scientific integer. I am aware of an issue from my previous bots where sometimes integer might become something like this "5.00000001" but I am yet to come across such in my code but then the request message did help me pin point those in the past. Perhaps i should investigate along that route and revert if i am able to find a solution pending when the update is made. Thanks
Yes, Python is notorious for its numeric calculation, especially with floating values. I would suggest you force int
for size
parameters, and use decimal.Decimal
for any calculations, and use format(<your-variable>, 'f')
to format parameters like price
to an non-scientific string
i will definitely try those. Thanks for the tips
Hello.. I keep getting these two errors. I couldn't find the cause in my code as my order sizes are to specification. I also couldn't find an explanation for the error online. What could they mean and what could be the cause.
Also may i suggest including "the exact request message sent (with the parameters/arguments used)" in error messages so it is easier during debug for others to see what exactly caused the exception at a glance.
Here are the error messages.
1:
2022-07-27 00:25:20: Exception occurred in: Traceback (most recent call last): File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api_client.py", line 198, in __call_api _request_timeout=_request_timeout, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api_client.py", line 478, in request body=body, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/rest.py", line 306, in POST body=body, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/rest.py", line 232, in request raise ApiException(http_resp=r) gate_api.exceptions.ApiException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Date': 'Wed, 27 Jul 2022 00:25:19 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty'}) HTTP response body: {"label":"INVALID_PROTOCOL","detail":"invalid argument: #4"}
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "gateioNewBuild.py", line 662, in main_code post_hedge_order_short_f(symbol,price = positionPrice,quantity = newPositionDirectionSize) File "gateioNewBuild.py", line 395, in post_hedge_order_short_f api_response = request_client().create_futures_order(settle, order) File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api/futures_api.py", line 3087, in create_futures_order return self.create_futures_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501 File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api/futures_api.py", line 3182, in create_futures_order_with_http_info collection_formats=collection_formats, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api_client.py", line 410, in call_api _host, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api_client.py", line 209, in __call_api raise GateApiException(err.get('label'), err.get('message'), err.get('detail'), e) gate_api.exceptions.GateApiException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Date': 'Wed, 27 Jul 2022 00:25:19 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty'}) HTTP response body: {"label":"INVALID_PROTOCOL","detail":"invalid argument: #4"}
2:
2022-07-26 23:58:30: Exception occurred in: Traceback (most recent call last): File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api_client.py", line 198, in __call_api _request_timeout=_request_timeout, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api_client.py", line 478, in request body=body, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/rest.py", line 306, in POST body=body, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/rest.py", line 232, in request raise ApiException(http_resp=r) gate_api.exceptions.ApiException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 26 Jul 2022 23:58:30 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty'}) HTTP response body: {"label":"INVALID_ARGUMENT","detail":"invalid size"}
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "gateioNewBuildLive.py", line 1001, in main_code close_hedge_long_f(symbol,price,quantity) File "gateioNewBuildLive.py", line 431, in close_hedge_long_f api_response = request_client().create_futures_order(settle, order) File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api/futures_api.py", line 3087, in create_futures_order return self.create_futures_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501 File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api/futures_api.py", line 3182, in create_futures_order_with_http_info collection_formats=collection_formats, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api_client.py", line 410, in call_api _host, File "/home/admin/.local/lib/python3.7/site-packages/gate_api/api_client.py", line 209, in __call_api raise GateApiException(err.get('label'), err.get('message'), err.get('detail'), e) gate_api.exceptions.GateApiException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 26 Jul 2022 23:58:30 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty'}) HTTP response body: {"label":"INVALID_ARGUMENT","detail":"invalid size"}