Add some more pairlist parameter definitions

This commit is contained in:
Matthias 2023-04-20 06:58:05 +02:00
parent 987da010c9
commit 2ea157d9d3
6 changed files with 51 additions and 12 deletions

View File

@ -70,12 +70,6 @@ class AgeFilter(IPairList):
@staticmethod
def available_parameters() -> Dict[str, PairlistParameter]:
"""
Return parameters used by this Pairlist Handler, and their type
contains a dictionary with the parameter name as key, and a dictionary
with the type and default value.
-> Please overwrite in subclasses
"""
return {
"min_days_listed": {
"type": "number",

View File

@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
class PairlistParameter(TypedDict):
type: Literal["number", "string", "boolean"]
default: Union[int, float, str, bool]
default: Union[int, float, str, bool, None]
description: str
help: str
@ -72,7 +72,7 @@ class IPairList(LoggingMixin, ABC):
return {}
@staticmethod
def refresh_period(params: Dict[str, PairlistParameter]) -> None:
def refresh_period_parameter() -> Dict[str, PairlistParameter]:
return {
"refresh_period": {
"type": "number",

View File

@ -7,7 +7,7 @@ from typing import Any, Dict, List
from freqtrade.constants import Config
from freqtrade.exceptions import OperationalException
from freqtrade.exchange.types import Tickers
from freqtrade.plugins.pairlist.IPairList import IPairList
from freqtrade.plugins.pairlist.IPairList import IPairList, PairlistParameter
logger = logging.getLogger(__name__)
@ -43,6 +43,23 @@ class OffsetFilter(IPairList):
return f"{self.name} - Taking {self._number_pairs} Pairs, starting from {self._offset}."
return f"{self.name} - Offsetting pairs by {self._offset}."
@staticmethod
def available_parameters() -> Dict[str, PairlistParameter]:
return {
"offset": {
"type": "number",
"default": 0,
"description": "Offset",
"help": "Offset of the pairlist.",
},
"number_assets": {
"type": "number",
"default": 0,
"description": "Number of assets",
"help": "Number of assets to use from the pairlist, starting from offset.",
},
}
def filter_pairlist(self, pairlist: List[str], tickers: Tickers) -> List[str]:
"""
Filters and sorts pairlist and returns the whitelist again.

View File

@ -9,7 +9,7 @@ import pandas as pd
from freqtrade.constants import Config
from freqtrade.exchange.types import Tickers
from freqtrade.persistence import Trade
from freqtrade.plugins.pairlist.IPairList import IPairList
from freqtrade.plugins.pairlist.IPairList import IPairList, PairlistParameter
logger = logging.getLogger(__name__)
@ -40,6 +40,23 @@ class PerformanceFilter(IPairList):
"""
return f"{self.name} - Sorting pairs by performance."
@staticmethod
def available_parameters() -> Dict[str, PairlistParameter]:
return {
"minutes": {
"type": "number",
"default": 0,
"description": "Minutes",
"help": "Consider trades from the last X minutes. 0 means all trades.",
},
"min_profit": {
"type": "number",
"default": None,
"description": "Minimum profit",
"help": "Minimum profit in percent. Pairs with less profit are removed.",
},
}
def filter_pairlist(self, pairlist: List[str], tickers: Tickers) -> List[str]:
"""
Filters and sorts pairlist and returns the allowlist again.

View File

@ -8,7 +8,7 @@ from freqtrade.constants import Config
from freqtrade.exceptions import OperationalException
from freqtrade.exchange import ROUND_UP
from freqtrade.exchange.types import Ticker
from freqtrade.plugins.pairlist.IPairList import IPairList
from freqtrade.plugins.pairlist.IPairList import IPairList, PairlistParameter
logger = logging.getLogger(__name__)

View File

@ -9,7 +9,7 @@ from typing import Any, Dict, List
from freqtrade.constants import Config
from freqtrade.exchange.types import Tickers
from freqtrade.plugins.pairlist.IPairList import IPairList
from freqtrade.plugins.pairlist.IPairList import IPairList, PairlistParameter
logger = logging.getLogger(__name__)
@ -40,6 +40,17 @@ class StaticPairList(IPairList):
"""
return f"{self.name}"
@staticmethod
def available_parameters() -> Dict[str, PairlistParameter]:
return {
"allow_inactive": {
"type": "boolean",
"default": False,
"description": "Allow inactive pairs",
"help": "Allow inactive pairs to be in the whitelist.",
},
}
def gen_pairlist(self, tickers: Tickers) -> List[str]:
"""
Generate the pairlist