(self, command, req={})
| 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 + '¤cyPair=' + 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" + '¤cyPair=' + 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") |
no test coverage detected