From 67193bca3dc6d43bdfdbbbb0a8c461b3569d12ba Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 23 Dec 2020 16:54:35 +0100 Subject: [PATCH] Move pairlists to be a plugin submodule --- freqtrade/commands/pairlist_commands.py | 2 +- freqtrade/freqtradebot.py | 2 +- freqtrade/optimize/backtesting.py | 2 +- freqtrade/{ => plugins}/pairlist/AgeFilter.py | 2 +- freqtrade/{ => plugins}/pairlist/IPairList.py | 0 .../{ => plugins}/pairlist/PerformanceFilter.py | 2 +- .../{ => plugins}/pairlist/PrecisionFilter.py | 2 +- freqtrade/{ => plugins}/pairlist/PriceFilter.py | 2 +- .../{ => plugins}/pairlist/ShuffleFilter.py | 2 +- freqtrade/{ => plugins}/pairlist/SpreadFilter.py | 2 +- .../{ => plugins}/pairlist/StaticPairList.py | 2 +- .../{ => plugins}/pairlist/VolumePairList.py | 2 +- freqtrade/{ => plugins}/pairlist/__init__.py | 0 .../pairlist/rangestabilityfilter.py | 2 +- .../{pairlist => plugins}/pairlistmanager.py | 2 +- freqtrade/resolvers/pairlist_resolver.py | 4 ++-- tests/data/test_dataprovider.py | 2 +- tests/optimize/test_backtesting.py | 16 ++++++++-------- tests/plugins/test_pairlist.py | 4 ++-- 19 files changed, 26 insertions(+), 26 deletions(-) rename freqtrade/{ => plugins}/pairlist/AgeFilter.py (98%) rename freqtrade/{ => plugins}/pairlist/IPairList.py (100%) rename freqtrade/{ => plugins}/pairlist/PerformanceFilter.py (97%) rename freqtrade/{ => plugins}/pairlist/PrecisionFilter.py (97%) rename freqtrade/{ => plugins}/pairlist/PriceFilter.py (98%) rename freqtrade/{ => plugins}/pairlist/ShuffleFilter.py (96%) rename freqtrade/{ => plugins}/pairlist/SpreadFilter.py (96%) rename freqtrade/{ => plugins}/pairlist/StaticPairList.py (97%) rename freqtrade/{ => plugins}/pairlist/VolumePairList.py (98%) rename freqtrade/{ => plugins}/pairlist/__init__.py (100%) rename freqtrade/{ => plugins}/pairlist/rangestabilityfilter.py (98%) rename freqtrade/{pairlist => plugins}/pairlistmanager.py (98%) diff --git a/freqtrade/commands/pairlist_commands.py b/freqtrade/commands/pairlist_commands.py index e4ee80ca5..0661cd03c 100644 --- a/freqtrade/commands/pairlist_commands.py +++ b/freqtrade/commands/pairlist_commands.py @@ -15,7 +15,7 @@ def start_test_pairlist(args: Dict[str, Any]) -> None: """ Test Pairlist configuration """ - from freqtrade.pairlist.pairlistmanager import PairListManager + from freqtrade.plugins.pairlistmanager import PairListManager config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE) exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config, validate=False) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 08b806076..dc8994d74 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -22,7 +22,7 @@ from freqtrade.exceptions import (DependencyException, ExchangeError, Insufficie from freqtrade.exchange import timeframe_to_minutes, timeframe_to_seconds from freqtrade.misc import safe_value_fallback, safe_value_fallback2 from freqtrade.mixins import LoggingMixin -from freqtrade.pairlist.pairlistmanager import PairListManager +from freqtrade.plugins.pairlistmanager import PairListManager from freqtrade.persistence import Order, PairLocks, Trade, cleanup_db, init_db from freqtrade.plugins.protectionmanager import ProtectionManager from freqtrade.resolvers import ExchangeResolver, StrategyResolver diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 639904975..49274f75e 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -21,7 +21,7 @@ from freqtrade.exchange import timeframe_to_minutes, timeframe_to_seconds from freqtrade.mixins import LoggingMixin from freqtrade.optimize.optimize_reports import (generate_backtest_stats, show_backtest_results, store_backtest_stats) -from freqtrade.pairlist.pairlistmanager import PairListManager +from freqtrade.plugins.pairlistmanager import PairListManager from freqtrade.persistence import PairLocks, Trade from freqtrade.plugins.protectionmanager import ProtectionManager from freqtrade.resolvers import ExchangeResolver, StrategyResolver diff --git a/freqtrade/pairlist/AgeFilter.py b/freqtrade/plugins/pairlist/AgeFilter.py similarity index 98% rename from freqtrade/pairlist/AgeFilter.py rename to freqtrade/plugins/pairlist/AgeFilter.py index e3465bd82..8c3a5d22f 100644 --- a/freqtrade/pairlist/AgeFilter.py +++ b/freqtrade/plugins/pairlist/AgeFilter.py @@ -10,7 +10,7 @@ from pandas import DataFrame from freqtrade.exceptions import OperationalException from freqtrade.misc import plural -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList logger = logging.getLogger(__name__) diff --git a/freqtrade/pairlist/IPairList.py b/freqtrade/plugins/pairlist/IPairList.py similarity index 100% rename from freqtrade/pairlist/IPairList.py rename to freqtrade/plugins/pairlist/IPairList.py diff --git a/freqtrade/pairlist/PerformanceFilter.py b/freqtrade/plugins/pairlist/PerformanceFilter.py similarity index 97% rename from freqtrade/pairlist/PerformanceFilter.py rename to freqtrade/plugins/pairlist/PerformanceFilter.py index 92a97099e..c99905af5 100644 --- a/freqtrade/pairlist/PerformanceFilter.py +++ b/freqtrade/plugins/pairlist/PerformanceFilter.py @@ -6,7 +6,7 @@ from typing import Any, Dict, List import pandas as pd -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList from freqtrade.persistence import Trade diff --git a/freqtrade/pairlist/PrecisionFilter.py b/freqtrade/plugins/pairlist/PrecisionFilter.py similarity index 97% rename from freqtrade/pairlist/PrecisionFilter.py rename to freqtrade/plugins/pairlist/PrecisionFilter.py index c0d2893a1..519337f29 100644 --- a/freqtrade/pairlist/PrecisionFilter.py +++ b/freqtrade/plugins/pairlist/PrecisionFilter.py @@ -5,7 +5,7 @@ import logging from typing import Any, Dict from freqtrade.exceptions import OperationalException -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList logger = logging.getLogger(__name__) diff --git a/freqtrade/pairlist/PriceFilter.py b/freqtrade/plugins/pairlist/PriceFilter.py similarity index 98% rename from freqtrade/pairlist/PriceFilter.py rename to freqtrade/plugins/pairlist/PriceFilter.py index 20a260b46..6558f196f 100644 --- a/freqtrade/pairlist/PriceFilter.py +++ b/freqtrade/plugins/pairlist/PriceFilter.py @@ -5,7 +5,7 @@ import logging from typing import Any, Dict from freqtrade.exceptions import OperationalException -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList logger = logging.getLogger(__name__) diff --git a/freqtrade/pairlist/ShuffleFilter.py b/freqtrade/plugins/pairlist/ShuffleFilter.py similarity index 96% rename from freqtrade/pairlist/ShuffleFilter.py rename to freqtrade/plugins/pairlist/ShuffleFilter.py index 28778db7b..4d3dd29e3 100644 --- a/freqtrade/pairlist/ShuffleFilter.py +++ b/freqtrade/plugins/pairlist/ShuffleFilter.py @@ -5,7 +5,7 @@ import logging import random from typing import Any, Dict, List -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList logger = logging.getLogger(__name__) diff --git a/freqtrade/pairlist/SpreadFilter.py b/freqtrade/plugins/pairlist/SpreadFilter.py similarity index 96% rename from freqtrade/pairlist/SpreadFilter.py rename to freqtrade/plugins/pairlist/SpreadFilter.py index cbbfb9626..2f3fe47e3 100644 --- a/freqtrade/pairlist/SpreadFilter.py +++ b/freqtrade/plugins/pairlist/SpreadFilter.py @@ -4,7 +4,7 @@ Spread pair list filter import logging from typing import Any, Dict -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList logger = logging.getLogger(__name__) diff --git a/freqtrade/pairlist/StaticPairList.py b/freqtrade/plugins/pairlist/StaticPairList.py similarity index 97% rename from freqtrade/pairlist/StaticPairList.py rename to freqtrade/plugins/pairlist/StaticPairList.py index 2879cb364..dd592e0ca 100644 --- a/freqtrade/pairlist/StaticPairList.py +++ b/freqtrade/plugins/pairlist/StaticPairList.py @@ -7,7 +7,7 @@ import logging from typing import Any, Dict, List from freqtrade.exceptions import OperationalException -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList logger = logging.getLogger(__name__) diff --git a/freqtrade/pairlist/VolumePairList.py b/freqtrade/plugins/pairlist/VolumePairList.py similarity index 98% rename from freqtrade/pairlist/VolumePairList.py rename to freqtrade/plugins/pairlist/VolumePairList.py index 7056bc59d..dd8fc64fd 100644 --- a/freqtrade/pairlist/VolumePairList.py +++ b/freqtrade/plugins/pairlist/VolumePairList.py @@ -8,7 +8,7 @@ from datetime import datetime from typing import Any, Dict, List from freqtrade.exceptions import OperationalException -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList logger = logging.getLogger(__name__) diff --git a/freqtrade/pairlist/__init__.py b/freqtrade/plugins/pairlist/__init__.py similarity index 100% rename from freqtrade/pairlist/__init__.py rename to freqtrade/plugins/pairlist/__init__.py diff --git a/freqtrade/pairlist/rangestabilityfilter.py b/freqtrade/plugins/pairlist/rangestabilityfilter.py similarity index 98% rename from freqtrade/pairlist/rangestabilityfilter.py rename to freqtrade/plugins/pairlist/rangestabilityfilter.py index 6efe1e2ae..f2e84930b 100644 --- a/freqtrade/pairlist/rangestabilityfilter.py +++ b/freqtrade/plugins/pairlist/rangestabilityfilter.py @@ -11,7 +11,7 @@ from pandas import DataFrame from freqtrade.exceptions import OperationalException from freqtrade.misc import plural -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList logger = logging.getLogger(__name__) diff --git a/freqtrade/pairlist/pairlistmanager.py b/freqtrade/plugins/pairlistmanager.py similarity index 98% rename from freqtrade/pairlist/pairlistmanager.py rename to freqtrade/plugins/pairlistmanager.py index 418cc9e92..b71f02898 100644 --- a/freqtrade/pairlist/pairlistmanager.py +++ b/freqtrade/plugins/pairlistmanager.py @@ -9,7 +9,7 @@ from cachetools import TTLCache, cached from freqtrade.constants import ListPairsWithTimeframes from freqtrade.exceptions import OperationalException -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList from freqtrade.resolvers import PairListResolver diff --git a/freqtrade/resolvers/pairlist_resolver.py b/freqtrade/resolvers/pairlist_resolver.py index 4df5da37c..72a3cc1dd 100644 --- a/freqtrade/resolvers/pairlist_resolver.py +++ b/freqtrade/resolvers/pairlist_resolver.py @@ -6,7 +6,7 @@ This module load custom pairlists import logging from pathlib import Path -from freqtrade.pairlist.IPairList import IPairList +from freqtrade.plugins.pairlist.IPairList import IPairList from freqtrade.resolvers import IResolver @@ -20,7 +20,7 @@ class PairListResolver(IResolver): object_type = IPairList object_type_str = "Pairlist" user_subdir = None - initial_search_path = Path(__file__).parent.parent.joinpath('pairlist').resolve() + initial_search_path = Path(__file__).parent.parent.joinpath('plugins/pairlist').resolve() @staticmethod def load_pairlist(pairlist_name: str, exchange, pairlistmanager, diff --git a/tests/data/test_dataprovider.py b/tests/data/test_dataprovider.py index a3c57a77b..ee2e551b6 100644 --- a/tests/data/test_dataprovider.py +++ b/tests/data/test_dataprovider.py @@ -6,7 +6,7 @@ from pandas import DataFrame from freqtrade.data.dataprovider import DataProvider from freqtrade.exceptions import ExchangeError, OperationalException -from freqtrade.pairlist.pairlistmanager import PairListManager +from freqtrade.plugins.pairlistmanager import PairListManager from freqtrade.state import RunMode from tests.conftest import get_patched_exchange diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index 971f8d048..376390664 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -341,7 +341,7 @@ def test_backtesting_start(default_conf, mocker, testdatadir, caplog) -> None: mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest') mocker.patch('freqtrade.optimize.backtesting.generate_backtest_stats') mocker.patch('freqtrade.optimize.backtesting.show_backtest_results') - mocker.patch('freqtrade.pairlist.pairlistmanager.PairListManager.whitelist', + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', PropertyMock(return_value=['UNITTEST/BTC'])) default_conf['timeframe'] = '1m' @@ -372,7 +372,7 @@ def test_backtesting_start_no_data(default_conf, mocker, caplog, testdatadir) -> mocker.patch('freqtrade.data.history.get_timerange', get_timerange) patch_exchange(mocker) mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest') - mocker.patch('freqtrade.pairlist.pairlistmanager.PairListManager.whitelist', + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', PropertyMock(return_value=['UNITTEST/BTC'])) default_conf['timeframe'] = "1m" @@ -392,7 +392,7 @@ def test_backtesting_no_pair_left(default_conf, mocker, caplog, testdatadir) -> mocker.patch('freqtrade.data.history.get_timerange', get_timerange) patch_exchange(mocker) mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest') - mocker.patch('freqtrade.pairlist.pairlistmanager.PairListManager.whitelist', + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', PropertyMock(return_value=[])) default_conf['timeframe'] = "1m" @@ -415,9 +415,9 @@ def test_backtesting_pairlist_list(default_conf, mocker, caplog, testdatadir, ti mocker.patch('freqtrade.data.history.get_timerange', get_timerange) patch_exchange(mocker) mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest') - mocker.patch('freqtrade.pairlist.pairlistmanager.PairListManager.whitelist', + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', PropertyMock(return_value=['XRP/BTC'])) - mocker.patch('freqtrade.pairlist.pairlistmanager.PairListManager.refresh_pairlist') + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.refresh_pairlist') default_conf['ticker_interval'] = "1m" default_conf['datadir'] = testdatadir @@ -700,7 +700,7 @@ def test_backtest_start_timerange(default_conf, mocker, caplog, testdatadir): mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest') mocker.patch('freqtrade.optimize.backtesting.generate_backtest_stats') mocker.patch('freqtrade.optimize.backtesting.show_backtest_results') - mocker.patch('freqtrade.pairlist.pairlistmanager.PairListManager.whitelist', + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', PropertyMock(return_value=['UNITTEST/BTC'])) patched_configuration_load_config_file(mocker, default_conf) @@ -740,7 +740,7 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir): patch_exchange(mocker) backtestmock = MagicMock(return_value=pd.DataFrame(columns=BT_DATA_COLUMNS + ['profit_abs'])) - mocker.patch('freqtrade.pairlist.pairlistmanager.PairListManager.whitelist', + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', PropertyMock(return_value=['UNITTEST/BTC'])) mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest', backtestmock) text_table_mock = MagicMock() @@ -837,7 +837,7 @@ def test_backtest_start_multi_strat_nomock(default_conf, mocker, caplog, testdat 'sell_reason': [SellType.ROI, SellType.ROI, SellType.STOP_LOSS] }), ]) - mocker.patch('freqtrade.pairlist.pairlistmanager.PairListManager.whitelist', + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', PropertyMock(return_value=['UNITTEST/BTC'])) mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest', backtestmock) diff --git a/tests/plugins/test_pairlist.py b/tests/plugins/test_pairlist.py index c4b370e15..1795fc27f 100644 --- a/tests/plugins/test_pairlist.py +++ b/tests/plugins/test_pairlist.py @@ -6,7 +6,7 @@ import pytest from freqtrade.constants import AVAILABLE_PAIRLISTS from freqtrade.exceptions import OperationalException -from freqtrade.pairlist.pairlistmanager import PairListManager +from freqtrade.plugins.pairlistmanager import PairListManager from freqtrade.resolvers import PairListResolver from tests.conftest import get_patched_freqtradebot, log_has, log_has_re @@ -190,7 +190,7 @@ def test_refresh_pairlist_dynamic_2(mocker, shitcoinmarkets, tickers, whitelist_ ) # Remove caching of ticker data to emulate changing volume by the time of second call mocker.patch.multiple( - 'freqtrade.pairlist.pairlistmanager.PairListManager', + 'freqtrade.plugins.pairlistmanager.PairListManager', _get_cached_tickers=MagicMock(return_value=tickers_dict), ) freqtrade = get_patched_freqtradebot(mocker, whitelist_conf_2)