freqtrade_origin/freqtrade/pairlist/StaticPairList.py

61 lines
2.0 KiB
Python
Raw Normal View History

2018-11-30 05:34:56 +00:00
"""
2020-05-17 11:26:21 +00:00
Static Pair List provider
2018-11-30 05:34:56 +00:00
2020-05-17 11:26:21 +00:00
Provides pair white list as it configured in config
"""
2018-11-30 05:34:56 +00:00
import logging
from typing import Any, Dict, List
2018-12-05 19:44:56 +00:00
from freqtrade.exceptions import OperationalException
2018-12-05 19:44:56 +00:00
from freqtrade.pairlist.IPairList import IPairList
2018-11-30 05:34:56 +00:00
2020-05-17 11:26:21 +00:00
2018-11-30 05:34:56 +00:00
logger = logging.getLogger(__name__)
2018-12-05 19:44:56 +00:00
class StaticPairList(IPairList):
2018-11-30 05:34:56 +00:00
def __init__(self, exchange, pairlistmanager,
config: Dict[str, Any], pairlistconfig: Dict[str, Any],
pairlist_pos: int) -> None:
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
if self._pairlist_pos != 0:
raise OperationalException(f"{self.name} can only be used in the first position "
"in the list of Pairlist Handlers.")
@property
def needstickers(self) -> bool:
"""
Boolean property defining if tickers are necessary.
2020-06-24 14:21:28 +00:00
If no Pairlist requires tickers, an empty List is passed
as tickers argument to filter_pairlist
"""
return False
2018-12-03 19:31:25 +00:00
def short_desc(self) -> str:
"""
Short whitelist method description - used for startup-messages
-> Please overwrite in subclasses
"""
2019-11-09 06:07:33 +00:00
return f"{self.name}"
2018-12-03 19:31:25 +00:00
def gen_pairlist(self, cached_pairlist: List[str], tickers: Dict) -> List[str]:
"""
Generate the pairlist
:param cached_pairlist: Previously generated pairlist (cached)
:param tickers: Tickers (from exchange.get_tickers()).
:return: List of pairs
"""
return self._whitelist_for_active_markets(self._config['exchange']['pair_whitelist'])
2019-11-09 12:40:36 +00:00
def filter_pairlist(self, pairlist: List[str], tickers: Dict) -> List[str]:
2018-11-30 05:34:56 +00:00
"""
2019-11-09 05:55:16 +00:00
Filters and sorts pairlist and returns the whitelist again.
Called on each bot iteration - please use internal caching if necessary
:param pairlist: pairlist to filter or sort
:param tickers: Tickers (from exchange.get_tickers()). May be cached.
:return: new whitelist
2018-11-30 05:34:56 +00:00
"""
return pairlist