Python-binance: Cancel all orders

Created on 8 Jun 2020  路  9Comments  路  Source: sammchardy/python-binance

Just wondering if there is a plan to implement this feature from the binance-official-api:
Cancel All Open Orders on a Symbol (TRADE) - Cancels all active orders on a symbol. This includes OCO orders.

This would be a really useful feature and save working with Order ID's. Thanks for your hard work.

Most helpful comment

The API call for this on Binance is documented here: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#cancel-all-open-orders-on-a-symbol-trade

in client.py:

def cancel_orders(self, **params):
        return self._delete('openOrders', True, data=params)

Then client.cancel_orders(symbol='BNBBTC')

All 9 comments

I want to clarify - I know we can use OCO to cancel our trades but the amount of trades possible appears to be heavily limited when placing OCO orders. I can only place 6 at a time which really isn't enough for me. If we could cancel all orders on a pair it would allow us to control our stops manually and keep up a high volume of orders.

The API call for this on Binance is documented here: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#cancel-all-open-orders-on-a-symbol-trade

in client.py:

def cancel_orders(self, **params):
        return self._delete('openOrders', True, data=params)

Then client.cancel_orders(symbol='BNBBTC')

I noticed that this function is not available anymore, or am I wrong?

When I use: client.cancel_orders(symbol='BTCUSDT')

I get: Unresolved attribute reference 'cancel_orders' for class 'Client'

I noticed that this function is not available anymore, or am I wrong?

When I use: client.cancel_orders(symbol='BTCUSDT')

I get: Unresolved attribute reference 'cancel_orders' for class 'Client'

As @iterums mentioned, 'cancel_orders' new function should be in 'client' and you re-open your project and re-try.
It works for me.

PLEASE HELP NOT WORC close my all orders ((

from binance.client import Client
from binance.websockets import BinanceSocketManager
import time
import math
api_key = 'IIIIIIIIIIIIIIIIIIII'
api_secret = 'IIIIIIIIIIIIIIIIIIII'
client = Client(api_key, api_secret)
ASSET = 'ZECUSDT'
CURRENCY = 'ZEC'
CRYPTOCURRENCY = 'USDT'
def balance(symbol):
balance = client.get_asset_balance(asset=symbol)
balance = {'free': balance['free'], 'locked':balance['locked']}
return balance
def history(symbol):
history = client.get_my_trades(symbol=symbol)
return history
def price(symbol):
price = client.get_avg_price(symbol=symbol)['price']
return float(price)
def order_market_buy(quantity):
order = client.order_market_buy(symbol=ASSET, quantity=quantity)
def order_market_sell(quantity):
order = client.order_market_sell(symbol=ASSET, quantity=quantity)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOT WORC!

def cancel_orders(self, **params):
return self._delete('openOrders', True, data=params)

#

PRICE = price(ASSET)
def main(FIRST_PRICE):
print('小袝袡效袗小 笑袝袧袗',int(PRICE))
nteu = PRICE
numbermu = 12
rezultae = nteu - numbermu
okruglenie = round(rezultae, 2)
print('袟袗 小袣袨袥鞋袣袨 袣校袩袠孝鞋!', + okruglenie )
nteuz = PRICE
numbermuz = 14
rezultaez = nteuz + numbermuz
okrugleniez = round(rezultaez, 2)
print('袟袗 小袣袨袥鞋袣袨 袩袪袨袛袗孝鞋!', + okrugleniez )
rtytrr = 170
print(okrugleniez)

#

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOT WORC!

client.cancel_orders(symbol='ZECUSDT')

#

START_PRICE = price(ASSET)
main(START_PRICE)

[PLEASE HELP NOT WORK!]
def cancel_orders(self, **params):
return self._delete('openOrders', True, data=params)

You must add that code to the Client class in the client.py file itself, which is located wherever your python-binance is installed.

(In VSCode with the right setup, you can right-click 'Client' on the line 'from binance.client import Client', select "Go to Definition", and that opens client.py.)

[PLEASE HELP NOT WORK!]
def cancel_orders(self, **params):
return self._delete('openOrders', True, data=params)

You must add that code to the Client class in the client.py file itself, which is located wherever your python-binance is installed.

(In VSCode with the right setup, you can right-click 'Client' on the line 'from binance.client import Client', select "Go to Definition", and that opens client.py.)

how to cancel all sell or buy individually? it's possible?

It's not possible?

@G34567 > how to cancel all sell or buy individually? it's possible?

Your questions are inappropriate here: python-binance is only a Python wrapper around the Binance API, so in this repository you should only post about issues with the wrapper itself. As for the Binance API and what that can or cannot do, you should refer to the official Binance documentation: https://binance-docs.github.io/apidocs/

Hope that helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamveritas picture iamveritas  路  3Comments

ohsnapitsjojo picture ohsnapitsjojo  路  3Comments

marzwu picture marzwu  路  4Comments

15chrjef picture 15chrjef  路  6Comments

delware1 picture delware1  路  4Comments