Esempio n. 1
0
    async def start_check(
            self,  # type: HummingbotApplication
            log_level: Optional[str] = None,
            restore: Optional[bool] = False):
        if self.strategy_task is not None and not self.strategy_task.done():
            self._notify(
                'The bot is already running - please run "stop" first')
            return

        if settings.required_rate_oracle:
            if not (await self.confirm_oracle_conversion_rate()):
                self._notify("The strategy failed to start.")
                return
            else:
                RateOracle.get_instance().start()
        is_valid = await self.status_check_all(notify_success=False)
        if not is_valid:
            self._notify("Status checks failed. Start aborted.")
            return
        if self._last_started_strategy_file != self.strategy_file_name:
            init_logging(
                "hummingbot_logs.yml",
                override_log_level=log_level.upper() if log_level else None,
                strategy_file_path=self.strategy_file_name)
            self._last_started_strategy_file = self.strategy_file_name

        # If macOS, disable App Nap.
        if platform.system() == "Darwin":
            import appnope
            appnope.nope()

        self._initialize_notifiers()

        self._notify(
            f"\nStatus check complete. Starting '{self.strategy_name}' strategy..."
        )
        if global_config_map.get("paper_trade_enabled").value:
            self._notify(
                "\nPaper Trading ON: All orders are simulated, and no real orders are placed."
            )

        for exchange in settings.required_exchanges:
            connector = str(exchange)
            status = get_connector_status(connector)

            # Display custom warning message for specific connectors
            warning_msg = warning_messages.get(connector, None)
            if warning_msg is not None:
                self._notify(f"\nConnector status: {status}\n"
                             f"{warning_msg}")

            # Display warning message if the exchange connector has outstanding issues or not working
            elif status != "GREEN":
                self._notify(
                    f"\nConnector status: {status}. This connector has one or more issues.\n"
                    "Refer to our Github page for more info: https://github.com/coinalpha/hummingbot"
                )

        await self.start_market_making(self.strategy_name, restore)
Esempio n. 2
0
 async def connection_df(self  # type: HummingbotApplication
                         ):
     columns = [
         "Exchange", "  Keys Added", "  Keys Confirmed",
         "  Connector Status"
     ]
     data = []
     failed_msgs = {}
     network_timeout = float(
         global_config_map["other_commands_timeout"].value)
     try:
         err_msgs = await asyncio.wait_for(
             UserBalances.instance().update_exchanges(reconnect=True),
             network_timeout)
     except asyncio.TimeoutError:
         self._notify(
             "\nA network error prevented the connection table to populate. See logs for more details."
         )
         raise
     for option in sorted(OPTIONS):
         keys_added = "No"
         keys_confirmed = 'No'
         status = get_connector_status(option)
         if option == "ethereum":
             eth_address = global_config_map["ethereum_wallet"].value
             if eth_address is not None and eth_address in Security.private_keys(
             ):
                 keys_added = "Yes"
                 err_msg = UserBalances.validate_ethereum_wallet()
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         elif option == "celo":
             celo_address = global_config_map["celo_address"].value
             if celo_address is not None and Security.encrypted_file_exists(
                     "celo_password"):
                 keys_added = "Yes"
                 err_msg = await self.validate_n_connect_celo(True)
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         else:
             api_keys = (await Security.api_keys(option)).values()
             if len(api_keys) > 0:
                 keys_added = "Yes"
                 err_msg = err_msgs.get(option)
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         data.append([option, keys_added, keys_confirmed, status])
     return pd.DataFrame(data=data, columns=columns), failed_msgs
Esempio n. 3
0
 async def connection_df(self  # type: HummingbotApplication
                         ):
     columns = [
         "Exchange", "  Keys Added", "  Keys Confirmed",
         "  Connector Status"
     ]
     data = []
     failed_msgs = {}
     err_msgs = await UserBalances.instance().update_exchanges(
         reconnect=True)
     for option in sorted(OPTIONS):
         keys_added = "No"
         keys_confirmed = 'No'
         status = get_connector_status(option)
         if option == "ethereum":
             eth_address = global_config_map["ethereum_wallet"].value
             if eth_address is not None and eth_address in Security.private_keys(
             ):
                 keys_added = "Yes"
                 err_msg = UserBalances.validate_ethereum_wallet()
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         elif option == "celo":
             celo_address = global_config_map["celo_address"].value
             if celo_address is not None and Security.encrypted_file_exists(
                     "celo_password"):
                 keys_added = "Yes"
                 err_msg = await self.validate_n_connect_celo(True)
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         else:
             api_keys = (await Security.api_keys(option)).values()
             if len(api_keys) > 0:
                 keys_added = "Yes"
                 err_msg = err_msgs.get(option)
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         data.append([option, keys_added, keys_confirmed, status])
     return pd.DataFrame(data=data, columns=columns), failed_msgs
