-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.py
48 lines (34 loc) · 1.3 KB
/
api.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
from utilities import get_result
"""
--------------------------------------------------------------------------------------------------------------------------------
PUBLIC
--------------------------------------------------------------------------------------------------------------------------------
"""
PUBLIC_URL_BASE = "https://api.kraken.com/0/public/"
def get_asset_info(assets=[]):
url = PUBLIC_URL_BASE + "Assets"
if assets:
url = url + '?asset={}'.format(','.join(assets))
return get_result(url)
def get_all_asset_altnames():
assets = get_asset_info()
return [assets[asset]['altname'] for asset in assets]
def get_currency_pairs(pairs=[]):
url = PUBLIC_URL_BASE + "AssetPairs"
if pairs:
url = url + '?pair={}'.format(','.join(pairs))
return get_result(url)
def get_ticker_info(pairs=None):
url = PUBLIC_URL_BASE + "Ticker"
if pairs:
url = url + '?pair={}'.format(','.join(pairs))
print(url)
return get_result(url)
def get_all_wsnames():
result = get_currency_pairs()
if not result:
return []
return [coin['wsname'] for coin in result.values() if 'wsname' in coin]
#print(get_asset_info(['XBT']))
#print(get_ticker_info(['XBTUSD', 'ETHUSD', 'LTCUSD']))
#print(get_all_asset_altnames())