def get_ticker_huobi_result_processor(json_document, pair_name, timest): if is_error(json_document) or json_document.get("tick") is None: msg = "get_ticker_huobi_result_processor - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return None return Ticker.from_huobi(pair_name, timest, json_document["tick"])
def get_ticker_poloniex_result_processor(json_document, pair_name, timest): if is_error( json_document ) or pair_name not in json_document or json_document[pair_name] is None: msg = "get_ticker_poloniex_result_processor - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return None return Ticker.from_poloniex(pair_name, timest, json_document[pair_name])
def get_ticker_bittrex_result_processor(json_document, pair_name, timest): if is_error(json_document) or json_document["result"] is None or json_document["result"]["Ask"] is None or json_document["result"]["Bid"] is None: msg = "get_ticker_bittrex_result_processor - error response - {er}".format(er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return None try: return Ticker.from_bittrex(pair_name, timest, json_document["result"]) except: print "eto pechalno: ", json_document raise
def get_ticker_kraken_result_processor(json_document, pair_name, timest): if is_error(json_document): msg = "get_ticker_kraken_result_processor - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return None if pair_name in json_document["result"]: return Ticker.from_kraken(pair_name, timest, json_document["result"][pair_name]) return None
def get_ticker_binance_result_processor(json_document, pair_name, timest): if is_error(json_document): msg = "get_ticker_binance_result_processor - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return None for entry in json_document: if pair_name in entry["symbol"]: return Ticker.from_binance(entry["symbol"], timest, entry) return None
def get_tickers_poloniex(currency_names, timest): final_url = get_ticker_poloniex_url(currency_names) err_msg = "get_tickerS_poloniex called for list of pairS at {timest}".format( timest=timest) error_code, json_response = send_request(final_url, err_msg) res = [] if error_code == STATUS.SUCCESS and json_response is not None: for pair_name in currency_names: if pair_name in json_response and json_response[ pair_name] is not None: res.append( Ticker.from_poloniex(pair_name, timest, json_response[pair_name])) return res
def create_tickers_and_raw_data_managers(self): symbols = self.instance.get('symbols') for symbol in symbols: periods = symbol.get('periods') for period in periods: exchange = symbol.get('exchange') ss = symbol.get('symbol') # history = symbol.get('history') raw_manager_key = exchange + ss + period ticker_key = exchange + ss if ticker_key not in self.tickers: self.tickers[ticker_key] = Ticker( 256, exchange, symbol, 0, 0, int(round(time.time() * 1000))) if raw_manager_key not in self.raw_data_managers: # don't forget to not actually hardcode the 500 lookback self.raw_data_managers[raw_manager_key] = RawDataManager( exchange, ss, period, 500)
def get_tickers_binance(pair_name, timest): """ {"symbol":"ETHBTC","bidPrice":"0.04039700","bidQty":"4.50700000","askPrice":"0.04047500","askQty":"1.30600000"}, {"symbol":"LTCBTC","bidPrice":"0.00875700","bidQty":"0.24000000","askPrice":"0.00876200","askQty":"0.01000000"}, :param pair_name: :param timest: :return: """ final_url = get_tickers_binance_url(pair_name) err_msg = "get_tickers_binance called for list of pairS at {timest}".format( timest=timest) error_code, r = send_request(final_url, err_msg) res = [] if error_code == STATUS.SUCCESS and r is not None: for entry in r: if entry["symbol"] in pair_name: res.append(Ticker.from_binance(entry["symbol"], timest, entry)) return res