diff --git a/hummingbot/client/command/config_command.py b/hummingbot/client/command/config_command.py index 601e7088f7..1c72502953 100644 --- a/hummingbot/client/command/config_command.py +++ b/hummingbot/client/command/config_command.py @@ -235,9 +235,12 @@ async def inventory_price_prompt( exchange = config_map["exchange"].value market = config_map["market"].value base_asset, quote_asset = market.split("-") - balances = await UserBalances.instance().balances( - exchange, base_asset, quote_asset - ) + if global_config_map["paper_trade_enabled"].value: + balances = global_config_map["paper_trade_account_balance"].value + else: + balances = await UserBalances.instance().balances( + exchange, base_asset, quote_asset + ) if balances.get(base_asset) is None: return diff --git a/hummingbot/client/command/create_command.py b/hummingbot/client/command/create_command.py index eb6d6e7487..4ca413be94 100644 --- a/hummingbot/client/command/create_command.py +++ b/hummingbot/client/command/create_command.py @@ -97,6 +97,9 @@ async def prompt_a_config(self, # type: HummingbotApplication config: ConfigVar, input_value=None, assign_default=True): + if config.key == "inventory_price": + await self.inventory_price_prompt(self.strategy_config_map, input_value) + return if input_value is None: if assign_default: self.app.set_text(parse_config_default_to_text(config)) diff --git a/hummingbot/client/config/config_helpers.py b/hummingbot/client/config/config_helpers.py index 2f8b491c75..8bc0b2ebcc 100644 --- a/hummingbot/client/config/config_helpers.py +++ b/hummingbot/client/config/config_helpers.py @@ -171,7 +171,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"]: diff --git a/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py b/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py index 94a4bbb2e5..252895e083 100644 --- a/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py +++ b/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py @@ -556,7 +556,7 @@ async def _user_stream_event_listener(self): update_data = event_message.get("a", {}) event_reason = update_data.get("m", {}) if event_reason == "FUNDING_FEE": - await self.get_funding_payment(event_message.get("E", int(time.time()))) + await self.get_funding_payment() else: # update balances for asset in update_data.get("B", []): @@ -933,7 +933,7 @@ async def get_funding_payment(self): funding_payment_tasks = [] for pair in self._trading_pairs: funding_payment_tasks.append(self.request(path="/fapi/v1/income", - params={"symbol": convert_to_exchange_trading_pair(pair), "incomeType": "FUNDING_FEE", "limit": 1}, + params={"symbol": convert_to_exchange_trading_pair(pair), "incomeType": "FUNDING_FEE", "limit": len(self._account_positions)}, method=MethodType.POST, add_timestamp=True, is_signed=True)) 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: diff --git a/hummingbot/core/utils/trading_pair_fetcher.py b/hummingbot/core/utils/trading_pair_fetcher.py index ea07080568..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,15 +48,13 @@ 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) - self.ready = True - - async def call_fetch_pairs(self, fetch_fn, exchange_name): + 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 - try: - self.trading_pairs[exchange_name] = await fetch_fn - except (asyncio.TimeoutError, asyncio.CancelledError, requests.exceptions.RequestException): - self.logger().error(f"Connector {exchange_name} failed to retrieve its trading pairs. " - f"Trading pairs autocompletion won't work.") - self.trading_pairs[exchange_name] = [] + for connector, result in self.trading_pairs.items(): + if isinstance(result, asyncio.TimeoutError): + self.trading_pairs[connector] = [] + self.ready = True diff --git a/hummingbot/strategy/pure_market_making/pure_market_making_config_map.py b/hummingbot/strategy/pure_market_making/pure_market_making_config_map.py index 1501d16c6c..e488ec0f17 100644 --- a/hummingbot/strategy/pure_market_making/pure_market_making_config_map.py +++ b/hummingbot/strategy/pure_market_making/pure_market_making_config_map.py @@ -100,6 +100,11 @@ def validate_price_floor_ceiling(value: str) -> Optional[str]: return "Value must be more than 0 or -1 to disable this feature." +def on_validated_price_type(value: str): + if value == 'inventory_cost': + pure_market_making_config_map["inventory_price"].value = None + + def exchange_on_validated(value: str): required_exchanges.append(value) @@ -241,6 +246,7 @@ def exchange_on_validated(value: str): prompt="What is the price of your base asset inventory? ", type_str="decimal", validator=lambda v: validate_decimal(v, min_value=Decimal("0"), inclusive=True), + required_if=lambda: pure_market_making_config_map.get("price_type").value == "inventory_cost", default=Decimal("1"), ), "filled_order_delay": @@ -308,6 +314,7 @@ def exchange_on_validated(value: str): type_str="str", required_if=lambda: pure_market_making_config_map.get("price_source").value != "custom_api", default="mid_price", + on_validated=on_validated_price_type, validator=lambda s: None if s in {"mid_price", "last_price", "last_own_trade_price", diff --git a/hummingbot/templates/conf_fee_overrides_TEMPLATE.yml b/hummingbot/templates/conf_fee_overrides_TEMPLATE.yml index 3aff911e85..fa3324522f 100644 --- a/hummingbot/templates/conf_fee_overrides_TEMPLATE.yml +++ b/hummingbot/templates/conf_fee_overrides_TEMPLATE.yml @@ -75,9 +75,6 @@ balancer_taker_fee_amount: uniswap_maker_fee_amount: uniswap_taker_fee_amount: -bitmax_maker_fee: -bitmax_taker_fee: - ascend_ex_maker_fee: ascend_ex_taker_fee: diff --git a/setup.py b/setup.py index 6ad90e8f60..8a0c12f2d2 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from setuptools import setup +from setuptools.command.build_ext import build_ext from Cython.Build import cythonize import numpy as np import os @@ -17,6 +18,16 @@ os.environ["CFLAGS"] = "-std=c++11" +# Avoid a gcc warning below: +# cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid +# for C/ObjC but not for C++ +class BuildExt(build_ext): + def build_extensions(self): + if '-Wstrict-prototypes' in self.compiler.compiler_so: + self.compiler.compiler_so.remove('-Wstrict-prototypes') + super().build_extensions() + + def main(): cpu_count = os.cpu_count() or 8 version = "20210309" @@ -165,6 +176,7 @@ def main(): "bin/hummingbot.py", "bin/hummingbot_quickstart.py" ], + cmdclass={'build_ext': BuildExt}, )