· 4 years ago · Jul 31, 2021, 10:46 PM
1from binance.client import Client
2
3try:
4 client = Client(input('Your API Key: '), input('Your secret key: '))
5except Exception as e:
6 print('Error: ', e)
7
8
9# Step 1:
10try:
11 balances = client.get_account()['balances']
12 for i in balances:
13 print('[*]', i['asset'], '(free:', i['free'], 'locked: ', i['locked']+')\n')
14except Exception as e:
15 print('Error: ', e)
16
17
18# Step 4:
19while True:
20 if input('Would you like to do a withdrawal? ') != 'y':
21 break
22 amount = float(input('How much would you like to withdraw? '))
23 asset = input('What asset would you like to withdraw? ')
24 address = input('Where would you like to send the money? ')
25 try:
26 client.withdraw(asset=asset, address=address, amount=amount)
27 except Exception as e:
28 print('Error: ', e)
29 print('Please try again.')
30 else:
31 print('Withdrawal complete.')
32