This repository was archived by the owner on Jul 7, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 755
Expand file tree
/
Copy pathtools.py
More file actions
90 lines (69 loc) · 2.36 KB
/
Copy pathtools.py
File metadata and controls
90 lines (69 loc) · 2.36 KB
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
86
87
88
89
90
'''
Copyright (C) 2017-2025 Bryant Moscon - [email protected]
Please see the LICENSE file for the terms and conditions
associated with this software.
'''
from urllib.request import urlopen
import requests
from yapic import json
"""
Just random functions I used while developing the library.
They may come in handy again . . .
"""
def poloniex_get_ticker_map():
"""
mappings between pair strings and pair IDs are not documented
so we can use their ticker endpoint which has the mappings embedded
"""
with urlopen("https://poloniex.com/public?command=returnTicker") as url:
data = json.loads(url.read().decode())
print("{")
for key in data:
print("'{}': {},".format(key, data[key]['id']))
print("}")
print("[", end='')
for key in data:
print("'{}', ".format(key), end='')
print("]", end='')
def bittrex_get_trading_pairs():
with urlopen('https://bittrex.com/api/v1.1/public/getmarkets') as url:
data = json.loads(url.read().decode())
print("[", end='')
for market in data['result']:
print("'{}', ".format(market['MarketName']), end='')
print("]", end='')
def coinbase_get_trading_pairs():
with urlopen('https://api.pro.coinbase.com/products') as url:
data = json.loads(url.read().decode())
print('[', end='')
for pair in data:
print("'" + pair['id'] + "',",)
print("]")
def hitbtc_get_trading_pairs():
with urlopen('https://api.hitbtc.com/api/2/public/symbol') as url:
data = json.loads(url.read().decode())
print('[', end='')
for pair in data:
print("'" + pair['id'] + "',",)
print("]")
def cex_get_trading_pairs():
r = requests.get('https://cex.io/api/currency_limits')
print("[")
for data in r.json()['data']['pairs']:
print("'{}-{}',".format(data['symbol1'], data['symbol2']))
print("]")
def exx_get_trading_pairs():
r = requests.get('https://api.exx.com/data/v1/tickers')
print("[")
for key in r.json():
print("'{}',".format(key))
print("]")
def bitmex_instruments():
r = requests.get('https://www.bitmex.com/api/v1/instrument/active')
print("[")
data = r.json()
for d in data:
print("'{}',".format(d['symbol']))
print("]")
if __name__ == '__main__':
bitmex_instruments()