· 9 years ago · Dec 26, 2016, 06:00 PM
1
2from HttpMD5Util import buildMySign,httpGet,httpPost
3import json
4
5class OKCoinFuture:
6
7 def __init__(self,url,apikey,secretkey):
8 self.__url = url
9 self.__apikey = apikey
10 self.__secretkey = secretkey
11
12 def liquidations(self, symbol, contract_type, status, current_page, page_length):
13 FUTURE_EXPLOSIVE = 'https://www.okcoin.com/api/v1/future_explosive.do'
14 params = {}
15 params['api_key'] = self.__apikey
16 params['symbol'] = symbol
17 params['contract_type'] = contract_type
18 params['status'] = status
19 params['current_page'] = current_page
20 params['page_length'] = page_length
21 params['sign'] = buildMySign(params, self.__secretkey)
22 #print ('current page', params['current_page'])
23 return httpPost(self.__url, FUTURE_EXPLOSIVE, params)
24
25def main(symbol, contract_type):
26
27 okcoinRESTURL = 'www.okcoin.com'
28 key = ***
29 secret = ***
30
31 trade = OKCoinFuture(okcoinRESTURL, key, secret )
32 #symbol = 'btc_usd'
33 #contract_type = 'quarter'
34 status = 1
35 page_length = 16
36 store = []
37 for i in range(1,10):
38 current_page = i
39 rekt = trade.liquidations(symbol, contract_type, status, current_page, page_length)
40 data = json.loads(rekt)['data']
41 [store.append(element) for element in data if element not in store]
42
43 return store
44store = (main( symbol = 'btc_usd',
45 contract_type = 'quarter'))
46print(len(store))