From b562239ec8f05328f1ef8e935b5146b15d3e0d6c Mon Sep 17 00:00:00 2001 From: Samuel Husso Date: Wed, 31 Jan 2018 17:29:07 +0200 Subject: [PATCH] ccxt has pairs in BASE_CURRENCY / QUOTE_CURRENCY format, remove bittrex references --- freqtrade/exchange/__init__.py | 23 +++++++++++++---------- freqtrade/misc.py | 4 ++-- freqtrade/optimize/backtesting.py | 1 - freqtrade/optimize/hyperopt.py | 1 - 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index 5839ad701..94ce835d5 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -23,13 +23,6 @@ _CONF: dict = {} _DRY_RUN_OPEN_ORDERS: Dict[str, Any] = {} -class Exchanges(enum.Enum): - """ - Maps supported exchange names to correspondent classes. - """ - BITTREX = Bittrex - - def init(config: dict) -> None: """ Initializes this module with the given config, @@ -63,10 +56,13 @@ def init(config: dict) -> None: # we need load api markets _API.load_markets() - + # Check if all pairs are available validate_pairs(config['exchange']['pair_whitelist']) + print("*"*20) + + def validate_pairs(pairs: List[str]) -> None: """ @@ -75,15 +71,22 @@ def validate_pairs(pairs: List[str]) -> None: :param pairs: list of pairs :return: None """ + # Note: ccxt has BaseCurrency/QuoteCurrency format for pairs + if not _API.markets: + _API.load_markets() + try: - markets = _API.get_markets() + markets = _API.markets except requests.exceptions.RequestException as e: logger.warning('Unable to validate pairs (assuming they are correct). Reason: %s', e) return stake_cur = _CONF['stake_currency'] for pair in pairs: - if not pair.startswith(stake_cur): + # TODO: ccxt expects pairs in BTC/USD format + pair = pair.replace('_', '/') + + if not pair.endswith(stake_cur): raise OperationalException( 'Pair {} not compatible with stake_currency: {}'.format(pair, stake_cur) ) diff --git a/freqtrade/misc.py b/freqtrade/misc.py index cf2db1004..0cd88b06d 100644 --- a/freqtrade/misc.py +++ b/freqtrade/misc.py @@ -406,7 +406,7 @@ CONF_SCHEMA = { 'type': 'array', 'items': { 'type': 'string', - 'pattern': '^[0-9A-Z]+_[0-9A-Z]+$' + 'pattern': '^[0-9A-Z]+/[0-9A-Z]+$' }, 'uniqueItems': True }, @@ -414,7 +414,7 @@ CONF_SCHEMA = { 'type': 'array', 'items': { 'type': 'string', - 'pattern': '^[0-9A-Z]+_[0-9A-Z]+$' + 'pattern': '^[0-9A-Z]+/[0-9A-Z]+$' }, 'uniqueItems': True } diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index e8fcec875..107d13a25 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -11,7 +11,6 @@ import freqtrade.misc as misc import freqtrade.optimize as optimize from freqtrade import exchange from freqtrade.analyze import populate_buy_trend, populate_sell_trend -from freqtrade.exchange import Bittrex from freqtrade.main import should_sell from freqtrade.persistence import Trade from freqtrade.strategy.strategy import Strategy diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 76932f7e3..8eefb13c6 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -22,7 +22,6 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib # Monkey patch config from freqtrade import main # noqa; noqa from freqtrade import exchange, misc, optimize -from freqtrade.exchange import Bittrex from freqtrade.misc import load_config from freqtrade.optimize import backtesting from freqtrade.optimize.backtesting import backtest