def parse_config_default_to_text(config: ConfigVar) -> str: """ :param config: ConfigVar object :return: text for default value prompt """ if config.default is None: default = "" elif callable(config.default): default = config.default() elif config.type == 'bool' and isinstance( config.prompt, str) and "Yes/No" in config.prompt: default = "Yes" if config.default else "No" else: default = str(config.default) if isinstance(default, Decimal): default = "{0:.4f}".format(default) return default
async def asset_ratio_maintenance_prompt_legacy( self, # type: HummingbotApplication config_map, input_value=None, ): if input_value: config_map['inventory_target_base_pct'].value = Decimal( input_value) else: exchange = config_map['exchange'].value market = config_map["market"].value base, quote = market.split("-") balances = await UserBalances.instance().balances( exchange, base, quote) if balances is None: return base_ratio = await UserBalances.base_amount_ratio( exchange, market, balances) if base_ratio is None: return base_ratio = round(base_ratio, 3) quote_ratio = 1 - base_ratio base, quote = config_map["market"].value.split("-") cvar = ConfigVar( key="temp_config", prompt= f"On {exchange}, you have {balances.get(base, 0):.4f} {base} and " f"{balances.get(quote, 0):.4f} {quote}. By market value, " f"your current inventory split is {base_ratio:.1%} {base} " f"and {quote_ratio:.1%} {quote}." f" Would you like to keep this ratio? (Yes/No) >>> ", required_if=lambda: True, type_str="bool", validator=validate_bool) await self.prompt_a_config_legacy(cvar) if cvar.value: config_map['inventory_target_base_pct'].value = round( base_ratio * Decimal('100'), 1) else: if self.app.to_stop_config: self.app.to_stop_config = False return await self.prompt_a_config_legacy( config_map["inventory_target_base_pct"])
async def prompt_single_variable( self, # type: HummingbotApplication cvar: ConfigVar, requirement_overwrite: bool = False) -> Any: """ Prompt a single variable in the input pane, validates and returns the user input :param cvar: the config var to be prompted :param requirement_overwrite: Set to true when a config var is forced to be prompted, even if it is not required by default setting :return: a validated user input or the variable's default value """ if cvar.required or requirement_overwrite: if cvar.key == "password": return await self._one_password_config() if cvar.key == "strategy_file_path": val = await self._import_or_create_strategy_config() elif cvar.key == "wallet": wallets = list_wallets() if len(wallets) > 0: val = await self._unlock_wallet() else: val = await self._create_or_import_wallet() else: if cvar.value is None: self.app.set_text(parse_cvar_default_value_prompt(cvar)) val = await self.app.prompt(prompt=cvar.prompt, is_password=cvar.is_secure) if not cvar.validate(val): # If the user inputs an empty string, use the default val_is_empty = val is None or (isinstance(val, str) and len(val) == 0) if cvar.default is not None and val_is_empty: val = cvar.default else: self._notify("%s is not a valid %s value" % (val, cvar.key)) val = await self.prompt_single_variable( cvar, requirement_overwrite) else: val = cvar.value if val is None or (isinstance(val, str) and len(val) == 0): val = cvar.default return val
def test_validator_functions_called(self): def validator(_): return "validator error" async def async_validator(_): return "async validator error" loop = asyncio.get_event_loop() var = ConfigVar("key", 'prompt', validator=validator) self.assertEqual("validator error", loop.run_until_complete(var.validate("a"))) var = ConfigVar("key", 'prompt', validator=async_validator) self.assertEqual("async validator error", loop.run_until_complete(var.validate("a")))
async def asset_ratio_maintenance_prompt( self, # type: HummingbotApplication config_map: BaseTradingStrategyConfigMap, input_value: Any = None, ): # pragma: no cover if input_value: config_map.inventory_target_base_pct = input_value else: exchange = config_map.exchange market = config_map.market base, quote = split_hb_trading_pair(market) balances = await UserBalances.instance().balances( exchange, base, quote) if balances is None: return base_ratio = await UserBalances.base_amount_ratio( exchange, market, balances) if base_ratio is None: return base_ratio = round(base_ratio, 3) quote_ratio = 1 - base_ratio cvar = ConfigVar( key="temp_config", prompt= f"On {exchange}, you have {balances.get(base, 0):.4f} {base} and " f"{balances.get(quote, 0):.4f} {quote}. By market value, " f"your current inventory split is {base_ratio:.1%} {base} " f"and {quote_ratio:.1%} {quote}." f" Would you like to keep this ratio? (Yes/No) >>> ", required_if=lambda: True, type_str="bool", validator=validate_bool) await self.prompt_a_config_legacy(cvar) if cvar.value: config_map.inventory_target_base_pct = round( base_ratio * Decimal('100'), 1) elif self.app.to_stop_config: self.app.to_stop_config = False else: await self.prompt_a_config(config_map, config="inventory_target_base_pct")
async def config_single_variable(self, # type: HummingbotApplication cvar: ConfigVar, is_single_key: bool = False) -> Any: if cvar.required or is_single_key: if cvar.key == "strategy_file_path": val = await self._import_or_create_strategy_config() elif cvar.key == "wallet": wallets = list_wallets() if len(wallets) > 0: val = await self._unlock_wallet() else: val = await self._create_or_import_wallet() logging.getLogger("hummingbot.public_eth_address").info(val) else: val = await self.app.prompt(prompt=cvar.prompt, is_password=cvar.is_secure) if not cvar.validate(val): self._notify("%s is not a valid %s value" % (val, cvar.key)) val = await self.config_single_variable(cvar) else: val = cvar.value if val is None or (isinstance(val, string_types) and len(val) == 0): val = cvar.default return val
def convert_to_exchange_trading_pair(hb_trading_pair: str) -> str: return hb_trading_pair.replace("-", "") def convert_from_exchange_trading_pair(trading_pair: str) -> str: base, quote = split_trading_pair(trading_pair) return f"{base}-{quote}" KEYS = { "eterbase_api_key": ConfigVar(key="eterbase_api_key", prompt="Enter your Eterbase API key >>> ", required_if=using_exchange("eterbase"), is_secure=True, is_connect_key=True), "eterbase_secret_key": ConfigVar(key="eterbase_secret_key", prompt="Enter your Eterbase secret key >>> ", required_if=using_exchange("eterbase"), is_secure=True, is_connect_key=True), "eterbase_account": ConfigVar(key="eterbase_account", prompt="Enter your Eterbase account >>> ", required_if=using_exchange("eterbase"), is_secure=True, is_connect_key=True), }
""" Generates the exchange order id based on user uid and client order id. :param user_uid: user uid, :param client_order_id: client order id used for local order tracking :return: order id of length 32 """ time = get_ms_timestamp() return [derive_order_id(userUid, client_order_id, time), time] def gen_client_order_id(is_buy: bool, trading_pair: str) -> str: side = "B" if is_buy else "S" base, quote = trading_pair.split("-") return f"{HBOT_BROKER_ID}-{side}{base[:3]}{quote[:3]}{get_tracking_nonce()}" KEYS = { "ascend_ex_api_key": ConfigVar(key="ascend_ex_api_key", prompt="Enter your AscendEx API key >>> ", required_if=using_exchange("ascend_ex"), is_secure=True, is_connect_key=True), "ascend_ex_secret_key": ConfigVar(key="ascend_ex_secret_key", prompt="Enter your AscendEx secret key >>> ", required_if=using_exchange("ascend_ex"), is_secure=True, is_connect_key=True), }
def market_2_prompt() -> str: connector = amm_arb_config_map.get("connector_2").value example = EXAMPLE_PAIRS.get(connector) return "Enter the token trading pair you would like to trade on %s%s >>> " \ % (connector, f" (e.g. {example})" if example else "") def order_amount_prompt() -> str: trading_pair = amm_arb_config_map["market_1"].value base_asset, quote_asset = trading_pair.split("-") return f"What is the amount of {base_asset} per order? >>> " amm_arb_config_map = { "strategy": ConfigVar(key="strategy", prompt="", default="amm_arb"), "connector_1": ConfigVar(key="connector_1", prompt="Enter your first spot connector (Exchange/AMM) >>> ", prompt_on_new=True, validator=validate_connector, on_validated=exchange_on_validated), "market_1": ConfigVar(key="market_1", prompt=market_1_prompt, prompt_on_new=True, validator=market_1_validator, on_validated=market_1_on_validated), "connector_2": ConfigVar(key="connector_2", prompt="Enter your second spot connector (Exchange/AMM) >>> ",
maker_market = pure_market_making_config_map.get("maker_market").value example = EXAMPLE_PAIRS.get(maker_market) return "Enter the token trading pair you would like to trade on %s%s >>> " \ % (maker_market, f" (e.g. {example})" if example else "") # strategy specific validators def is_valid_maker_market_trading_pair(value: str) -> bool: maker_market = pure_market_making_config_map.get("maker_market").value return is_valid_market_trading_pair(maker_market, value) pure_market_making_config_map = { "maker_market": ConfigVar(key="maker_market", prompt="Enter your maker exchange name >>> ", validator=is_exchange, on_validated=lambda value: required_exchanges.append(value)), "maker_market_trading_pair": ConfigVar(key="primary_market_trading_pair", prompt=maker_trading_pair_prompt, validator=is_valid_maker_market_trading_pair), "mode": ConfigVar( key="mode", prompt= "Enter quantity of bid/ask orders per side (single/multiple) >>> ", type_str="str", validator=lambda v: v in {"single", "multiple"}, default="single"), "bid_place_threshold": ConfigVar(
def is_exchange_information_valid(exchange_info: Dict[str, Any]) -> bool: """ Verifies if a trading pair is enabled to operate with based on its exchange information :param exchange_info: the exchange information for a trading pair :return: True if the trading pair is enabled, False otherwise """ return exchange_info.get( "status", None) == "TRADING" and "SPOT" in exchange_info.get( "permissions", list()) KEYS = { "binance_api_key": ConfigVar(key="binance_api_key", prompt="Enter your Binance API key >>> ", required_if=using_exchange("binance"), is_secure=True, is_connect_key=True), "binance_api_secret": ConfigVar(key="binance_api_secret", prompt="Enter your Binance API secret >>> ", required_if=using_exchange("binance"), is_secure=True, is_connect_key=True), } OTHER_DOMAINS = ["binance_us"] OTHER_DOMAINS_PARAMETER = {"binance_us": "us"} OTHER_DOMAINS_EXAMPLE_PAIR = {"binance_us": "BTC-USDT"} OTHER_DOMAINS_DEFAULT_FEES = {"binance_us": [0.1, 0.1]} OTHER_DOMAINS_KEYS = {
% (market, f" (e.g. {example})" if example else "") def str2bool(value: str): return str(value).lower() in ("yes", "true", "t", "1") # checks if the trading pair is valid def validate_market_trading_pair_tuple(value: str) -> Optional[str]: market = dev_simple_trade_config_map.get("market").value return validate_market_trading_pair(market, value) dev_simple_trade_config_map = { "strategy": ConfigVar(key="strategy", prompt="", default="dev_simple_trade"), "market": ConfigVar(key="market", prompt="Enter the name of the exchange >>> ", validator=validate_exchange, on_validated=lambda value: required_exchanges.append(value)), "market_trading_pair_tuple": ConfigVar(key="market_trading_pair_tuple", prompt=trading_pair_prompt, validator=validate_market_trading_pair_tuple), "order_type": ConfigVar( key="order_type", prompt="Enter type of order (limit/market) default is market >>> ", type_str="str", validator=lambda v: None
maker_market = pure_market_making_config_map.get("maker_market").value example = EXAMPLE_PAIRS.get(maker_market) return "Enter the token symbol you would like to trade on %s%s >>> " \ % (maker_market, f" (e.g. {example})" if example else "") # strategy specific validators def is_valid_maker_market_symbol(value: str) -> bool: maker_market = pure_market_making_config_map.get("maker_market").value return is_valid_market_symbol(maker_market, value) pure_market_making_config_map = { "maker_market": ConfigVar(key="maker_market", prompt="Enter your maker exchange name >>> ", validator=is_exchange, on_validated=lambda value: required_exchanges.append(value)), "maker_market_symbol": ConfigVar(key="primary_market_symbol", prompt=maker_symbol_prompt, validator=is_valid_maker_market_symbol), "mode": ConfigVar(key="mode", prompt="Enter quantity of orders per side [bid/ask] " "(single/multiple) default is single >>> ", type_str="str", validator=lambda v: v in {"single", "multiple"}, default="single"), "bid_place_threshold": ConfigVar( key="bid_place_threshold",
if use_oracle and (first_base != second_base or first_quote != second_quote): settings.required_rate_oracle = True settings.rate_oracle_pairs = [] if first_base != second_base: settings.rate_oracle_pairs.append(f"{second_base}-{first_base}") if first_quote != second_quote: settings.rate_oracle_pairs.append(f"{second_quote}-{first_quote}") else: settings.required_rate_oracle = False settings.rate_oracle_pairs = [] arbitrage_config_map = { "strategy": ConfigVar(key="strategy", prompt="", default="arbitrage"), "primary_market": ConfigVar( key="primary_market", prompt="Enter your primary spot connector >>> ", prompt_on_new=True, validator=validate_exchange, on_validated=lambda value: settings.required_exchanges.append(value), ), "secondary_market": ConfigVar( key="secondary_market", prompt="Enter your secondary spot connector >>> ", prompt_on_new=True, validator=validate_exchange, on_validated=secondary_market_on_validated,
def using_bamboo_coordinator_mode() -> bool: return global_config_map.get("bamboo_relay_use_coordinator").value MIN_QUOTE_ORDER_AMOUNTS = [["BTC", 0.0011], ["ETH", 0.05], ["USD", 11], ["BNB", 0.5]] # Main global config store global_config_map = { # The variables below are usually not prompted during setup process "client_id": ConfigVar(key="client_id", prompt=None, required_if=lambda: False, default=generate_client_id()), "log_level": ConfigVar(key="log_level", prompt=None, required_if=lambda: False, default="INFO"), "debug_console": ConfigVar(key="debug_console", prompt=None, type_str="bool", required_if=lambda: False, default=False), "strategy_report_interval": ConfigVar(key="strategy_report_interval", prompt=None,
def market_trading_pair_prompt() -> str: exchange = celo_arb_config_map.get("secondary_exchange").value example = AllConnectorSettings.get_example_pairs().get(exchange) return "Enter the token trading pair you would like to trade on %s%s >>> " \ % (exchange, f" (e.g. {example})" if example else "") def order_amount_prompt() -> str: trading_pair = celo_arb_config_map["secondary_market"].value base_asset, quote_asset = trading_pair.split("-") return f"What is the amount of {base_asset} per order? >>> " celo_arb_config_map = { "strategy": ConfigVar( key="strategy", prompt="", default="celo_arb"), "secondary_exchange": ConfigVar( key="secondary_exchange", prompt="Enter your secondary spot connector >>> ", prompt_on_new=True, validator=validate_exchange, on_validated=exchange_on_validated), "secondary_market": ConfigVar( key="secondary_market", prompt=market_trading_pair_prompt, prompt_on_new=True, validator=lambda x: validate_market_trading_pair(celo_arb_config_map["secondary_exchange"].value, x)), "order_amount": ConfigVar( key="order_amount", prompt=order_amount_prompt,
try: module_path = f"hummingbot.connector.{connector_type}.{connector}.{connector}_utils" all_keys.update(getattr(importlib.import_module(module_path), "KEYS")) except Exception: continue return all_keys # Main global config store key_config_map = connector_keys() main_config_map = { # The variables below are usually not prompted during setup process "client_id": ConfigVar(key="client_id", prompt=None, required_if=lambda: False, default=generate_client_id()), "log_level": ConfigVar(key="log_level", prompt=None, required_if=lambda: False, default="INFO"), "debug_console": ConfigVar(key="debug_console", prompt=None, type_str="bool", required_if=lambda: False, default=False), "strategy_report_interval": ConfigVar(key="strategy_report_interval", prompt=None,
base_asset, quote_asset = trading_pair.split("-") return f"What is the amount of {base_asset} per order? >>> " def on_validated_price_source_exchange(value: str): if value is None: avellaneda_market_making_config_map["price_source_market"].value = None def exchange_on_validated(value: str): required_exchanges.append(value) avellaneda_market_making_config_map = { "strategy": ConfigVar(key="strategy", prompt=None, default="avellaneda_market_making"), "exchange": ConfigVar(key="exchange", prompt="Enter your maker spot connector >>> ", validator=validate_exchange, on_validated=exchange_on_validated, prompt_on_new=True), "market": ConfigVar(key="market", prompt=maker_trading_pair_prompt, validator=validate_exchange_trading_pair, prompt_on_new=True), "execution_timeframe": ConfigVar( key="execution_timeframe", prompt=
for entry in data: order_row = OrderBookRow(float(entry["price"]), float(entry["quantity"]), update_id) if entry["side"] == "buy": bids.append(order_row) elif entry["side"] == "sell": asks.append(order_row) return bids, asks KEYS = { "probit_api_key": ConfigVar(key="probit_api_key", prompt="Enter your ProBit Client ID >>> ", required_if=using_exchange("probit"), is_secure=True, is_connect_key=True), "probit_secret_key": ConfigVar(key="probit_secret_key", prompt="Enter your ProBit secret key >>> ", required_if=using_exchange("probit"), is_secure=True, is_connect_key=True), } OTHER_DOMAINS = ["probit_kr"] OTHER_DOMAINS_PARAMETER = {"probit_kr": "kr"} OTHER_DOMAINS_EXAMPLE_PAIR = {"probit_kr": "BTC-USDT"} OTHER_DOMAINS_DEFAULT_FEES = {"probit_kr": [0.2, 0.2]} OTHER_DOMAINS_KEYS = {
if not advanced_mode and cvar.value is None and cvar.default is not None: cvar.value = cvar.default elif cvar == pure_market_making_config_map["advanced_mode"]: found_advanced_section = True # strategy specific validators def is_valid_maker_market_trading_pair(value: str) -> bool: maker_market = pure_market_making_config_map.get("maker_market").value return is_valid_market_trading_pair(maker_market, value) pure_market_making_config_map = { "maker_market": ConfigVar(key="maker_market", prompt="Enter your maker exchange name >>> ", validator=is_exchange, on_validated=lambda value: required_exchanges.append(value)), "maker_market_trading_pair": ConfigVar(key="primary_market_trading_pair", prompt=maker_trading_pair_prompt, validator=is_valid_maker_market_trading_pair), "bid_place_threshold": ConfigVar( key="bid_place_threshold", prompt="How far away from the mid price do you want to place the " "first bid order? (Enter 0.01 to indicate 1%) >>> ", type_str="decimal", validator=is_valid_percent), "ask_place_threshold": ConfigVar( key="ask_place_threshold",
def validate_price_source_market(value: str) -> Optional[str]: market = pure_market_making_config_map.get("price_source_exchange").value return validate_market_trading_pair(market, value) def exchange_on_validated(value: str): required_exchanges.append(value) ExchangePriceManager.set_exchanges_to_feed([value]) ExchangePriceManager.start() pure_market_making_config_map = { "strategy": ConfigVar(key="strategy", prompt=None, default="pure_market_making"), "exchange": ConfigVar(key="exchange", prompt="Enter your maker exchange name >>> ", validator=validate_exchange, on_validated=exchange_on_validated, prompt_on_new=True), "market": ConfigVar(key="market", prompt=maker_trading_pair_prompt, validator=validate_exchange_trading_pair, prompt_on_new=True), "bid_spread": ConfigVar( key="bid_spread", prompt="How far away from the mid price do you want to place the "
def convert_from_exchange_trading_pair( exchange_trading_pair: str) -> Optional[str]: if split_trading_pair(exchange_trading_pair) is None: return None # Altmarkets uses lowercase (btcusdt) base_asset, quote_asset = split_trading_pair(exchange_trading_pair) return f"{base_asset.upper()}-{quote_asset.upper()}" def convert_to_exchange_trading_pair(am_trading_pair: str) -> str: # Altmarkets uses lowercase (btcusdt) return am_trading_pair.replace("-", "").lower() KEYS = { "altmarkets_api_key": ConfigVar(key="altmarkets_api_key", prompt="Enter your Altmarkets API key >>> ", required_if=using_exchange("altmarkets"), is_secure=True, is_connect_key=True), "altmarkets_secret_key": ConfigVar(key="altmarkets_secret_key", prompt="Enter your Altmarkets secret key >>> ", required_if=using_exchange("altmarkets"), is_secure=True, is_connect_key=True), }
exchange_trading_pair: str) -> Optional[str]: if split_trading_pair(exchange_trading_pair) is None: return None base_asset, quote_asset = split_trading_pair(exchange_trading_pair) return f"{base_asset}-{quote_asset}" def convert_to_exchange_trading_pair(hb_trading_pair: str) -> str: return hb_trading_pair.replace("-", "") KEYS = { "binance_perpetual_api_key": ConfigVar(key="binance_perpetual_api_key", prompt="Enter your Binance Perpetual API key >>> ", required_if=using_exchange("binance_perpetual"), is_secure=True, is_connect_key=True), "binance_perpetual_api_secret": ConfigVar(key="binance_perpetual_api_secret", prompt="Enter your Binance Perpetual API secret >>> ", required_if=using_exchange("binance_perpetual"), is_secure=True, is_connect_key=True), } OTHER_DOMAINS = ["binance_perpetual_testnet"] OTHER_DOMAINS_PARAMETER = { "binance_perpetual_testnet": "binance_perpetual_testnet" } OTHER_DOMAINS_EXAMPLE_PAIR = {"binance_perpetual_testnet": "BTC-USDT"}
# checks if the symbol pair is valid def is_valid_market_trading_pair_tuple(value: str) -> bool: market = dev_5_vwap_config_map.get("market").value return is_valid_market_trading_pair(market, value) def order_percent_of_volume_prompt(): percent_slippage = dev_5_vwap_config_map.get("percent_slippage").value return ("What percent of open order volume up to %s percent slippage do you want" % percent_slippage + "each order to be? (default is 100 percent)? >>> ") dev_5_vwap_config_map = { "market": ConfigVar(key="market", prompt="Enter the name of the exchange >>> ", validator=is_exchange, on_validated=lambda value: required_exchanges.append(value)), "market_trading_pair_tuple": ConfigVar(key="market_trading_pair_tuple", prompt=symbol_prompt, validator=is_valid_market_trading_pair_tuple), "order_type": ConfigVar(key="order_type", prompt="Enter type of order (limit/market) default is market >>> ", type_str="str", validator=lambda v: v in {"limit", "market", ""}, default="market"), "order_amount": ConfigVar(key="order_amount", prompt="What is your preferred quantity (denominated in the base asset, default is 1)? " ">>> ",
def get_next_funding_timestamp(current_timestamp: float) -> float: # On ByBit Perpetuals, funding occurs every 8 hours at 00:00UTC, 08:00UTC and 16:00UTC. # Reference: https://help.bybit.com/hc/en-us/articles/360039261134-Funding-fee-calculation int_ts = int(current_timestamp) eight_hours = 8 * 60 * 60 mod = int_ts % eight_hours return float(int_ts - mod + eight_hours) KEYS = { "bybit_perpetual_api_key": ConfigVar(key="bybit_perpetual_api_key", prompt="Enter your Bybit Perpetual API key >>> ", required_if=using_exchange("bybit_perpetual"), is_secure=True, is_connect_key=True), "bybit_perpetual_secret_key": ConfigVar(key="bybit_perpetual_secret_key", prompt="Enter your Bybit Perpetual secret key >>> ", required_if=using_exchange("bybit_perpetual"), is_secure=True, is_connect_key=True), } OTHER_DOMAINS = ["bybit_perpetual_testnet"] OTHER_DOMAINS_PARAMETER = { "bybit_perpetual_testnet": "bybit_perpetual_testnet" } OTHER_DOMAINS_EXAMPLE_PAIR = {"bybit_perpetual_testnet": "BTC-USDT"}
def market_on_validated(value: str) -> None: required_exchanges.append(value) requried_connector_trading_pairs["uniswap_v3"] = [value] def market_prompt() -> str: connector = "uniswap_v3" example = EXAMPLE_PAIRS.get(connector) return "Enter the pair you would like to provide liquidity to {}>>> ".format( f" (e.g. {example}) " if example else "") uniswap_v3_lp_config_map = { "strategy": ConfigVar( key="strategy", prompt="", default="uniswap_v3_lp"), "market": ConfigVar( key="market", prompt=market_prompt, prompt_on_new=True, validator=market_validator, on_validated=market_on_validated), "fee_tier": ConfigVar( key="fee_tier", prompt="On which fee tier do you want to provide liquidity on? (LOW/MEDIUM/HIGH) ", validator=lambda s: None if s in {"LOW", "MEDIUM", "HIGH", } else "Invalid fee tier.",
def validate_price_floor_ceiling(value: str) -> Optional[str]: try: decimal_value = Decimal(value) except Exception: return f"{value} is not in decimal format." 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 derivative_on_validated(value: str): required_exchanges.append(value) perpetual_market_making_config_map = { "strategy": ConfigVar(key="strategy", prompt=None, default="perpetual_market_making"), "derivative": ConfigVar(key="derivative", prompt="Enter your maker derivative connector >>> ", validator=validate_derivative, on_validated=derivative_on_validated, prompt_on_new=True), "market": ConfigVar(key="market", prompt=maker_trading_pair_prompt, validator=validate_derivative_trading_pair, prompt_on_new=True), "leverage": ConfigVar( key="leverage", prompt="How much leverage do you want to use? "
markets = list(liquidity_mining_config_map["markets"].value.split(",")) tokens = set() for market in markets: tokens.update(set(market.split("-"))) if value not in tokens: return f"Invalid token. {value} is not one of {','.join(tokens)}" def order_size_prompt() -> str: token = liquidity_mining_config_map["token"].value return f"What is the size of each order (in {token} amount)? >>> " liquidity_mining_config_map = { "strategy": ConfigVar( key="strategy", prompt="", default="liquidity_mining"), "exchange": ConfigVar(key="exchange", prompt="Enter the spot connector to use for liquidity mining >>> ", validator=validate_exchange, on_validated=exchange_on_validated, prompt_on_new=True), "markets": ConfigVar(key="markets", prompt="Enter a list of markets (comma separated, e.g. LTC-USDT,ETH-USDT) >>> ", type_str="str", prompt_on_new=True), "token": ConfigVar(key="token", prompt="What asset (base or quote) do you want to use to provide liquidity? >>> ",
def get_new_client_order_id(trade_type: TradeType, trading_pair: str) -> str: side = "" if trade_type is TradeType.BUY: side = "buy" if trade_type is TradeType.SELL: side = "sell" tracking_nonce = get_tracking_nonce() return f"{BROKER_ID}-{side}-{trading_pair}-{tracking_nonce}" def build_api_factory() -> WebAssistantsFactory: api_factory = WebAssistantsFactory( ws_post_processors=[HuobiWSPostProcessor()]) return api_factory KEYS = { "huobi_api_key": ConfigVar(key="huobi_api_key", prompt="Enter your Huobi API key >>> ", required_if=using_exchange("huobi"), is_secure=True, is_connect_key=True), "huobi_secret_key": ConfigVar(key="huobi_secret_key", prompt="Enter your Huobi secret key >>> ", required_if=using_exchange("huobi"), is_secure=True, is_connect_key=True), }
avellaneda_market_making_config_map.get( "order_book_depth_factor").value = None avellaneda_market_making_config_map.get( "order_amount_shape_factor").value = None else: avellaneda_market_making_config_map.get("max_spread").value = None avellaneda_market_making_config_map.get("min_spread").value = None avellaneda_market_making_config_map.get( "vol_to_spread_multiplier").value = None avellaneda_market_making_config_map.get( "inventory_risk_aversion").value = None avellaneda_market_making_config_map = { "strategy": ConfigVar(key="strategy", prompt=None, default="avellaneda_market_making"), "exchange": ConfigVar(key="exchange", prompt="Enter your maker spot connector >>> ", validator=validate_exchange, on_validated=exchange_on_validated, prompt_on_new=True), "market": ConfigVar(key="market", prompt=maker_trading_pair_prompt, validator=validate_exchange_trading_pair, prompt_on_new=True), "order_amount": ConfigVar(key="order_amount", prompt=order_amount_prompt, type_str="decimal",