-
Notifications
You must be signed in to change notification settings - Fork 3
/
account_balance.py
85 lines (78 loc) · 1.69 KB
/
account_balance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
## Script to get the balance of the account:
api_key = ''
api_secret = ''
from binance.client import Client
client = Client(api_key, api_secret)
## ACCOUNT FUNCTIONS
# Get account info
info = client.get_account()
# Example response:
"""
{
"makerCommission": 15,
"takerCommission": 15,
"buyerCommission": 0,
"sellerCommission": 0,
"canTrade": true,
"canWithdraw": true,
"canDeposit": true,
"balances": [
{
"asset": "BTC",
"free": "4723846.89208129",
"locked": "0.00000000"
},
{
"asset": "LTC",
"free": "4763368.68006011",
"locked": "0.00000000"
}
]
}
"""
# Get asset balance
balance = client.get_asset_balance(asset='BTC')
# Example response:
"""
{
"asset": "BTC",
"free": "4723846.89208129",
"locked": "0.00000000"
}
"""
# Get account status
status = client.get_account_status()
# Example response:
"""
{
"msg": "Order failed:Low Order fill rate! Will be reactivated after 5 minutes.",
"success": true,
"objs": [
"5"
]
}
"""
# Getting the open orders of a symbol (after getting the account info and the balance of the traded cryptos)
orders = client.get_open_orders(symbol='BNBBTC')
## or of all the open orders:
orders = client.get_open_orders()
# Example response:
"""
[
{
"symbol": "LTCBTC",
"orderId": 1,
"clientOrderId": "myOrder1",
"price": "0.1",
"origQty": "1.0",
"executedQty": "0.0",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0.0",
"icebergQty": "0.0",
"time": 1499827319559
}
]
"""