From e6894425da2e5996aaf8118debef637cf1bfabf9 Mon Sep 17 00:00:00 2001 From: Nicolas Baum Date: Tue, 9 Mar 2021 21:03:29 -0300 Subject: [PATCH 1/6] (fix) Added check to replace timeout errors with empty lists when fetching trading pairs in slow connections --- hummingbot/core/utils/trading_pair_fetcher.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hummingbot/core/utils/trading_pair_fetcher.py b/hummingbot/core/utils/trading_pair_fetcher.py index 81078f8bb2..1da79fa514 100644 --- a/hummingbot/core/utils/trading_pair_fetcher.py +++ b/hummingbot/core/utils/trading_pair_fetcher.py @@ -53,4 +53,8 @@ async def fetch_all(self): results = await safe_gather(*tasks, return_exceptions=True) self.trading_pairs = dict(zip(fetched_connectors, results)) + # In case trading pair fetching returned timeout, using empty list + for connector, result in self.trading_pairs.items(): + if isinstance(result, asyncio.TimeoutError): + self.trading_pairs[connector] = [] self.ready = True From 0e0d75707604a18fa044dcff974d84e4e5d394d5 Mon Sep 17 00:00:00 2001 From: Nicolas Baum Date: Tue, 9 Mar 2021 23:29:22 -0300 Subject: [PATCH 2/6] Reduced timeout of synchronous call to requests.get to 1 second, so as to allow async calls to use the remaining time in the main wait_for loop of trading_fetchers --- hummingbot/client/config/config_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hummingbot/client/config/config_helpers.py b/hummingbot/client/config/config_helpers.py index 420123336b..3e4877a603 100644 --- a/hummingbot/client/config/config_helpers.py +++ b/hummingbot/client/config/config_helpers.py @@ -169,7 +169,7 @@ def get_erc20_token_addresses() -> Dict[str, List]: address_file_path = TOKEN_ADDRESSES_FILE_PATH token_list = {} - resp = requests.get(token_list_url, timeout=3) + resp = requests.get(token_list_url, timeout=1) decoded_resp = resp.json() for token in decoded_resp["tokens"]: From 11a33e4af31ce6dec639b55960c8c2bf8d1b0437 Mon Sep 17 00:00:00 2001 From: Nullably <37262506+Nullably@users.noreply.github.com> Date: Wed, 10 Mar 2021 12:05:39 +0800 Subject: [PATCH 3/6] (fix) update version number --- hummingbot/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hummingbot/VERSION b/hummingbot/VERSION index 9a859936a4..9b1bb85123 100644 --- a/hummingbot/VERSION +++ b/hummingbot/VERSION @@ -1 +1 @@ -dev-0.38.0 +0.37.1 From 3dafda54e59a6db1b67089514a8479260106b0d3 Mon Sep 17 00:00:00 2001 From: Kirill Stroukov Date: Sat, 13 Mar 2021 20:09:27 +0100 Subject: [PATCH 4/6] fix/Beaxy float rounding --- .../exchange/beaxy/beaxy_exchange.pyx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hummingbot/connector/exchange/beaxy/beaxy_exchange.pyx b/hummingbot/connector/exchange/beaxy/beaxy_exchange.pyx index 53f4d09608..9fe3817fbf 100644 --- a/hummingbot/connector/exchange/beaxy/beaxy_exchange.pyx +++ b/hummingbot/connector/exchange/beaxy/beaxy_exchange.pyx @@ -363,8 +363,8 @@ cdef class BeaxyExchange(ExchangeBase): tracked_order.last_state = order_update['order_status'] if order_update['filled_size']: - execute_price = Decimal(order_update['limit_price'] if order_update['limit_price'] else order_update['average_price']) - execute_amount_diff = Decimal(order_update['filled_size']) - tracked_order.executed_amount_base + execute_price = Decimal(str(order_update['limit_price'] if order_update['limit_price'] else order_update['average_price'])) + execute_amount_diff = Decimal(str(order_update['filled_size'])) - tracked_order.executed_amount_base # Emit event if executed amount is greater than 0. if execute_amount_diff > s_decimal_0: @@ -398,9 +398,9 @@ cdef class BeaxyExchange(ExchangeBase): if tracked_order.is_done: if not tracked_order.is_failure and not tracked_order.is_cancelled: - new_confirmed_amount = Decimal(order_update['size']) + new_confirmed_amount = Decimal(str(order_update['size'])) execute_amount_diff = new_confirmed_amount - tracked_order.executed_amount_base - execute_price = Decimal(order_update['limit_price'] if order_update['limit_price'] else order_update['average_price']) + execute_price = Decimal(str(order_update['limit_price'] if order_update['limit_price'] else order_update['average_price'])) # Emit event if executed amount is greater than 0. if execute_amount_diff > s_decimal_0: @@ -748,8 +748,8 @@ cdef class BeaxyExchange(ExchangeBase): res = await self._api_request('get', BeaxyConstants.TradingApi.TRADE_SETTINGS_ENDPOINT) for symbol_data in res['symbols']: symbol = self.convert_from_exchange_trading_pair(symbol_data['name']) - self._maker_fee_percentage[symbol] = Decimal(symbol_data['maker_fee']) - self._taker_fee_percentage[symbol] = Decimal(symbol_data['taker_fee']) + self._maker_fee_percentage[symbol] = Decimal(str(symbol_data['maker_fee'])) + self._taker_fee_percentage[symbol] = Decimal(str(symbol_data['taker_fee'])) self._last_fee_percentage_update_timestamp = current_timestamp except asyncio.CancelledError: @@ -774,8 +774,8 @@ cdef class BeaxyExchange(ExchangeBase): for balance_entry in account_balances: asset_name = balance_entry['currency'] - available_balance = Decimal(balance_entry['available_balance']) - total_balance = Decimal(balance_entry['total_balance']) + available_balance = Decimal(str(balance_entry['available_balance'])) + total_balance = Decimal(str(balance_entry['total_balance'])) self._account_available_balances[asset_name] = available_balance self._account_balances[asset_name] = total_balance remote_asset_names.add(asset_name) @@ -855,8 +855,8 @@ cdef class BeaxyExchange(ExchangeBase): for msg in msgs: asset_name = msg['currency'] - available_balance = Decimal(msg['available_balance']) - total_balance = Decimal(msg['total_balance']) + available_balance = Decimal(str(msg['available_balance'])) + total_balance = Decimal(str(msg['total_balance'])) self._account_available_balances[asset_name] = available_balance self._account_balances[asset_name] = total_balance @@ -882,8 +882,8 @@ cdef class BeaxyExchange(ExchangeBase): execute_amount_diff = s_decimal_0 if order_status == 'partially_filled': - order_filled_size = Decimal(order['trade_size']) - execute_price = Decimal(order['trade_price']) + order_filled_size = Decimal(str(order['trade_size'])) + execute_price = Decimal(str(order['trade_price'])) execute_amount_diff = order_filled_size - tracked_order.executed_amount_base @@ -917,9 +917,9 @@ cdef class BeaxyExchange(ExchangeBase): elif order_status == 'completely_filled': - new_confirmed_amount = Decimal(order['size']) + new_confirmed_amount = Decimal(str(order['size'])) execute_amount_diff = new_confirmed_amount - tracked_order.executed_amount_base - execute_price = Decimal(order['limit_price'] if order['limit_price'] else order['average_price']) + execute_price = Decimal(str(order['limit_price'] if order['limit_price'] else order['average_price'])) # Emit event if executed amount is greater than 0. if execute_amount_diff > s_decimal_0: From ad4627e0ca2d0bc61402f718a3b7781bcb1c12d6 Mon Sep 17 00:00:00 2001 From: Cooper <49931286+ccraighead@users.noreply.github.com> Date: Thu, 1 Apr 2021 00:37:33 -0400 Subject: [PATCH 5/6] Update trading_pair_fetcher.py --- hummingbot/core/utils/trading_pair_fetcher.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hummingbot/core/utils/trading_pair_fetcher.py b/hummingbot/core/utils/trading_pair_fetcher.py index ae79aefe9a..1da79fa514 100644 --- a/hummingbot/core/utils/trading_pair_fetcher.py +++ b/hummingbot/core/utils/trading_pair_fetcher.py @@ -4,11 +4,11 @@ Any, Optional, ) +from hummingbot.core.utils.async_utils import safe_gather from hummingbot.logger import HummingbotLogger from hummingbot.client.settings import CONNECTOR_SETTINGS, ConnectorType import logging import asyncio -import requests from .async_utils import safe_ensure_future @@ -35,6 +35,8 @@ def __init__(self): safe_ensure_future(self.fetch_all()) async def fetch_all(self): + tasks = [] + fetched_connectors = [] for conn_setting in CONNECTOR_SETTINGS.values(): module_name = f"{conn_setting.base_name()}_connector" if conn_setting.type is ConnectorType.Connector \ else f"{conn_setting.base_name()}_api_order_book_data_source" @@ -46,8 +48,8 @@ async def fetch_all(self): module = getattr(importlib.import_module(module_path), class_name) args = {} args = conn_setting.add_domain_parameter(args) - safe_ensure_future(self.call_fetch_pairs(module.fetch_trading_pairs(**args), conn_setting.name)) - + tasks.append(asyncio.wait_for(asyncio.shield(module.fetch_trading_pairs(**args)), timeout=3)) + fetched_connectors.append(conn_setting.name) results = await safe_gather(*tasks, return_exceptions=True) self.trading_pairs = dict(zip(fetched_connectors, results)) @@ -55,5 +57,4 @@ async def fetch_all(self): for connector, result in self.trading_pairs.items(): if isinstance(result, asyncio.TimeoutError): self.trading_pairs[connector] = [] - - self.ready = True \ No newline at end of file + self.ready = True From 1e4129a1ef6a49e6b34e98deefaad16c036c1085 Mon Sep 17 00:00:00 2001 From: Cooper <49931286+ccraighead@users.noreply.github.com> Date: Thu, 1 Apr 2021 01:52:20 -0400 Subject: [PATCH 6/6] Update VERSION --- hummingbot/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hummingbot/VERSION b/hummingbot/VERSION index 9b1bb85123..9a859936a4 100644 --- a/hummingbot/VERSION +++ b/hummingbot/VERSION @@ -1 +1 @@ -0.37.1 +dev-0.38.0