Skip to content

Instantly share code, notes, and snippets.

@sosukeinu
Forked from anfederico/dust.py
Created January 22, 2018 14:32
Show Gist options
  • Save sosukeinu/f55dec31a0111d9cc645c2aafed787df to your computer and use it in GitHub Desktop.
Save sosukeinu/f55dec31a0111d9cc645c2aafed787df to your computer and use it in GitHub Desktop.
Get rid of dust on your Binance account
# 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