[英]How to cancel futures binance order?
I'm working with python-binance .我正在使用python-binance 。 In my code, I place a futures market order, using this code:
在我的代码中,我使用以下代码下达期货市场订单:
order = self.client.futures_create_order(
symbol=coin_pare,
type='MARKET',
side=route,
quantity=value * self.main_leverage,
)
Then, when I want to close this order, I decide to use cancel_order in this library, using this code:然后,当我想关闭这个订单时,我决定在这个库中使用 cancel_order,使用以下代码:
self.client.cancel_order(symbol=pare, orderId=order_id, origClientOrderId=client_order_id)
And I get an error: APIError(code=-2011): Unknown order sent.
我收到一个错误:
APIError(code=-2011): Unknown order sent.
Is there another way how to cancel certain order?还有其他方法可以取消某些订单吗?
timestamp is mandatory in parameters for cancel orders mentioned in https://binance-docs.github.io/apidocs/futures/en/#query-order-user_data you should edit like this:时间戳在https://binance-docs.github.io/apidocs/futures/en/#query-order-user_data中提到的取消订单参数中是强制性的,您应该像这样编辑:
(self.client.cancel_order(symbol=pare, orderId=order_id, origClientOrderId=client_order_id, timestamp=true)
You just need to remove spaces and encode the string.您只需要删除空格并对字符串进行编码。 Do this:
做这个:
from urllib.parse import quote
from json import dumps
order_id_str = dumps(order_id).replace(" ", "")
order_id_str = quote(order_id_str)
self.client.cancel_order(symbol=pare, orderIdList=order_id_str)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.