diff --git a/freqtrade/main.py b/freqtrade/main.py index 18bc04e6f..4a88806c7 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -379,7 +379,7 @@ def main() -> None: throttle( _process, min_secs=_CONF['internals'].get('process_throttle_secs', 10), - dynamic_whitelist=args.dynamic_whitelist, + nb_assets=args.dynamic_whitelist, ) old_state = new_state except KeyboardInterrupt: diff --git a/freqtrade/tests/test_misc.py b/freqtrade/tests/test_misc.py index 962c833e4..cd529039a 100644 --- a/freqtrade/tests/test_misc.py +++ b/freqtrade/tests/test_misc.py @@ -16,16 +16,28 @@ def test_throttle(): return 42 start = time.time() - result = throttle(func, 0.1) + result = throttle(func, min_secs=0.1) end = time.time() assert result == 42 assert end - start > 0.1 - result = throttle(func, -1) + result = throttle(func, min_secs=-1) assert result == 42 +def test_throttle_with_assets(): + + def func(nb_assets=-1): + return nb_assets + + result = throttle(func, min_secs=0.1, nb_assets=666) + assert result == 666 + + result = throttle(func, min_secs=0.1) + assert result == -1 + + def test_parse_args_defaults(): args = parse_args([]) assert args is not None @@ -73,7 +85,8 @@ def test_parse_args_dynamic_whitelist_invalid_values(): def test_parse_args_backtesting(mocker): - backtesting_mock = mocker.patch('freqtrade.optimize.backtesting.start', MagicMock()) + backtesting_mock = mocker.patch( + 'freqtrade.optimize.backtesting.start', MagicMock()) args = parse_args(['backtesting']) assert args is None assert backtesting_mock.call_count == 1 @@ -96,7 +109,8 @@ def test_parse_args_backtesting_invalid(): def test_parse_args_backtesting_custom(mocker): - backtesting_mock = mocker.patch('freqtrade.optimize.backtesting.start', MagicMock()) + backtesting_mock = mocker.patch( + 'freqtrade.optimize.backtesting.start', MagicMock()) args = parse_args([ '-c', 'test_conf.json', 'backtesting', @@ -117,7 +131,8 @@ def test_parse_args_backtesting_custom(mocker): def test_parse_args_hyperopt(mocker): - hyperopt_mock = mocker.patch('freqtrade.optimize.hyperopt.start', MagicMock()) + hyperopt_mock = mocker.patch( + 'freqtrade.optimize.hyperopt.start', MagicMock()) args = parse_args(['hyperopt']) assert args is None assert hyperopt_mock.call_count == 1 @@ -130,7 +145,8 @@ def test_parse_args_hyperopt(mocker): def test_parse_args_hyperopt_custom(mocker): - hyperopt_mock = mocker.patch('freqtrade.optimize.hyperopt.start', MagicMock()) + hyperopt_mock = mocker.patch( + 'freqtrade.optimize.hyperopt.start', MagicMock()) args = parse_args(['-c', 'test_conf.json', 'hyperopt', '--epochs', '20']) assert args is None assert hyperopt_mock.call_count == 1 @@ -155,7 +171,10 @@ def test_load_config(default_conf, mocker): def test_load_config_invalid_pair(default_conf, mocker): conf = deepcopy(default_conf) conf['exchange']['pair_whitelist'].append('BTC-ETH') - mocker.patch('freqtrade.misc.open', mocker.mock_open(read_data=json.dumps(conf))) + mocker.patch( + 'freqtrade.misc.open', + mocker.mock_open( + read_data=json.dumps(conf))) with pytest.raises(ValidationError, match=r'.*does not match.*'): load_config('somefile') @@ -163,6 +182,9 @@ def test_load_config_invalid_pair(default_conf, mocker): def test_load_config_missing_attributes(default_conf, mocker): conf = deepcopy(default_conf) conf.pop('exchange') - mocker.patch('freqtrade.misc.open', mocker.mock_open(read_data=json.dumps(conf))) + mocker.patch( + 'freqtrade.misc.open', + mocker.mock_open( + read_data=json.dumps(conf))) with pytest.raises(ValidationError, match=r'.*\'exchange\' is a required property.*'): load_config('somefile')