def ticker(self, currency_pair=None): # https://openapi.digifinex.vip/v2/ticker?apiKey=15d12cfa0a69be # https://openapi.digifinex.vip/v2/ticker?symbol=usdt_btc&apiKey=15d12cfa0a69be TICKER_RESOURCE = "/v2/ticker" if currency_pair is None: params = 'apiKey=' + self.account.api_key result = requests.get(self.base_url + TICKER_RESOURCE, params) if result.status_code != 200: return ERRORCODE.Error_Code_For_Status_Code[result.status_code] result = json.loads(result.text) code = result['code'] if code != 0: return ERRORCODE.Error_code_for_DigiFinex[code] # 这里要重新写 result = result['ticker'] return result else: params = 'symbol=' + make_currency_pair_string(currency_pair) params = append_api_key(params, self.account.api_key) result = requests.get(self.base_url + TICKER_RESOURCE, params) if result.status_code != 200: return ERRORCODE.Error_Code_For_Status_Code[result.status_code] result = json.loads(result.text) code = result['code'] if code != 0: return ERRORCODE.Error_code_for_DigiFinex[code] #这里要重新写 # result=result['ticker'][make_currency_pair_string(currency_pair)] result = universal.Ticker(self.MARKET, currency_pair, result) return result
def ticker(self, currency_pair='btc_usdt'): TICKER_RESOURCE = "/api/v1/ticker.do" params = '' if currency_pair: params = 'symbol=%(symbol)s' % {'symbol': currency_pair} result = universal.Ticker( self.__market, currency_pair, httpGet(self.base_url, TICKER_RESOURCE, params)) return result
def ticker(self, currency_pair, aggregational=False): # /ticker.php?c=all&mk_type=cnc TICKER_RESOURCE = "/ticker.php" params = make_currency_pair_string(currency_pair) result = requests.get(self.base_url + TICKER_RESOURCE, params) if result.status_code != 200: return ERRORCODE.Error_Code_For_Status_Code[result.status_code] if aggregational == True: result = json.loads(result.text) else: result = universal.Ticker(self.MARKET, currency_pair, result.text) return result