You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With cancelReplace, when Cancel Order Succeeds but New Order Placement fails it does not output cancel-data as stated in Github docs. Instead it only throws an Error without the needed cancel-data:
The problem seems to be ClientError(status_code, err["code"], err["msg"], response.headers), i.e, it provides information on the error code and error message only, although, the response contains data field as well: {
"code": -2021,
"msg": "Order cancel-replace partially failed.",
"data": {}
How can i access the data field as well?
The text was updated successfully, but these errors were encountered:
I managed to edit the _handle_exception function (in binance\api.py) which only refers to error code and message but leaves out data. I was not able to just add the data field into ClientError raise because that leads to errors when there is no data response in some request error.
So i just added a global variable that stores the cancel_data returned if Order cancel-replace partially failed:
With cancelReplace, when Cancel Order Succeeds but New Order Placement fails it does not output cancel-data as stated in Github docs. Instead it only throws an Error without the needed cancel-data:
Traceback (most recent call last): File "c:\Users\Pascal\Python Skripts\Binance\Binance.py", line 35, in <module> trade = client.cancel_and_replace(symbol=ticker, side='SELL', type= 'LIMIT_MAKER', cancelReplaceMode= 'ALLOW_FAILURE', quantity= 950, price= 0.7, cancelOrderId= 37359904) File "C:\Users\Pascal\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\spot\trade.py", line 184, in cancel_and_replace return self.sign_request("POST", url_path, params) File "C:\Users\Pascal\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\api.py", line 83, in sign_request return self.send_request(http_method, url_path, payload) File "C:\Users\Pascal\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\api.py", line 117, in send_request self._handle_exception(response) File "C:\Users\Pascal\AppData\Local\Programs\Python\Python310\lib\site-packages\binance\api.py", line 170, in _handle_exception raise ClientError(status_code, err["code"], err["msg"], response.headers) binance.error.ClientError: (409, -2021, 'Order cancel-replace partially failed.', {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '562', 'Connection': 'keep-alive', 'Date': 'Tue, 15 Nov 2022 22:52:38 GMT', 'Server': 'nginx', 'x-mbx-uuid': '5abc70b8-6e7b-4008-a43e-760621393663', 'x-mbx-used-weight': '34', 'x-mbx-used-weight-1m': '34', 'x-mbx-order-count-10s': '1', 'x-mbx-order-count-1d': '17', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 0c792defeeaa18965559ad74895ea56a.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'FRA60-P3', 'X-Amz-Cf-Id': 'eQX28Fk_LBpAlk017J8xjnPr6roldN-_grxxiuGwtFdcVPyYRkBLGQ=='})
If new order placement fails, the cancellation-data should be returned from the successful cancel.
@aisling-2 already answered:
How can i access the data field as well?
The text was updated successfully, but these errors were encountered: