def test_check_exchange(default_conf, caplog) -> None:
    configuration = Configuration(Namespace())

    # Test a valid exchange
    default_conf.get('exchange').update({'name': 'BITTREX'})
    assert configuration.check_exchange(default_conf)

    # Test a valid exchange
    default_conf.get('exchange').update({'name': 'binance'})
    assert configuration.check_exchange(default_conf)

    # Test a invalid exchange
    default_conf.get('exchange').update({'name': 'unknown_exchange'})
    configuration.config = default_conf

    with pytest.raises(OperationalException,
                       match=r'.*Exchange "unknown_exchange" not supported.*'):
        configuration.check_exchange(default_conf)
def test_check_exchange(default_conf, caplog) -> None:
    configuration = Configuration(Namespace())

    # Test a valid exchange
    default_conf.get('exchange').update({'name': 'BITTREX'})
    assert configuration.check_exchange(default_conf)

    # Test a valid exchange
    default_conf.get('exchange').update({'name': 'binance'})
    assert configuration.check_exchange(default_conf)

    # Test a invalid exchange
    default_conf.get('exchange').update({'name': 'unknown_exchange'})
    configuration.config = default_conf

    with pytest.raises(OperationalException,
                       match=r'.*Exchange "unknown_exchange" not supported.*'):
        configuration.check_exchange(default_conf)

    # Test ccxt_rate_limit depreciation
    default_conf.get('exchange').update({'name': 'binance'})
    default_conf['exchange']['ccxt_rate_limit'] = True
    configuration.check_exchange(default_conf)
    assert log_has(
        "`ccxt_rate_limit` has been deprecated in favor of "
        "`ccxt_config` and `ccxt_async_config` and will be removed "
        "in a future version.", caplog.record_tuples)
def test_check_exchange(default_conf) -> None:
    """
    Test the configuration validator with a missing attribute
    """
    conf = deepcopy(default_conf)
    configuration = Configuration(Namespace())

    # Test a valid exchange
    conf.get('exchange').update({'name': 'BITTREX'})
    assert configuration.check_exchange(conf)

    # Test a valid exchange
    conf.get('exchange').update({'name': 'binance'})
    assert configuration.check_exchange(conf)

    # Test a invalid exchange
    conf.get('exchange').update({'name': 'unknown_exchange'})
    configuration.config = conf

    with pytest.raises(OperationalException,
                       match=r'.*Exchange "unknown_exchange" not supported.*'):
        configuration.check_exchange(conf)
Example #4
0
def test_check_exchange(default_conf, caplog) -> None:
    configuration = Configuration(Namespace())

    # Test an officially supported by Freqtrade team exchange
    default_conf.get('exchange').update({'name': 'BITTREX'})
    assert configuration.check_exchange(default_conf)
    assert log_has_re(
        r"Exchange .* is officially supported by the Freqtrade development team\.",
        caplog.record_tuples)
    caplog.clear()

    # Test an officially supported by Freqtrade team exchange
    default_conf.get('exchange').update({'name': 'binance'})
    assert configuration.check_exchange(default_conf)
    assert log_has_re(
        r"Exchange .* is officially supported by the Freqtrade development team\.",
        caplog.record_tuples)
    caplog.clear()

    # Test an available exchange, supported by ccxt
    default_conf.get('exchange').update({'name': 'kraken'})
    assert configuration.check_exchange(default_conf)
    assert log_has_re(
        r"Exchange .* is supported by ccxt and .* not officially supported "
        r"by the Freqtrade development team\. .*", caplog.record_tuples)
    caplog.clear()

    # Test a 'bad' exchange, which known to have serious problems
    default_conf.get('exchange').update({'name': 'bitmex'})
    assert not configuration.check_exchange(default_conf)
    assert log_has_re(
        r"Exchange .* is known to not work with the bot yet\. "
        r"Use it only for development and testing purposes\.",
        caplog.record_tuples)
    caplog.clear()

    # Test a 'bad' exchange with check_for_bad=False
    default_conf.get('exchange').update({'name': 'bitmex'})
    assert configuration.check_exchange(default_conf, False)
    assert log_has_re(
        r"Exchange .* is supported by ccxt and .* not officially supported "
        r"by the Freqtrade development team\. .*", caplog.record_tuples)
    caplog.clear()

    # Test an invalid exchange
    default_conf.get('exchange').update({'name': 'unknown_exchange'})
    configuration.config = default_conf

    with pytest.raises(
            OperationalException,
            match=r'.*Exchange "unknown_exchange" is not supported by ccxt '
            r'and therefore not available for the bot.*'):
        configuration.check_exchange(default_conf)
            'ccxt_async_config': {
                'enableRateLimit': True,
                'rateLimit': 200
            }
        }
    }
    timeframes = args.timeframes or ['1m', '5m']

configuration._load_logging_config(config)

if args.config and args.exchange:
    logger.warning("The --exchange option is ignored, "
                   "using exchange settings from the configuration file.")

# Check if the exchange set by the user is supported
configuration.check_exchange(config)

configuration._load_datadir_config(config)

dl_path = Path(config['datadir'])

pairs_file = Path(
    args.pairs_file) if args.pairs_file else dl_path.joinpath('pairs.json')

if not pairs or args.pairs_file:
    logger.info(f'Reading pairs file "{pairs_file}".')
    # Download pairs from the pairs file if no config is specified
    # or if pairs file is specified explicitely
    if not pairs_file.exists():
        sys.exit(f'No pairs file found with path "{pairs_file}".')