Fix PerformanceFilter failing in test-pairlist mode
This commit is contained in:
parent
0d50e99563
commit
37b71b8cfd
@ -39,7 +39,12 @@ class PerformanceFilter(IPairList):
|
||||
:return: new allowlist
|
||||
"""
|
||||
# Get the trading performance for pairs from database
|
||||
try:
|
||||
performance = pd.DataFrame(Trade.get_overall_performance())
|
||||
except AttributeError:
|
||||
# Performancefilter does not work in backtesting.
|
||||
self.log_once("PerformanceFilter is not available in this mode.", logger.warning)
|
||||
return pairlist
|
||||
|
||||
# Skip performance-based sorting if no performance data is available
|
||||
if len(performance) == 0:
|
||||
|
@ -7,10 +7,11 @@ import pytest
|
||||
|
||||
from freqtrade.constants import AVAILABLE_PAIRLISTS
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.persistence import Trade
|
||||
from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist
|
||||
from freqtrade.plugins.pairlistmanager import PairListManager
|
||||
from freqtrade.resolvers import PairListResolver
|
||||
from tests.conftest import get_patched_freqtradebot, log_has, log_has_re
|
||||
from tests.conftest import get_patched_exchange, get_patched_freqtradebot, log_has, log_has_re
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
@ -512,6 +513,18 @@ def test_PrecisionFilter_error(mocker, whitelist_conf) -> None:
|
||||
PairListManager(MagicMock, whitelist_conf)
|
||||
|
||||
|
||||
def test_PerformanceFilter_error(mocker, whitelist_conf, caplog) -> None:
|
||||
whitelist_conf['pairlists'] = [{"method": "StaticPairList"}, {"method": "PerformanceFilter"}]
|
||||
if hasattr(Trade, 'query'):
|
||||
del Trade.query
|
||||
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
|
||||
exchange = get_patched_exchange(mocker, whitelist_conf)
|
||||
pm = PairListManager(exchange, whitelist_conf)
|
||||
pm.refresh_pairlist()
|
||||
|
||||
assert log_has("PerformanceFilter is not available in this mode.", caplog)
|
||||
|
||||
|
||||
def test_gen_pair_whitelist_not_supported(mocker, default_conf, tickers) -> None:
|
||||
default_conf['pairlists'] = [{'method': 'VolumePairList', 'number_assets': 10}]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user