mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 05:50:36 +00:00
Add test for new warning modes
This commit is contained in:
@@ -2390,3 +2390,65 @@ def test_MarketCapPairList_exceptions(mocker, default_conf_usdt):
|
||||
OperationalException, match="This filter only support marketcap rank up to 250."
|
||||
):
|
||||
PairListManager(exchange, default_conf_usdt)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pairlists,expected_error,expected_warning",
|
||||
[
|
||||
(
|
||||
[{"method": "StaticPairList"}],
|
||||
None, # Error
|
||||
None, # Warning
|
||||
),
|
||||
(
|
||||
[{"method": "VolumePairList", "number_assets": 10}],
|
||||
"VolumePairList", # Error
|
||||
None, # Warning
|
||||
),
|
||||
(
|
||||
[{"method": "MarketCapPairList", "number_assets": 10}],
|
||||
None, # Error
|
||||
r"MarketCapPairList.*lookahead.*", # Warning
|
||||
),
|
||||
(
|
||||
[{"method": "StaticPairList"}, {"method": "FullTradesFilter"}],
|
||||
None, # Error
|
||||
r"FullTradesFilter do not generate.*", # Warning
|
||||
),
|
||||
( # combi, fails and warns
|
||||
[
|
||||
{"method": "VolumePairList", "number_assets": 10},
|
||||
{"method": "MarketCapPairList", "number_assets": 10},
|
||||
],
|
||||
"VolumePairList", # Error
|
||||
r"MarketCapPairList.*lookahead.*", # Warning
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_backtesting_modes(
|
||||
mocker, default_conf_usdt, pairlists, expected_error, expected_warning, caplog, markets, tickers
|
||||
):
|
||||
default_conf_usdt["runmode"] = "dry_run"
|
||||
default_conf_usdt["pairlists"] = pairlists
|
||||
|
||||
mocker.patch.multiple(
|
||||
EXMS,
|
||||
markets=PropertyMock(return_value=markets),
|
||||
exchange_has=MagicMock(return_value=True),
|
||||
get_tickers=tickers,
|
||||
)
|
||||
exchange = get_patched_exchange(mocker, default_conf_usdt)
|
||||
|
||||
# Dry run mode - works always
|
||||
PairListManager(exchange, default_conf_usdt)
|
||||
|
||||
default_conf_usdt["runmode"] = "backtest"
|
||||
if expected_error:
|
||||
with pytest.raises(OperationalException, match=f"Pairlist Handlers {expected_error}.*"):
|
||||
PairListManager(exchange, default_conf_usdt)
|
||||
|
||||
if not expected_error:
|
||||
PairListManager(exchange, default_conf_usdt)
|
||||
|
||||
if expected_warning:
|
||||
assert log_has_re(f"Pairlist Handlers {expected_warning}", caplog)
|
||||
|
||||
Reference in New Issue
Block a user