Esempio n. 4
0
    async def start_check(self,  # type: HummingbotApplication
                          log_level: Optional[str] = None,
                          restore: Optional[bool] = False,
                          strategy_file_name: Optional[str] = None):
        if self.strategy_task is not None and not self.strategy_task.done():
            self.notify('The bot is already running - please run "stop" first')
            return

        if settings.required_rate_oracle:
            # If the strategy to run requires using the rate oracle to find FX rates, validate there is a rate for
            # each configured token pair
            if not (await self.confirm_oracle_conversion_rate()):
                self.notify("The strategy failed to start.")
                return

        if strategy_file_name:
            file_name = strategy_file_name.split(".")[0]
            self.strategy_file_name = file_name
            self.strategy_name = file_name
        elif not await self.status_check_all(notify_success=False):
            self.notify("Status checks failed. Start aborted.")
            return
        if self._last_started_strategy_file != self.strategy_file_name:
            init_logging("hummingbot_logs.yml",
                         override_log_level=log_level.upper() if log_level else None,
                         strategy_file_path=self.strategy_file_name)
            self._last_started_strategy_file = self.strategy_file_name

        # If macOS, disable App Nap.
        if platform.system() == "Darwin":
            import appnope
            appnope.nope()

        self._initialize_notifiers()
        try:
            self._initialize_strategy(self.strategy_name)
        except NotImplementedError:
            self.strategy_name = None
            self.strategy_file_name = None
            self.notify("Invalid strategy. Start aborted.")
            raise

        if any([str(exchange).endswith("paper_trade") for exchange in settings.required_exchanges]):
            self.notify("\nPaper Trading Active: All orders are simulated and no real orders are placed.")

        for exchange in settings.required_exchanges:
            connector: str = str(exchange)
            status: str = get_connector_status(connector)
            warning_msg: Optional[str] = warning_messages.get(connector, None)

            # confirm gateway connection
            conn_setting: settings.ConnectorSetting = settings.AllConnectorSettings.get_connector_settings()[connector]
            if conn_setting.uses_gateway_generic_connector():
                connector_details: Dict[str, Any] = conn_setting.conn_init_parameters()
                if connector_details:
                    data: List[List[str]] = [
                        ["chain", connector_details['chain']],
                        ["network", connector_details['network']],
                        ["wallet_address", connector_details['wallet_address']]
                    ]
                    await UserBalances.instance().update_exchange_balance(connector)
                    balances: List[str] = [
                        f"{str(PerformanceMetrics.smart_round(v, 8))} {k}"
                        for k, v in UserBalances.instance().all_balances(connector).items()
                    ]
                    data.append(["balances", ""])
                    for bal in balances:
                        data.append(["", bal])
                    wallet_df: pd.DataFrame = pd.DataFrame(data=data, columns=["", f"{connector} configuration"])
                    self.notify(wallet_df.to_string(index=False))

                    self.app.clear_input()
                    self.placeholder_mode = True
                    use_configuration = await self.app.prompt(prompt="Do you want to continue? (Yes/No) >>> ")
                    self.placeholder_mode = False
                    self.app.change_prompt(prompt=">>> ")

                    if use_configuration in ["N", "n", "No", "no"]:
                        return

                    if use_configuration not in ["Y", "y", "Yes", "yes"]:
                        self.notify("Invalid input. Please execute the `start` command again.")
                        return

            # Display custom warning message for specific connectors
            elif warning_msg is not None:
                self.notify(f"\nConnector status: {status}\n"
                            f"{warning_msg}")

            # Display warning message if the exchange connector has outstanding issues or not working
            elif not status.endswith("GREEN"):
                self.notify(f"\nConnector status: {status}. This connector has one or more issues.\n"
                            "Refer to our Github page for more info: https://github.com/coinalpha/hummingbot")

        self.notify(f"\nStatus check complete. Starting '{self.strategy_name}' strategy...")
        await self.start_market_making(restore)
        # We always start the RateOracle. It is required for PNL calculation.
        RateOracle.get_instance().start()