我和python-binance.一起工作在我的代码中,我使用以下代码下了期货市场订单:
order = self.client.futures_create_order(
symbol=coin_pare,
type='MARKET',
side=route,
quantity=value * self.main_leverage,
)
然后,当我想关闭这个命令时,我决定在这个库中使用cancel_order,使用以下代码:
self.client.cancel_order(symbol=pare, orderId=order_id, origClientOrderId=client_order_id)
我得到了一个错误:APIError(code=-2011): Unknown order sent.
还有另外一种方式来取消某些订单吗?
发布于 2022-04-03 19:53:02
在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)
发布于 2022-05-22 07:44:30
您只需要删除空格并对字符串进行编码。这样做:
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)
https://stackoverflow.com/questions/70413668
复制相似问题