Example #1
0
def get_balance_poloniex_result_processor(json_document, timest):
    if is_error(json_document):

        msg = "get_balance_poloniex_result_processor - error response - {er}".format(
            er=json_document)
        log_to_file(msg, ERROR_LOG_FILE_NAME)

        return None

    return Balance.from_poloniex(timest, json_document)
Example #2
0
def get_order_book_poloniex_result_processor(json_document, pair_name, timest):
    if is_error(json_document):

        msg = "get_order_book_poloniex_result_processor - error response - {er}".format(
            er=json_document)
        log_to_file(msg, ERROR_LOG_FILE_NAME)

        return None

    return OrderBook.from_poloniex(json_document, pair_name, timest)
Example #3
0
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])
Example #4
0
def parse_order_id_poloniex(json_document):
    """
     {u'orderNumber': u'15573359248', u'resultingTrades': []}
    """

    if is_error(json_document) or "orderNumber" not in json_document:

        msg = "parse_order_id_poloniex - error response - {er}".format(
            er=json_document)
        log_to_file(msg, ERROR_LOG_FILE_NAME)

        return None

    return json_document["orderNumber"]
Example #5
0
def get_history_poloniex_result_processor(json_document, pair_name, timest):
    all_history_records = []

    if is_error(json_document):

        msg = "get_history_poloniex_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:
        all_history_records.append(
            TradeHistory.from_poloniex(rr, pair_name, timest))

    return all_history_records
Example #6
0
def get_open_orders_poloniex_result_processor(json_document, pair_name):
    orders = []
    if is_error(json_document):

        msg = "get_open_orders_poloniex_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:
        order = Trade.from_poloniex(entry, pair_name)
        if order is not None:
            orders.append(order)

    return STATUS.SUCCESS, orders
Example #7
0
def get_order_history_poloniex_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):

        msg = "get_order_history_poloniex_result_processor - error response - {er}".format(er=json_document)
        log_to_file(msg, ERROR_LOG_FILE_NAME)

        return STATUS.FAILURE, orders

    if pair_name != "all":
        orders = parse_orders_currency(json_document, pair_name)
    else:
        for pair in json_document:
            orders += parse_orders_currency(json_document[pair], pair)

    return STATUS.SUCCESS, orders
Example #8
0
def get_ohlc_poloniex_result_processor(json_response, pair_name, date_start,
                                       date_end):
    result_set = []

    if is_error(json_response):
        msg = "get_ohlc_poloniex_result_processor - error response - {er}".format(
            er=json_response)
        log_to_file(msg, ERROR_LOG_FILE_NAME)

        return result_set

    for record in json_response:
        #
        #   There is option to get his kind of response:
        #   [{
        #       "date": 0, "high": 0, "low": 0, "open": 0, "close": 0, "volume": 0,
        #       "quoteVolume": 0, "weightedAverage": 0
        #   }]
        #
        if long(record["date"]) != 0:
            result_set.append(Candle.from_poloniex(record, pair_name))

    return result_set