forked from Doaxan/crypto_arbitrage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexmo.py
33 lines (25 loc) · 821 Bytes
/
exmo.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
import time
import ujson
import requests
TICKER = "https://api.exmo.me/v1/ticker/"
def request_json(url):
global json_response
while True:
try:
r = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'})
json_response = ujson.loads(r.content.decode('utf-8'))
except ValueError:
print("error request_json:")
print(url)
print(r)
time.sleep(2)
continue
return json_response
def get_ticker():
return request_json(TICKER)
def get_buy_sell():
exmo_ticker = get_ticker()
exmo_buy_sell = {'name': 'exmo', 'pairs': {}}
for pair in exmo_ticker:
exmo_buy_sell['pairs'][pair] = {'buy': exmo_ticker[pair]['sell_price'], 'sell': exmo_ticker[pair]['buy_price']}
return exmo_buy_sell