Reimplement adjustment of ccxt 'has' with more generic ccxt_config class attribute

This commit is contained in:
hroff-1902 2019-11-13 20:22:23 +03:00
parent e26bbc7de8
commit 6174a5dd55
2 changed files with 14 additions and 10 deletions

View File

@ -17,5 +17,6 @@ class Bibox(Exchange):
may still not work as expected.
"""
# Adjust ccxt exchange API metadata info
_ccxt_has: Dict = {"fetchCurrencies": False}
# fetchCurrencies API point requires authentication for Bibox,
# so switch it off for Freqtrade load_markets()
_ccxt_config: Dict = {"has": {"fetchCurrencies": False}}

View File

@ -30,8 +30,8 @@ class Exchange:
_config: Dict = {}
# Adjustments to ccxt exchange API metadata info (ccxt exchange `has` options)
_ccxt_has: Dict = {}
# Parameters to add directly to ccxt sync/async initialization.
_ccxt_config: Dict = {}
# Parameters to add directly to buy/sell calls (like agreeing to trading agreement)
_params: Dict = {}
@ -94,10 +94,17 @@ class Exchange:
self._trades_pagination_arg = self._ft_has['trades_pagination_arg']
# Initialize ccxt objects
ccxt_config = self._ccxt_config.copy()
ccxt_config = deep_merge_dicts(exchange_config.get('ccxt_config', {}),
ccxt_config)
self._api = self._init_ccxt(
exchange_config, ccxt_kwargs=exchange_config.get('ccxt_config'))
exchange_config, ccxt_kwargs=ccxt_config)
ccxt_async_config = self._ccxt_config.copy()
ccxt_async_config = deep_merge_dicts(exchange_config.get('ccxt_async_config', {}),
ccxt_async_config)
self._api_async = self._init_ccxt(
exchange_config, ccxt_async, ccxt_kwargs=exchange_config.get('ccxt_async_config'))
exchange_config, ccxt_async, ccxt_kwargs=ccxt_async_config)
logger.info('Using Exchange "%s"', self.name)
@ -155,10 +162,6 @@ class Exchange:
except ccxt.BaseError as e:
raise OperationalException(f"Initialization of ccxt failed. Reason: {e}") from e
# Adjust ccxt API metadata info (`has` options) for the exchange
for k, v in self._ccxt_has.items():
api.has[k] = v
self.set_sandbox(api, exchange_config, name)
return api