Beispiel #1
0
def test_show_info(default_conf, mocker, caplog) -> None:
    """
    Test Configuration.show_info()
    """
    mocker.patch('freqtrade.configuration.open',
                 mocker.mock_open(read_data=json.dumps(default_conf)))

    args = [
        '--dynamic-whitelist', '10', '--strategy', 'TestStrategy',
        '--dry-run-db'
    ]
    args = Arguments(args, '').get_parsed_arg()

    configuration = Configuration(args)
    configuration.get_config()

    assert log_has(
        'Parameter --dynamic-whitelist detected. '
        'Using dynamically generated whitelist. '
        '(not applicable with Backtesting and Hyperopt)', caplog.record_tuples)

    assert log_has('Parameter --dry-run-db detected ...', caplog.record_tuples)

    assert log_has('Dry_run will use the DB file: "tradesv3.dry_run.sqlite"',
                   caplog.record_tuples)

    # Test the Dry run condition
    configuration.config.update({'dry_run': False})
    configuration._load_common_config(configuration.config)
    assert log_has('Dry run is disabled. (--dry_run_db ignored)',
                   caplog.record_tuples)
Beispiel #2
0
def start(args: Namespace) -> None:
    """
    Start Backtesting script
    :param args: Cli args from Arguments()
    :return: None
    """

    # Remove noisy log messages
    logging.getLogger('hyperopt.mongoexp').setLevel(logging.WARNING)
    logging.getLogger('hyperopt.tpe').setLevel(logging.WARNING)

    # Initialize configuration
    # Monkey patch the configuration with hyperopt_conf.py
    configuration = Configuration(args)
    logger.info('Starting freqtrade in Hyperopt mode')

    optimize_config = hyperopt_optimize_conf()
    config = configuration._load_common_config(optimize_config)
    config = configuration._load_backtesting_config(config)
    config = configuration._load_hyperopt_config(config)
    config['exchange']['key'] = ''
    config['exchange']['secret'] = ''

    # Initialize backtesting object
    hyperopt = Hyperopt(config)
    hyperopt.start()