-
-
Save CamonZ/e47ea0a170a38c21d1a7a1f01cf0561c to your computer and use it in GitHub Desktop.
Get rid of dust on your Binance account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install python-binance | |
from binance.client import Client | |
client = Client(api_key, api_secret) | |
DUST = 0.001 # BTC | |
account = client.get_account() | |
prices = client.get_all_tickers() | |
prices = {p['symbol']: float(p['price']) for p in prices} | |
balances = {b['asset']: float(b['free']) for b in account['balances']} | |
for ticker, amount in balances.items(): | |
try: | |
price = prices['{0}BTC'.format(ticker)] | |
except KeyError: | |
continue | |
value = amount*price | |
if value <= DUST and value > 0: | |
try: | |
order = client.order_market_sell(symbol='{0}BTC'.format(ticker), quantity=round(amount, 4)) | |
print("Selling {0} of {1} = {2} BTC".format(round(amount, 4), ticker, value)) | |
print(order) | |
except Exception as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment