From eb00dec39c1097f24b1d6ba0ee2e8fa963a9063a Mon Sep 17 00:00:00 2001 From: Nicolas Baum Date: Wed, 3 Mar 2021 12:27:56 -0300 Subject: [PATCH 1/3] 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/3] 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 5e11a5314688b9d23f67072396ca4149ed05a171 Mon Sep 17 00:00:00 2001 From: Nicolas Baum Date: Tue, 30 Mar 2021 16:03:12 -0300 Subject: [PATCH 3/3] 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))