async def main(): await create_yml_files() # This init_logging() call is important, to skip over the missing config warnings. init_logging("hummingbot_logs.yml") read_system_configs_from_yml() hb = HummingbotApplication.main_application() with patch_stdout(log_field=hb.app.log_field): dev_mode = check_dev_mode() if dev_mode: hb.app.log("Running from dev branches. Full remote logging will be enabled.") init_logging("hummingbot_logs.yml", override_log_level=global_config_map.get("log_level").value, dev_mode=dev_mode) tasks: List[Coroutine] = [hb.run()] if global_config_map.get("debug_console").value: if not hasattr(__builtins__, "help"): import _sitebuiltins __builtins__.help = _sitebuiltins._Helper() from hummingbot.core.management.console import start_management_console management_port: int = detect_available_port(8211) tasks.append(start_management_console(locals(), host="localhost", port=management_port)) await safe_gather(*tasks)
def application_warning(self): # Application warnings. self._expire_old_application_warnings() if check_dev_mode() and len(self._app_warnings) > 0: app_warning = self._format_application_warnings() self._notify(app_warning) return app_warning
async def quick_start(args): config_file_name = args.config_file_name wallet = args.wallet password = args.config_password if args.auto_set_permissions is not None: autofix_permissions(args.auto_set_permissions) if password is not None and not Security.login(password): logging.getLogger().error("Invalid password.") return await Security.wait_til_decryption_done() await create_yml_files() init_logging("hummingbot_logs.yml") read_system_configs_from_yml() hb = HummingbotApplication.main_application() # Todo: validate strategy and config_file_name before assinging if config_file_name is not None: hb.strategy_file_name = config_file_name hb.strategy_name = update_strategy_config_map_from_file( os.path.join(CONF_FILE_PATH, config_file_name)) # To ensure quickstart runs with the default value of False for kill_switch_enabled if not present if not global_config_map.get("kill_switch_enabled"): global_config_map.get("kill_switch_enabled").value = False if wallet and password: global_config_map.get("ethereum_wallet").value = wallet if hb.strategy_name and hb.strategy_file_name: if not all_configs_complete(hb.strategy_name): hb.status() with patch_stdout(log_field=hb.app.log_field): dev_mode = check_dev_mode() if dev_mode: hb.app.log( "Running from dev branches. Full remote logging will be enabled." ) log_level = global_config_map.get("log_level").value init_logging("hummingbot_logs.yml", override_log_level=log_level, dev_mode=dev_mode) if hb.strategy_file_name is not None and hb.strategy_name is not None: await write_config_to_yml(hb.strategy_name, hb.strategy_file_name) hb.start(log_level) tasks: List[Coroutine] = [hb.run()] if global_config_map.get("debug_console").value: management_port: int = detect_available_port(8211) tasks.append( start_management_console(locals(), host="localhost", port=management_port)) await safe_gather(*tasks)
async def main(): chdir_to_data_directory() await create_yml_files() # This init_logging() call is important, to skip over the missing config warnings. init_logging("hummingbot_logs.yml") hb = HummingbotApplication.main_application() setHummingInstance(hb) read_configs_from_yml() ExchangeRateConversion.get_instance().start() with patch_stdout(log_field=hb.app.log_field): dev_mode = check_dev_mode() if dev_mode: hb.app.log( "Running from dev branches. Full remote logging will be enabled." ) init_logging( "hummingbot_logs.yml", override_log_level=global_config_map.get("log_level").value, dev_mode=dev_mode) tasks: List[Coroutine] = [hb.run(), sio.connect('ws://localhost:5000')] await safe_gather(*tasks)
async def main(): await create_yml_files() # This init_logging() call is important, to skip over the missing config warnings. init_logging("hummingbot_logs.yml") read_configs_from_yml() if __name__ == '__main__': hb = HummingbotApplication.main_application() with patch_stdout(log_field=hb.app.log_field): dev_mode = check_dev_mode() if dev_mode: hb.app.log( "Running from dev branches. Full remote logging will be enabled." ) init_logging( "hummingbot_logs.yml", override_log_level=global_config_map.get("log_level").value, dev_mode=dev_mode) tasks: List[Coroutine] = [hb.run()] if global_config_map.get("debug_console").value: management_port: int = detect_available_port(8211) tasks.append( start_management_console(locals(), host="localhost", port=management_port)) await asyncio.gather(*tasks)
async def quick_start(): try: args = CmdlineParser().parse_args() strategy = args.strategy config_file_name = args.config_file_name wallet = args.wallet password = args.config_password await create_yml_files() init_logging("hummingbot_logs.yml") read_configs_from_yml() ExchangeRateConversion.get_instance().start() await ExchangeRateConversion.get_instance().wait_till_ready() hb = HummingbotApplication.main_application() in_memory_config_map.get("password").value = password in_memory_config_map.get("strategy").value = strategy in_memory_config_map.get("strategy").validate(strategy) in_memory_config_map.get("strategy_file_path").value = config_file_name in_memory_config_map.get("strategy_file_path").validate(config_file_name) # To ensure quickstart runs with the default value of False for kill_switch_enabled if not present if not global_config_map.get("kill_switch_enabled"): global_config_map.get("kill_switch_enabled").value = False if wallet and password: global_config_map.get("wallet").value = wallet hb.acct = unlock_wallet(public_key=wallet, password=password) if not hb.config_complete: config_map = load_required_configs() empty_configs = [key for key, config in config_map.items() if config.value is None and config.required] empty_config_description: str = "\n- ".join([""] + empty_configs) raise ValueError(f"Missing empty configs: {empty_config_description}\n") with patch_stdout(log_field=hb.app.log_field): dev_mode = check_dev_mode() if dev_mode: hb.app.log("Running from dev branches. Full remote logging will be enabled.") log_level = global_config_map.get("log_level").value init_logging("hummingbot_logs.yml", override_log_level=log_level, dev_mode=dev_mode, strategy_file_path=config_file_name) await write_config_to_yml() hb.start(log_level) tasks: List[Coroutine] = [hb.run()] if global_config_map.get("debug_console").value: management_port: int = detect_available_port(8211) tasks.append(start_management_console(locals(), host="localhost", port=management_port)) await safe_gather(*tasks) except Exception as e: # In case of quick start failure, start the bot normally to allow further configuration logging.getLogger().warning(f"Bot config incomplete: {str(e)}. Starting normally...") await normal_start()
async def quick_start(): try: args = CmdlineParser().parse_args() strategy = args.strategy config_file_name = args.config_file_name wallet = args.wallet wallet_password = args.wallet_password await create_yml_files() init_logging("hummingbot_logs.yml") read_configs_from_yml() hb = HummingbotApplication.main_application() in_memory_config_map.get("strategy").value = strategy in_memory_config_map.get("strategy").validate(strategy) in_memory_config_map.get("strategy_file_path").value = config_file_name in_memory_config_map.get("strategy_file_path").validate( config_file_name) if wallet and wallet_password: global_config_map.get("wallet").value = wallet hb.acct = unlock_wallet(public_key=wallet, password=wallet_password) if not hb.config_complete: empty_configs = hb._get_empty_configs() empty_config_description: str = "\n- ".join([""] + empty_configs) raise ValueError( f"Missing empty configs: {empty_config_description}\n") with patch_stdout(log_field=hb.app.log_field): dev_mode = check_dev_mode() if dev_mode: hb.app.log( "Running from dev branches. Full remote logging will be enabled." ) log_level = global_config_map.get("log_level").value init_logging("hummingbot_logs.yml", override_log_level=log_level, dev_mode=dev_mode) hb.start(log_level) tasks: List[Coroutine] = [hb.run()] if global_config_map.get("debug_console").value: management_port: int = detect_available_port(8211) tasks.append( start_management_console(locals(), host="localhost", port=management_port)) await asyncio.gather(*tasks) except Exception as e: # In case of quick start failure, start the bot normally to allow further configuration logging.getLogger().warning( f"Bot config incomplete: {str(e)}. Starting normally...") await normal_start()
def status( self, # type: HummingbotApplication ) -> bool: # Preliminary checks. self._notify("\n Preliminary checks:") if self.config_complete: self._notify(" - Config check: Config complete") else: self._notify( ' x Config check: Pending config. Please enter "config" before starting the bot.' ) return False if self.wallet is not None: # Only check node url when a wallet has been initialized eth_node_valid = check_web3( global_config_map.get("ethereum_rpc_url").value) if eth_node_valid: self._notify( " - Node check: Ethereum node running and current") else: self._notify( ' x Node check: Bad ethereum rpc url. Your node may be syncing. ' 'Please re-configure by entering "config ethereum_rpc_url"' ) return False if self.wallet.network_status is NetworkStatus.CONNECTED: if self._trading_required: has_minimum_eth = self.wallet.get_balance("ETH") > 0.01 if has_minimum_eth: self._notify( " - ETH wallet check: Minimum ETH requirement satisfied" ) else: for market_name, market_instance in self.markets.items( ): # Don't display warning for IDEX since no transactions are initiated from the wallet if hasattr(market_instance, "wallet") \ and market_instance.wallet is self.wallet \ and market_instance.display_name == "idex": continue else: self._notify( " x ETH wallet check: Not enough ETH in wallet. " "A small amount of Ether is required for sending transactions on " "Decentralized Exchanges") break else: self._notify( " x ETH wallet check: ETH wallet is not connected.") loading_markets: List[MarketBase] = [] for market in self.markets.values(): if not market.ready: loading_markets.append(market) if len(loading_markets) > 0: self._notify( f" x Market check: Waiting for markets " + ",".join([m.name.capitalize() for m in loading_markets]) + f" to get ready for trading. \n" f" Please keep the bot running and try to start again in a few minutes. \n" ) for market in loading_markets: market_status_df = pd.DataFrame( data=market.status_dict.items(), columns=["description", "status"]) self._notify( f" x {market.display_name.capitalize()} market status:\n" + "\n".join([ " " + line for line in market_status_df.to_string( index=False, ).split("\n") ]) + "\n") return False elif not all([ market.network_status is NetworkStatus.CONNECTED for market in self.markets.values() ]): offline_markets: List[str] = [ market_name for market_name, market in self.markets.items() if market.network_status is not NetworkStatus.CONNECTED ] for offline_market in offline_markets: self._notify( f" x Market check: {offline_market} is currently offline." ) # See if we can print out the strategy status. self._notify(" - Market check: All markets ready") if self.strategy is None: self._notify(" x initializing strategy.") else: self._notify(self.strategy.format_status() + "\n") # Application warnings. self._expire_old_application_warnings() if check_dev_mode() and len(self._app_warnings) > 0: self._notify(self._format_application_warnings()) return True