Start pairlist parameter listing

This commit is contained in:
Matthias
2023-04-19 21:08:44 +02:00
parent 5ad352fdf1
commit 987da010c9
3 changed files with 54 additions and 2 deletions
+24 -1
View File
@@ -12,7 +12,7 @@ from freqtrade.constants import Config, ListPairsWithTimeframes
from freqtrade.exceptions import OperationalException
from freqtrade.exchange.types import Tickers
from freqtrade.misc import plural
from freqtrade.plugins.pairlist.IPairList import IPairList
from freqtrade.plugins.pairlist.IPairList import IPairList, PairlistParameter
from freqtrade.util import PeriodicCache
@@ -68,6 +68,29 @@ class AgeFilter(IPairList):
f"{self._max_days_listed} {plural(self._max_days_listed, 'day')}"
) if self._max_days_listed else '')
@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",
"default": 10,
"description": "Minimum Days Listed",
"help": "Minimum number of days a pair must have been listed on the exchange.",
},
"max_days_listed": {
"type": "number",
"default": None,
"description": "Maximum Days Listed",
"help": "Maximum number of days a pair must have been listed on the exchange.",
},
}
def filter_pairlist(self, pairlist: List[str], tickers: Tickers) -> List[str]:
"""
:param pairlist: pairlist to filter or sort
+29 -1
View File
@@ -4,7 +4,7 @@ PairList Handler base class
import logging
from abc import ABC, abstractmethod, abstractproperty
from copy import deepcopy
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Literal, Optional, TypedDict, Union
from freqtrade.constants import Config
from freqtrade.exceptions import OperationalException
@@ -16,6 +16,13 @@ from freqtrade.mixins import LoggingMixin
logger = logging.getLogger(__name__)
class PairlistParameter(TypedDict):
type: Literal["number", "string", "boolean"]
default: Union[int, float, str, bool]
description: str
help: str
class IPairList(LoggingMixin, ABC):
def __init__(self, exchange: Exchange, pairlistmanager,
@@ -54,6 +61,27 @@ class IPairList(LoggingMixin, ABC):
as tickers argument to filter_pairlist
"""
@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 {}
@staticmethod
def refresh_period(params: Dict[str, PairlistParameter]) -> None:
return {
"refresh_period": {
"type": "number",
"default": 1800,
"description": "Refresh period",
"help": "Refresh period in seconds",
}
}
@abstractmethod
def short_desc(self) -> str:
"""
+1
View File
@@ -310,6 +310,7 @@ def list_pairlists(config=Depends(get_config)):
return {'pairlists': [{
"name": x['name'],
"params": x['class'].available_parameters(),
} for x in pairlists
]}