forked from yasinkuyu/binance-trader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
balance.py
44 lines (28 loc) · 961 Bytes
/
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
# -*- coding: UTF-8 -*-
# @yasinkuyu
from BinanceAPI import *
import config
class Binance:
def __init__(self):
self.client = BinanceAPI(config.api_key, config.api_secret)
def balances(self):
balances = self.client.get_account()
for balance in balances['balances'] :
if int(balance["locked"]) > 0 or int(balance["free"]) > 0 :
print '%s: %s' % (balance['asset'], balance['free'])
def orders(self, symbol, limit):
orders = self.client.get_all_orders(symbol=symbol, limit=limit)
print orders
def tickers(self):
return self.client.get_all_tickers()
def server_time(self):
return self.client.get_server_time()
def openorders(self):
return self.client.get_open_orders()
try:
m = Binance()
#m.balances()
m.orders('WTCBTC',10)
except BinanceAPIException as e:
print e.status_code
print e.message