MCPcopy
hub / github.com/owocki/pytrader / api_query

Method api_query

history/poloniex.py:31–57  ·  view source on GitHub ↗
(self, command, req={})

Source from the content-addressed store, hash-verified

29 return after
30
31 def api_query(self, command, req={}):
32
33 if(command == "returnTicker" or command == "return24Volume"):
34 ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/public?command=' + command))
35 return json.loads(ret.read())
36 elif(command == "returnOrderBook"):
37 ret = urllib2.urlopen(urllib2.Request(
38 'http://poloniex.com/public?command=' + command + '&currencyPair=' + str(req['currencyPair'])))
39 return json.loads(ret.read())
40 elif(command == "returnMarketTradeHistory"):
41 ret = urllib2.urlopen(urllib2.Request('http://poloniex.com/public?command=' +
42 "returnTradeHistory" + '&currencyPair=' + str(req['currencyPair'])))
43 return json.loads(ret.read())
44 else:
45 req['command'] = command
46 req['nonce'] = int(time.time()*1000)
47 post_data = urllib.urlencode(req)
48
49 sign = hmac.new(self.Secret, post_data, hashlib.sha512).hexdigest()
50 headers = {
51 'Sign': sign,
52 'Key': self.APIKey
53 }
54
55 ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/tradingApi', post_data, headers))
56 jsonRet = json.loads(ret.read())
57 return self.post_process(jsonRet)
58
59 def returnTicker(self):
60 return self.api_query("returnTicker")

Callers 12

returnTickerMethod · 0.95
return24VolumeMethod · 0.95
returnOrderBookMethod · 0.95
returnBalancesMethod · 0.95
returnOpenOrdersMethod · 0.95
returnTradeHistoryMethod · 0.95
buyMethod · 0.95
sellMethod · 0.95
cancelMethod · 0.95
withdrawMethod · 0.95
returnDepositHistoryMethod · 0.95

Calls 1

post_processMethod · 0.95

Tested by

no test coverage detected