Example #1
0
def test_start_failure(mocker, default_conf, caplog) -> None:
    start_mock = MagicMock()
    mocker.patch('freqtrade.configuration.Configuration._load_config_file',
                 lambda *args, **kwargs: default_conf)
    mocker.patch('freqtrade.optimize.hyperopt.Hyperopt.start', start_mock)
    patch_exchange(mocker)

    args = [
        '--config', 'config.json', '--strategy', 'TestStrategy', 'hyperopt',
        '--epochs', '5'
    ]
    args = get_args(args)
    StrategyResolver({'strategy': 'DefaultStrategy'})
    with pytest.raises(ValueError):
        start(args)
    assert log_has("Please don't use --strategy for hyperopt.",
                   caplog.record_tuples)
Example #2
0
def test_start(mocker, default_conf, caplog) -> None:
    start_mock = MagicMock()
    mocker.patch('freqtrade.configuration.Configuration._load_config_file',
                 lambda *args, **kwargs: default_conf)
    mocker.patch('freqtrade.optimize.hyperopt.Hyperopt.start', start_mock)
    patch_exchange(mocker)

    args = [
        '--config', 'config.json', '--strategy', 'DefaultStrategy', 'hyperopt',
        '--epochs', '5'
    ]
    args = get_args(args)
    StrategyResolver({'strategy': 'DefaultStrategy'})
    start(args)

    import pprint
    pprint.pprint(caplog.record_tuples)

    assert log_has('Starting freqtrade in Hyperopt mode', caplog.record_tuples)
    assert start_mock.call_count == 1
Example #3
0
def test_start(mocker, default_conf, caplog) -> None:
    """
    Test start() function
    """
    start_mock = MagicMock()
    mocker.patch('freqtrade.optimize.hyperopt.Hyperopt.start', start_mock)
    mocker.patch('freqtrade.configuration.open',
                 mocker.mock_open(read_data=json.dumps(default_conf)))
    args = [
        '--config', 'config.json', '--strategy', 'DefaultStrategy', 'hyperopt',
        '--epochs', '5'
    ]
    args = get_args(args)
    StrategyResolver({'strategy': 'DefaultStrategy'})
    start(args)

    import pprint
    pprint.pprint(caplog.record_tuples)

    assert log_has('Starting freqtrade in Hyperopt mode', caplog.record_tuples)
    assert start_mock.call_count == 1