From eb00dec39c1097f24b1d6ba0ee2e8fa963a9063a Mon Sep 17 00:00:00 2001 From: Nicolas Baum Date: Wed, 3 Mar 2021 12:27:56 -0300 Subject: [PATCH 1/9] Fix price_typ=inventory_cost will trigger config for inventory_cost --- .../pure_market_making/pure_market_making_config_map.py | 6 ++++++ 1 file changed, 6 insertions(+) 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 a8d69eec0b..a8a324300b 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 @@ -99,6 +99,10 @@ def validate_price_floor_ceiling(value: str) -> Optional[str]: if not (decimal_value == Decimal("-1") or decimal_value > Decimal("0")): 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 +245,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 +313,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", From 2f3299a5d96e6ecd764154ff36a9b0b8f137d0d6 Mon Sep 17 00:00:00 2001 From: Nicolas Baum Date: Wed, 3 Mar 2021 12:32:32 -0300 Subject: [PATCH 2/9] Fixed flake8 --- .../strategy/pure_market_making/pure_market_making_config_map.py | 1 + 1 file changed, 1 insertion(+) 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 a8a324300b..b63809f817 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 @@ -99,6 +99,7 @@ def validate_price_floor_ceiling(value: str) -> Optional[str]: if not (decimal_value == Decimal("-1") or decimal_value > Decimal("0")): 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 From 3dafda54e59a6db1b67089514a8479260106b0d3 Mon Sep 17 00:00:00 2001 From: Kirill Stroukov Date: Sat, 13 Mar 2021 20:09:27 +0100 Subject: [PATCH 3/9] 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 4f9e4f9b5e91e421cc7fe603ad7eb128cdb48f65 Mon Sep 17 00:00:00 2001 From: TheHolyRoger Date: Fri, 26 Mar 2021 03:59:04 +0000 Subject: [PATCH 4/9] Fix / Disable `-Wstrict-prototypes` warning during build --- setup.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/setup.py b/setup.py index 083859ad4c..d8f3934d02 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}, ) From 5e11a5314688b9d23f67072396ca4149ed05a171 Mon Sep 17 00:00:00 2001 From: Nicolas Baum Date: Tue, 30 Mar 2021 16:03:12 -0300 Subject: [PATCH 5/9] Added case where paper_trade is enabled for UserBalances. Added special case for prompt_a_config with inventory_price_prompt --- hummingbot/client/command/config_command.py | 9 ++++++--- hummingbot/client/command/create_command.py | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hummingbot/client/command/config_command.py b/hummingbot/client/command/config_command.py index 444609ce50..a76172e6ee 100644 --- a/hummingbot/client/command/config_command.py +++ b/hummingbot/client/command/config_command.py @@ -236,9 +236,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 21881542b7..1cdaaddc4e 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)) From e0ae5b38cf85a20c6daa9b9cfba8b17d670c0377 Mon Sep 17 00:00:00 2001 From: vic-en Date: Wed, 31 Mar 2021 00:41:00 +0100 Subject: [PATCH 6/9] (fix) fix binance perp funding payment function --- .../binance_perpetual/binance_perpetual_derivative.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)) From 4d25aa32a8d8b6ca0b6c597047072b27a34bb4d0 Mon Sep 17 00:00:00 2001 From: Daniel Tan Date: Thu, 1 Apr 2021 11:41:43 +0800 Subject: [PATCH 7/9] (refactor) remove bitmax config from conf_fee_overrides_TEMPLATE.yml --- hummingbot/templates/conf_fee_overrides_TEMPLATE.yml | 3 --- 1 file changed, 3 deletions(-) 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: 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 8/9] 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 9/9] 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