-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapi_models.py
56 lines (42 loc) · 1.59 KB
/
api_models.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
import requests
from kucoin.client import Client
class TradeOgreApi:
def __init__(self, requests_session):
self.api_uri = 'https://tradeogre.com/api/v1'
self.session = requests_session
def get_markets(self):
"""Return Markets in JSON format."""
this_uri = self.api_uri + '/markets'
answer = requests.get(this_uri)
return answer.json()
def get_market_currency(self, market_name):
markets = self.get_markets()
found_market = None
for x, market in enumerate(markets):
if list(market.keys())[0] == market_name:
found_market = markets[x]
break
return found_market
def get_mk_cur_by_list(self, markets_list):
markets = self.get_markets()
found_markets = []
for x, market in enumerate(markets):
if list(market.keys())[0] in markets_list:
found_markets.append(markets[x])
return found_markets
def get_order_book(self, market_name):
this_uri = self.api_uri + '/orders/' + market_name
answer = requests.get(this_uri)
return answer.json()
class KucoinApi:
def __init__(self, auth):
self.api_uri = 'https://openapi-sandbox.kucoin.com'
self.api_key = auth['api_key']
self.api_secret = auth['api_secret']
self.api_passphrase = auth['api_passphrase']
self.client = Client(self.api_key, self.api_secret, self.api_passphrase)
def get_markets(self):
markets = self.client.get_markets()
return markets
def check_keys(self):
pass