简体   繁体   English

如何取消期货币安订单?

[英]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.

相关问题 如何在 python 中使用 ccxt 制作币安期货订单? - How to make a binance futures order with ccxt in python? 币安期货 API 以检索填充订单作为信号 - Binance futures API to retrieve filled order as signal 如何使用 python-binance 下达带有止盈和止损的期货市场订单 - How to place a Futures Market order with Take Profit and Stop Loss using python-binance 如何在 binance 上创建期货限价订单以及止盈和止损? - How to create a futures limit order together with take profit and stop loss on binance? 如何在 Binance API Python 上设置止盈止损的市场期货订单? - How to place a market futures order with take profit and stop loss on Binance API Python? Binance 期货测试网上的空头订单导致 APIError(ReduceOnly 订单被拒绝) - Short Order on Binance futures testnet resulting in APIError (ReduceOnly Order is Rejected) 我无法获取币安期货订单历史数据 - I can't get binance Futures order book historical data 如何使用 python-binance 下期货市场订单:APIError(code=-1111): Precision is over the maximum defined for this assets - How to place a futures market order using python-binance: APIError(code=-1111): Precision is over the maximum defined for this asset 期货币安 Websocket - Binance Websocket for futures 如何向币安发送OCO订单 - How to send OCO order to binance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM