ccxt has pairs in BASE_CURRENCY / QUOTE_CURRENCY format, remove bittrex references

This commit is contained in:
Samuel Husso 2018-01-31 17:29:07 +02:00
parent f0945c354e
commit b562239ec8
4 changed files with 15 additions and 14 deletions

View File

@ -23,13 +23,6 @@ _CONF: dict = {}
_DRY_RUN_OPEN_ORDERS: Dict[str, Any] = {} _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: def init(config: dict) -> None:
""" """
Initializes this module with the given config, Initializes this module with the given config,
@ -67,6 +60,9 @@ def init(config: dict) -> None:
# Check if all pairs are available # Check if all pairs are available
validate_pairs(config['exchange']['pair_whitelist']) validate_pairs(config['exchange']['pair_whitelist'])
print("*"*20)
def validate_pairs(pairs: List[str]) -> None: def validate_pairs(pairs: List[str]) -> None:
""" """
@ -75,15 +71,22 @@ def validate_pairs(pairs: List[str]) -> None:
:param pairs: list of pairs :param pairs: list of pairs
:return: None :return: None
""" """
# Note: ccxt has BaseCurrency/QuoteCurrency format for pairs
if not _API.markets:
_API.load_markets()
try: try:
markets = _API.get_markets() markets = _API.markets
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
logger.warning('Unable to validate pairs (assuming they are correct). Reason: %s', e) logger.warning('Unable to validate pairs (assuming they are correct). Reason: %s', e)
return return
stake_cur = _CONF['stake_currency'] stake_cur = _CONF['stake_currency']
for pair in pairs: 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( raise OperationalException(
'Pair {} not compatible with stake_currency: {}'.format(pair, stake_cur) 'Pair {} not compatible with stake_currency: {}'.format(pair, stake_cur)
) )

View File

@ -406,7 +406,7 @@ CONF_SCHEMA = {
'type': 'array', 'type': 'array',
'items': { 'items': {
'type': 'string', 'type': 'string',
'pattern': '^[0-9A-Z]+_[0-9A-Z]+$' 'pattern': '^[0-9A-Z]+/[0-9A-Z]+$'
}, },
'uniqueItems': True 'uniqueItems': True
}, },
@ -414,7 +414,7 @@ CONF_SCHEMA = {
'type': 'array', 'type': 'array',
'items': { 'items': {
'type': 'string', 'type': 'string',
'pattern': '^[0-9A-Z]+_[0-9A-Z]+$' 'pattern': '^[0-9A-Z]+/[0-9A-Z]+$'
}, },
'uniqueItems': True 'uniqueItems': True
} }

View File

@ -11,7 +11,6 @@ import freqtrade.misc as misc
import freqtrade.optimize as optimize import freqtrade.optimize as optimize
from freqtrade import exchange from freqtrade import exchange
from freqtrade.analyze import populate_buy_trend, populate_sell_trend from freqtrade.analyze import populate_buy_trend, populate_sell_trend
from freqtrade.exchange import Bittrex
from freqtrade.main import should_sell from freqtrade.main import should_sell
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.strategy.strategy import Strategy from freqtrade.strategy.strategy import Strategy

View File

@ -22,7 +22,6 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib
# Monkey patch config # Monkey patch config
from freqtrade import main # noqa; noqa from freqtrade import main # noqa; noqa
from freqtrade import exchange, misc, optimize from freqtrade import exchange, misc, optimize
from freqtrade.exchange import Bittrex
from freqtrade.misc import load_config from freqtrade.misc import load_config
from freqtrade.optimize import backtesting from freqtrade.optimize import backtesting
from freqtrade.optimize.backtesting import backtest from freqtrade.optimize.backtesting import backtest