def cancel_order_bittrex(key, order_id): # https://bittrex.com/api/v1.1/market/cancel?apikey=API_KEY&uuid=ORDER_UUID final_url = BITTREX_CANCEL_ORDER + key.api_key + "&nonce=" + str( generate_nonce()) body = { "uuid": order_id, } final_url += _urlencode(body) headers = {"apisign": signed_string(final_url, key.secret)} post_details = PostRequestDetails(final_url, headers, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "cancel_order_bittrex: {res}".format(res=post_details) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") err_msg = "cancel bittrex order with id {id}".format(id=order_id) res = send_get_request_with_header(post_details.final_url, post_details.headers, err_msg, timeout=BITTREX_DEAL_TIMEOUT) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: print_to_console(res, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(res, "market_utils.log") return res
def cancel_order_binance(key, pair_name, order_id): body = { "recvWindow": 5000, "timestamp": get_now_seconds_utc_ms(), "symbol": pair_name, "orderId": order_id } post_details = generate_post_request(BINANCE_CANCEL_ORDER, body, key) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "cancel_order_binance: url - {url} headers - {headers} body - {body}".format( url=post_details.final_url, headers=post_details.headers, body=post_details.body) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") err_msg = "cancel binance order with id {id}".format(id=order_id) res = send_delete_request_with_header(post_details, err_msg, max_tries=3) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: print_to_console(res, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(res, "market_utils.log") return res
def subscribe(self): if self.should_run: die_hard("Poloniex - another subcription thread running?") if get_logging_level() == LOG_ALL_TRACE: msg = "Poloniex - call subscribe!" log_to_file(msg, SOCKET_ERRORS_LOG_FILE_NAME) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) self.should_run = True if get_logging_level() == LOG_ALL_TRACE: websocket.enableTrace(True) # Create connection try: self.ws = create_connection(POLONIEX_WEBSCOKET_URL, enable_multithread=True) self.ws.settimeout(15) except Exception as e: msg = 'Poloniex - connect ws error - {}, retry...'.format(str(e)) print_to_console(msg, LOG_ALL_ERRORS) self.disconnect() return # actual subscription in dedicated thread # self.on_open() self.ws.send(self.subscribe_string) log_conect_to_websocket("Poloniex") # event loop for processing responce while self.should_run: try: compressed_data = self.ws.recv() self.on_public(compressed_data) except Exception as e: log_error_on_receive_from_socket("Poloniex", e) break if self.last_heartbeat_ts: # During last 5 seconds - no heartbeats no any updates ts_now = get_now_seconds_utc() if ts_now - self.last_heartbeat_ts > POLONIEX_WEBSOCKET_TIMEOUT: log_heartbeat_is_missing("Poloniex", POLONIEX_WEBSOCKET_TIMEOUT, self.last_heartbeat_ts, ts_now) break log_subscription_cancelled("Poloniex") self.disconnect()
def send_delete_request_with_header(post_details, error_msg, max_tries): res = STATUS.FAILURE, None try_number = 0 while try_number < max_tries: try_number += 1 try: response = requests.delete(post_details.final_url, data=post_details.body, headers=post_details.headers, timeout=HTTP_TIMEOUT_SECONDS) json_response = response.json() if get_logging_level() >= LOG_ALL_DEBUG: msg = "send_delete_request_with_header: RESULT: {res} for url={url}".format( res=json_response, url=post_details.final_url) log_to_file(msg, DEBUG_LOG_FILE_NAME) status = STATUS.SUCCESS if HTTP_SUCCESS == response.status_code else STATUS.FAILURE return status, json_response except Exception, e: log_error_request_failed("send_delete_request_with_header", post_details.final_url, error_msg, e)
def add_buy_order_binance(key, pair_name, price, amount): post_details = add_buy_order_binance_url(key, pair_name, price, amount) err_msg = "add_buy_order_binance called for {pair} for amount = {amount} with price {price}".format( pair=pair_name, amount=amount, price=price) res = send_post_request_with_header(post_details, err_msg, max_tries=BINANCE_NUM_OF_DEAL_RETRY, timeout=BINANCE_DEAL_TIMEOUT) """ { "orderId": 1373289, "clientOrderId": "Is7wGaKBtLBK7JjDkNAJwn", "origQty": "10.00000000", "symbol": "RDNBTC", "side": "BUY", "timeInForce": "GTC", "status": "NEW", "transactTime": 1512581468544, "type": "LIMIT", "price": "0.00022220", "executedQty": "0.00000000" } """ if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: print_to_console(res, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(res, "market_utils.log") return res
def get_order_history_huobi(key, pair_name, time_start=0, time_end=get_now_seconds_utc()): post_details = get_order_history_huobi_post_details( key, pair_name, time_start, time_end) err_msg = "get_all_orders_huobi for {pair_name}".format( pair_name=pair_name) status_code, json_response = send_get_request_with_header( post_details.final_url, post_details.headers, err_msg, timeout=HUOBI_DEAL_TIMEOUT) if get_logging_level() >= LOG_ALL_DEBUG: msg = "get_order_history_huobi: {sc} {resp}".format(sc=status_code, resp=json_response) print_to_console(msg, LOG_ALL_DEBUG) log_to_file(msg, DEBUG_LOG_FILE_NAME) historical_orders = [] if status_code == STATUS.SUCCESS: status_code, historical_orders = get_orders_huobi_result_processor( json_response, pair_name) return status_code, historical_orders
def _process_futures(cls, work_units_batch): """ Operate under `WorkUnit` objects after returning from async calls. Try to apply job specific constructor method for response returned by exchange. In case constructor method fail for any reason - try to wrap all available details into debug string. :param work_units_batch: :return: array of either object, parsed from exchange responce or error messages as string """ res = [] for work_unit in work_units_batch: if get_logging_level() >= LOG_ALL_DEBUG: log_responce(work_unit) result = None if work_unit.future_value is None or work_unit.future_status_code != HTTP_SUCCESS: result = log_responce_cant_be_parsed(work_unit) res.append(result) else: try: result = work_unit.method(work_unit.future_value_json, *work_unit.args) except Exception as e: pass if result is not None: if type(result) is list: # DK FIXME: terrible! res += result else: res.append(result) else: result = log_responce_cant_be_parsed(work_unit) res.append(result) return res
def add_sell_order_binance(key, pair_name, price, amount): post_details = add_sell_order_binance_url(key, pair_name, price, amount) err_msg = "add_sell_order binance called for {pair} for amount = {amount} " \ "with price {price}".format(pair=pair_name, amount=amount, price=price) # NOTE: Yeah, body must be empty! res = send_post_request_with_header(post_details, err_msg, max_tries=BINANCE_NUM_OF_DEAL_RETRY, timeout=BINANCE_DEAL_TIMEOUT) """ { "orderId": 1373492, "clientOrderId": "e04JGgCpafdrR6O1lOLwgD", "origQty": "1.00000000", "symbol": "RDNBTC", "side": "SELL", "timeInForce": "GTC", "status": "NEW", "transactTime": 1512581721384, "type": "LIMIT", "price": "1.00022220", "executedQty": "0.00000000" } """ if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: print_to_console(res, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(res, "market_utils.log") return res
def cancel_order_huobi(key, order_id): HUOBI_CANCEL_PATH = HUOBI_CANCEL_ORDER + str(order_id) + "/submitcancel" final_url = HUOBI_API_URL + HUOBI_CANCEL_PATH + "?" body = init_body(key) message = _urlencode(body).encode('utf8') msg = "POST\n{base_url}\n{path}\n{msg1}".format(base_url=HUOBI_API_ONLY, path=HUOBI_CANCEL_PATH, msg1=message) signature = sign_string_256_base64(key.secret, msg) body.append(("Signature", signature)) final_url += _urlencode(body).encode('utf8') body = {} post_details = PostRequestDetails(final_url, HUOBI_POST_HEADERS, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "cancel_order_huobi: url - {url} headers - {headers} body - {body}".format( url=final_url, headers=HUOBI_POST_HEADERS, body=body) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") err_msg = "cancel huobi order with id {id}".format(id=order_id) return send_post_request_with_logging(post_details, err_msg)
def get_order_history_binance(key, pair_name, limit=BINANCE_ORDER_HISTORY_LIMIT, last_order_id=None): post_details = get_order_history_binance_post_details( key, pair_name, limit, last_order_id) err_msg = "get_all_orders_binance for {pair_name}".format( pair_name=pair_name) status_code, json_response = send_get_request_with_header( post_details.final_url, post_details.headers, err_msg, timeout=BINANCE_DEAL_TIMEOUT) if get_logging_level() >= LOG_ALL_DEBUG: msg = "get_order_history_binance: {sc} {resp}".format( sc=status_code, resp=json_response) print_to_console(msg, LOG_ALL_DEBUG) log_to_file(msg, DEBUG_LOG_FILE_NAME) historical_orders = [] if status_code == STATUS.SUCCESS: msg = "{fn} - error response - {er}".format( fn=get_order_history_binance.func_name, er=json_response) status_code, historical_orders = get_orders_binance_result_processor( json_response, pair_name, msg) return status_code, historical_orders
def send_post_request_with_logging(post_details, err_msg): res = send_post_request_with_header(post_details, err_msg, max_tries=POLONIEX_NUM_OF_DEAL_RETRY, timeout=POLONIEX_DEAL_TIMEOUT) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: print_to_console(res, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(res, "market_utils.log") return res
def __eq__(self, other): if get_logging_level() >= LOG_ALL_DEBUG: msg = "compare {u} with {b}".format(u=self, b=other) log_to_file(msg, "expire_deal.log") if other is None: return False # NOTE: we actually don't care about timest related crap as it will not be the same :( # return self.__dict__ == other.__dict__ return self.order_id == other.order_id and self.trade_type == other.trade_type and \ self.exchange_id == other.exchange_id and self.pair_id == other.pair_id
def log_arbitrage_determined_volume_not_enough(sell_order_book, buy_order_book, msg_queue): msg = """analyse order book - DETERMINED volume of deal is not ENOUGH {pair_name}: first_exchange: {first_exchange} first exchange volume: <b>{vol1}</b> second_exchange: {second_exchange} second_exchange_volume: <b>{vol2}</b>""".format( pair_name=get_pair_name_by_id(sell_order_book.pair_id), first_exchange=get_exchange_name_by_id(sell_order_book.exchange_id), second_exchange=get_exchange_name_by_id(buy_order_book.exchange_id), vol1=float_to_str(sell_order_book.bid[FIRST].volume), vol2=float_to_str(buy_order_book.ask[LAST].volume)) print_to_console(msg, LOG_ALL_MARKET_NETWORK_RELATED_CRAP) log_to_file(msg, DEBUG_LOG_FILE_NAME) if get_logging_level() >= LOG_ALL_TRACE: msg_queue.add_message(DEBUG_INFO_MSG, msg)
def get_trades_history_binance(key, pair_name, limit, last_order_id=None): final_url = BINANCE_GET_ALL_TRADES body = [] if last_order_id is not None: body.append(("fromId", last_order_id)) body.append(("symbol", pair_name)) body.append(("limit", limit)) body.append(("timestamp", get_now_seconds_utc_ms())) body.append(("recvWindow", 5000)) body.append(("signature", signed_body_256(body, key.secret))) post_details = generate_post_request(final_url, body, key) if get_logging_level() >= LOG_ALL_DEBUG: msg = "get_trades_history_binance: {res}".format(res=post_details) print_to_console(msg, LOG_ALL_DEBUG) log_to_file(msg, DEBUG_LOG_FILE_NAME) err_msg = "get_all_trades_binance for {pair_name}".format( pair_name=pair_name) error_code, res = send_get_request_with_header( post_details.final_url, post_details.headers, err_msg, timeout=BINANCE_DEAL_TIMEOUT) if get_logging_level() >= LOG_ALL_DEBUG: msg = "get_all_trades_binance: {er_c} {r}".format(er_c=error_code, r=res) print_to_console(msg, LOG_ALL_DEBUG) log_to_file(msg, DEBUG_LOG_FILE_NAME) return error_code, res
def add_sell_order_bittrex(key, pair_name, price, amount): post_details = add_sell_order_bittrex_url(key, pair_name, price, amount) err_msg = "add_sell_order bittrex called for {pair} for amount = {amount} with price {price}".format( pair=pair_name, amount=amount, price=price) res = send_get_request_with_header(post_details.final_url, post_details.headers, err_msg, timeout=BITTREX_DEAL_TIMEOUT) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: print_to_console(res, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(res, "market_utils.log") return res
def add_buy_order_poloniex_url(key, pair_name, price, amount): body = generate_body(pair_name, price, amount, "buy") headers = {"Key": key.api_key, "Sign": signed_body(body, key.secret)} # https://poloniex.com/tradingApi final_url = POLONIEX_BUY_ORDER res = PostRequestDetails(final_url, headers, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "add_buy_order_poloniex: {res}".format(res=res) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return res
def subscribe(self): # # FIXME DBG PART - REMOVE AFTER TESTS # if self.should_run: die_hard("Binance another running?") msg = "Binance - call subscribe!" log_to_file(msg, SOCKET_ERRORS_LOG_FILE_NAME) self.should_run = True if get_logging_level() == LOG_ALL_TRACE: websocket.enableTrace(True) # Create connection try: self.ws = create_connection(self.subscription_url, enable_multithread=True) self.ws.settimeout(15) except Exception as e: print('Binance - connect ws error - {}, retry...'.format(str(e))) self.disconnect() return # actual subscription - for binance can be embedded within url # self.ws.send(self.subscription_url) log_conect_to_websocket("Binance") # event loop while self.should_run: try: compressed_data = self.ws.recv() self.on_public(self.ws, compressed_data) except Exception as e: log_error_on_receive_from_socket("Binance", e) break log_subscription_cancelled("Binance") self.disconnect()
def send_request(final_url, error_msg): res = STATUS.FAILURE, None try: response = requests.get(final_url, timeout=HTTP_TIMEOUT_SECONDS) json_response = response.json() if get_logging_level() >= LOG_ALL_DEBUG: log_to_file(json_response, DEBUG_LOG_FILE_NAME) if response.status_code == HTTP_SUCCESS: res = STATUS.SUCCESS, json_response else: res = STATUS.FAILURE, json_response except Exception, e: log_error_request_failed("send_request", final_url, error_msg, e)
def get_open_orders_binance_post_details(key, pair_name): body = { "symbol": pair_name, "timestamp": get_now_seconds_utc_ms(), "recvWindow": 5000 } post_details = generate_post_request(BINANCE_GET_ALL_OPEN_ORDERS, body, key) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "get_open_orders_binance_post_details: {res}".format( res=post_details) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return post_details
def get_open_orders_kraken_post_details(key, pair_name=None): final_url = KRAKEN_BASE_API_URL + KRAKEN_GET_OPEN_ORDERS body = {"nonce": generate_nonce()} headers = { "API-Key": key.api_key, "API-Sign": sign_kraken(body, KRAKEN_GET_OPEN_ORDERS, key.secret) } res = PostRequestDetails(final_url, headers, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "ger_open_orders_kraken: {res}".format(res=res) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return res
def get_balance_bittrex(key): """ https://bittrex.com/api/v1.1/account/getbalances?apikey=8a2dd16465b0469197574ec0a516badb&nonce=1508507525325 {'apisign': 'e6bfb1cc60dcd93d291542cf6c4084e942659be7c363633f710336338a3158b37eb3f999250e5113ffc9e48c18ebe24cf9f4d496f6348a319cbd7f1bc0fc680c'} {} {u'message': u'', u'result': [{u'Available': 21300.0, u'Currency': u'ARDR', u'Balance': 21300.0, u'Pending': 0.0, u'CryptoAddress': u'76730d86115b49b9b7f71578feb35b7da1ca6c13e5f745aa9b630707f5439e68'}, {u'Available': 49704.04069438, u'Currency': u'BAT', u'Balance': 49704.04069438, u'Pending': 0.0, u'CryptoAddress': None}, {u'Available': 0.0, u'Currency': u'BCC', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': u'1H24rzfFWy8thV1AYQch3GByrQQuXA65LY'}, {u'Available': 0.28912516, u'Currency': u'BTC', u'Balance': 0.28912516, u'Pending': 0.0, u'CryptoAddress': u'1EJztGvnKbNj3GeFbt83HhsKeLBYeu8jGq'}, {u'Available': 0.0, u'Currency': u'BTS', u'Balance': 0.0, u'Pending': 0.0, u'CryptoAddress': u'490d0054055c43ada6e'}, Added 07.01.2018 Funny bittrex tend to return this: {u'message': u'', u'result': [], u'success': True} It will lead to error message - so such case should not be considered as proper response. """ post_details = get_balance_bittrex_post_details(key) err_msg = "check bittrex balance called" timest = get_now_seconds_utc() status_code, res = send_post_request_with_header( post_details, err_msg, max_tries=BITTREX_NUM_OF_DEAL_RETRY, timeout=BITTREX_DEAL_TIMEOUT) if get_logging_level() >= LOG_ALL_DEBUG: log_to_file(res, DEBUG_LOG_FILE_NAME) if status_code == STATUS.SUCCESS: status_code, res = get_balance_bittrex_result_processor(res, timest) return status_code, res
def get_open_orders_poloniex_post_details(key, pair_name): body = { 'command': 'returnOpenOrders', 'currencyPair': pair_name, 'nonce': generate_nonce() } headers = {"Key": key.api_key, "Sign": signed_body(body, key.secret)} # https://poloniex.com/tradingApi final_url = POLONIEX_GET_OPEN_ORDERS res = PostRequestDetails(final_url, headers, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "get_open_order_poloniex: {res}".format(res=res) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return res
def add_buy_order_kraken_url(key, pair_name, price, amount): # https://api.kraken.com/0/private/AddOrder final_url = KRAKEN_BASE_API_URL + KRAKEN_BUY_ORDER body = generate_body(pair_name, price, amount, "buy") headers = { "API-Key": key.api_key, "API-Sign": sign_kraken(body, KRAKEN_BUY_ORDER, key.secret) } res = PostRequestDetails(final_url, headers, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "add_buy_order_kraken: {res}".format(res=res) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return res
def get_balance_huobi(key): post_details = get_balance_huobi_post_details(key) err_msg = "check huobi balance called" timest = get_now_seconds_utc() status_code, res = send_get_request_with_header( post_details.final_url, post_details.headers, err_msg, timeout=HUOBI_DEAL_TIMEOUT) if get_logging_level() >= LOG_ALL_DEBUG: log_to_file(res, "balance.log") if status_code == STATUS.SUCCESS: status_code, res = get_balance_huobi_result_processor(res, timest) return status_code, res
def get_open_orders_poloniex(key, pair_name): post_details = get_open_orders_poloniex_post_details(key, pair_name) err_msg = "get poloniex open orders" status_code, res = send_post_request_with_header(post_details, err_msg, max_tries=3) if get_logging_level() >= LOG_ALL_DEBUG: msg = "get_open_orders_poloniex: {res}".format(res=res) print_to_console(msg, LOG_ALL_DEBUG) log_to_file(msg, "market_utils.log") orders = [] if status_code == STATUS.SUCCESS: status_code, orders = get_open_orders_poloniex_result_processor( res, pair_name) return status_code, orders
def subscribe(self): if self.should_run: die_hard("Huobi - another subcription thread running?") self.should_run = True if get_logging_level() == LOG_ALL_TRACE: websocket.enableTrace(True) # Create connection try: self.ws = create_connection(HUOBI_WEBSOCKET_URL, enable_multithread=True, sslopt={"cert_reqs": ssl.CERT_NONE}) self.ws.settimeout(15) except Exception as e: print('Huobi - connect ws error - {}, retry...'.format(str(e))) self.disconnect() return # actual subscription in dedicated thread self.on_open() log_conect_to_websocket("Huobi") # event loop while self.should_run: try: compress_data = self.ws.recv() if compress_data: self.on_public(compress_data) except Exception as e: log_error_on_receive_from_socket("Huobi", e) break log_subscription_cancelled("Huobi") self.disconnect()
def get_closed_orders_kraken_post_details(key, pair_name=None, time_start=0, time_end=get_now_seconds_utc()): final_url = KRAKEN_BASE_API_URL + KRAKEN_GET_CLOSE_ORDERS body = {"nonce": generate_nonce(), "start": time_start, "end": time_end} headers = { "API-Key": key.api_key, "API-Sign": sign_kraken(body, KRAKEN_GET_CLOSE_ORDERS, key.secret) } res = PostRequestDetails(final_url, headers, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "get_closed_orders_kraken: {res}".format(res=res) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return res
def add_buy_order_huobi_url(key, pair_name, price, amount): final_url = BUY_URL + generate_url(key, HUOBI_API_ONLY, HUOBI_BUY_ORDER) params = json.dumps({ "account-id": get_huobi_account(key), "amount": float_to_str(amount), "price": float_to_str(price), "source": "api", "symbol": pair_name, "type": "buy-limit" }) res = PostRequestDetails(final_url, HUOBI_POST_HEADERS, params) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "add_buy_order_huobi: {res}".format(res=res) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return res
def add_sell_order_bittrex_url(key, pair_name, price, amount): # https://bittrex.com/api/v1.1/market/selllimit?apikey=API_KEY&market=BTC-LTC&quantity=1.2&rate=1.3 final_url = BITTREX_SELL_ORDER + key.api_key + "&nonce=" + str(generate_nonce()) body = { "market": pair_name, "quantity": float_to_str(amount), "rate": float_to_str(price) } final_url += _urlencode(body) headers = {"apisign": signed_string(final_url, key.secret)} res = PostRequestDetails(final_url, headers, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "add_sell_order_bittrex: {res}".format(res=res) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return res
def get_order_history_poloniex_post_details(key, pair_name, time_start, time_end, limit): body = { 'command': 'returnTradeHistory', 'currencyPair': pair_name, 'start': time_start, 'end': time_end, 'limit': limit, 'nonce': generate_nonce() } headers = {"Key": key.api_key, "Sign": signed_body(body, key.secret)} # https://poloniex.com/tradingApi final_url = POLONIEX_GET_ORDER_HISTORY post_details = PostRequestDetails(final_url, headers, body) if get_logging_level() >= LOG_ALL_MARKET_RELATED_CRAP: msg = "get orders history poloniex: {res}".format(res=post_details) print_to_console(msg, LOG_ALL_MARKET_RELATED_CRAP) log_to_file(msg, "market_utils.log") return post_details