Exemplo n.º 1
0
 def _get_bot_metrics(self):
     return {
         MetricsFields.ID.value: self.bot_id,
         MetricsFields.CURRENT_SESSION.value: {
             MetricsFields.STARTED_AT.value:
             int(self.octobot.start_time),
             MetricsFields.UP_TIME.value:
             int(time.time() - self.octobot.start_time),
             MetricsFields.SIMULATOR.value:
             ConfigManager.get_trader_simulator_enabled(self.edited_config),
             MetricsFields.TRADER.value:
             ConfigManager.get_trader_enabled(self.edited_config),
             MetricsFields.EVAL_CONFIG.value:
             self._get_eval_config(),
             MetricsFields.PAIRS.value:
             self._get_traded_pairs(),
             MetricsFields.EXCHANGES.value:
             list(self.octobot.get_exchanges_list().keys()),
             MetricsFields.NOTIFICATIONS.value:
             self._get_notification_types(),
             MetricsFields.TYPE.value:
             get_octobot_type(),
             MetricsFields.PLATFORM.value:
             get_current_platform()
         }
     }
Exemplo n.º 2
0
    def _check_exchange_data(self, config, found_currencies_prices):
        for exchange_data in self._previous_state.values():
            # check currencies
            missing_traded_currencies = set()
            for currency in exchange_data[
                    WATCHED_MARKETS_INITIAL_STARTUP_VALUES].keys():
                if currency in found_currencies_prices:
                    found_currencies_prices[currency] = True
                else:
                    missing_traded_currencies.add(currency)
            if missing_traded_currencies:
                self.logger.warning(
                    f"{self.ERROR_MESSAGE}Missing trading pair(s) for "
                    f"{', '.join(missing_traded_currencies)}.")
                return False
            # check reference market
            if exchange_data[REFERENCE_MARKET] != config[CONFIG_TRADING][
                    CONFIG_TRADER_REFERENCE_MARKET]:
                self.logger.warning(
                    f"{self.ERROR_MESSAGE}Reference market changed, "
                    f"reinitializing traders.")
                return False

            # check initial portfolios and portfolios values
            if ConfigManager.get_trader_simulator_enabled(config):
                if exchange_data[SIMULATOR_INITIAL_STARTUP_PORTFOLIO] is None \
                        or exchange_data[SIMULATOR_INITIAL_STARTUP_PORTFOLIO_VALUE] is None:
                    return False
            if ConfigManager.get_trader_enabled(config):
                if exchange_data[REAL_INITIAL_STARTUP_PORTFOLIO] is None\
                        or exchange_data[REAL_INITIAL_STARTUP_PORTFOLIO_VALUE] is None:
                    return False
        return True
Exemplo n.º 3
0
 def __init__(self, octobot):
     self.octobot = octobot
     self.edited_config = octobot.edited_config
     self.enabled = ConfigManager.get_metrics_enabled(self.edited_config)
     self.bot_id = self._init_config_bot_id(self.edited_config)
     self.reference_market = ConfigManager.get_reference_market(
         self.edited_config)
     self.logger = get_logger(self.__class__.__name__)
     self.current_config = None
     self.keep_running = True
     self.session = octobot.get_aiohttp_session()
     self.has_real_trader = ConfigManager.get_trader_enabled(
         self.edited_config)
Exemplo n.º 4
0
 def enabled(config):
     return ConfigManager.get_trader_enabled(config)