def test_is_currency_enabled(config):
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES]["Bitcoin"][commons_constants.CONFIG_ENABLED_OPTION] = True
    assert util.is_currency_enabled(config, "Bitcoin", True) is True
    assert util.is_currency_enabled(config, "Bitcoin", False) is True
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES]["Bitcoin"][commons_constants.CONFIG_ENABLED_OPTION] = False
    assert util.is_currency_enabled(config, "Bitcoin", True) is False
    config[commons_constants.CONFIG_CRYPTO_CURRENCIES]["Bitcoin"].pop(commons_constants.CONFIG_ENABLED_OPTION, None)
    assert util.is_currency_enabled(config, "Bitcoin", True) is True
    assert util.is_currency_enabled(config, "Bitcoin", False) is False
 def _set_config_traded_pair(self, cryptocurrency, traded_symbol_pairs_set, existing_pairs):
     try:
         if self.config[constants.CONFIG_CRYPTO_CURRENCIES][cryptocurrency][constants.CONFIG_CRYPTO_PAIRS]:
             is_enabled = util.is_currency_enabled(self.config, cryptocurrency, True)
             if self.config[constants.CONFIG_CRYPTO_CURRENCIES][cryptocurrency][constants.CONFIG_CRYPTO_PAIRS] != \
                     constants.CONFIG_SYMBOLS_WILDCARD:
                 self._populate_non_wildcard_pairs(cryptocurrency, existing_pairs, is_enabled)
             else:
                 self._populate_wildcard_pairs(cryptocurrency, existing_pairs, is_enabled)
             # add to global traded pairs
             if is_enabled:
                 if not self.traded_cryptocurrencies[cryptocurrency]:
                     self._logger.error(
                         f"{self.exchange_manager.exchange_name} is not supporting any {cryptocurrency} trading pair"
                         f" from the current configuration.")
                 traded_symbol_pairs_set = traded_symbol_pairs_set.union(
                     self.traded_cryptocurrencies[cryptocurrency]
                 )
         else:
             self._logger.error(f"Current configuration for {cryptocurrency} is not including any trading pair, "
                                f"this asset can't be traded and related orders won't be loaded. "
                                f"OctoBot requires at least one trading pair in configuration to handle an asset. "
                                f"You can add trading pair(s) for each asset in the configuration section.")
     except errors.ConfigError as err:
         self._logger.error(str(err))
     return traded_symbol_pairs_set
示例#3
0
 def get_profile_traded_pairs_by_currency(profile):
     return {
         currency: val[commons_constants.CONFIG_CRYPTO_PAIRS]
         for currency, val in profile.config[commons_constants.CONFIG_CRYPTO_CURRENCIES].items()
         if commons_constants.CONFIG_CRYPTO_PAIRS in val
             and val[commons_constants.CONFIG_CRYPTO_PAIRS]
             and trading_util.is_currency_enabled(profile.config, currency, True)
     }