Start pairlist parameter listing
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user