def get_balance_bittrex_result_processor(json_document, timest): if is_error(json_document) or len(json_document["result"]) < 1: msg = "get_balance_bittrex_result_processor - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return STATUS.FAILURE, None return STATUS.SUCCESS, Balance.from_bittrex(timest, json_document["result"])
def get_order_book_bittrex_result_processor(json_document, pair_name, timest): if is_error(json_document): msg = "get_order_book_bittrex_result_processor - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return None return OrderBook.from_bittrex(json_document["result"], pair_name, timest)
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_history_bittrex_result_processor(json_document, pair_name, timest): all_history_records = [] if is_error(json_document) or json_document["result"] is None: msg = "get_history_bittrex_result_processor - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return all_history_records for rr in json_document["result"]: all_history_records.append( TradeHistory.from_bittrex(rr, pair_name, timest)) return all_history_records
def parse_order_id_bittrex(json_document): """ {u'message': u'', u'result': { u'uuid': u'b818589b-f799-476d-9b9c-71bc1ac5c653'}, u'success': True } """ if is_error(json_document) or "uuid" not in json_document["result"]: msg = "parse_order_id_bittrex - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return None return json_document["result"]["uuid"]
def get_ohlc_bittrex_result_processor(json_document, pair_name, date_start, date_end): """ result":[{"O":0.08184725,"H":0.08184725,"L":0.08181559,"C":0.08181559,"V":9.56201864,"T":"2017-07-21T17:26:00","BV":0.78232812}, {"O":0.08181559,"H":0.08184725,"L":0.08181559,"C":0.08184725,"V":3.28483907,"T":"2017-07-21T17:27:00","BV":0.26876032} """ result_set = [] if is_error(json_document) or json_document["result"] is None: msg = "get_ohlc_bittrex_result_processor - error response - {er}".format(er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return result_set for record in json_document["result"]: result_set.append(Candle.from_bittrex(record, pair_name)) return result_set
def get_order_history_bittrex_result_processor(json_document, pair_name): """ json_document - response from exchange api as json string pair_name - for backwords compabilities """ orders = [] if is_error(json_document) or json_document["result"] is None: msg = "get_order_history_bittrex_result_processor - error response - {er}".format( er=json_document) log_to_file(msg, ERROR_LOG_FILE_NAME) return STATUS.FAILURE, orders for entry in json_document["result"]: order = Trade.from_bittrex_history(entry) if order is not None: orders.append(order) return STATUS.SUCCESS, orders