"Working with a pair of {pair}".format(pair=pair_name)) # Get pair limits from the exchange for elem in limits['symbols']: if elem['symbol'] == pair_name: CURR_LIMITS = elem break else: raise Exception( "Could not find settings for the selected pair" + pair_name) # We receive balances from the exchange in the specified currencies balances = { balance['asset']: float(balance['free']) for balance in bot.account()['balances'] if balance['asset'] in [pair_obj['base'], pair_obj['quote']] } log.debug("Balance {balance}".format(balance=[ "{k}: {bal: 0.8f}".format(k=k, bal=balances[k]) for k in balances ])) # If the balance allows you to trade - above the exchange limits and above the specified amount in the settings if balances[pair_obj['base']] >= pair_obj['spend_sum']: # We receive information on offers from a glass, in the quantity specified in the settings offers = bot.depth(symbol=pair_name, limit=pair_obj['offers_amount']) # We take purchase prices(for sales prices, replace bids with asks) prices = [float(bid[0]) for bid in offers['bids']]
from binance_api import Binance bot = Binance(API_KEY='**********', API_SECRET='**********') print('account', bot.account())