attached pairlist manager onto dataprovider init for unified access to dynamic whitelist

This commit is contained in:
Paul D. Mendes
2020-05-11 19:32:28 +04:00
parent bc9efc31ad
commit 9fbe135790
3 changed files with 40 additions and 26 deletions

View File

@@ -10,6 +10,7 @@ from typing import Any, Dict, List, Optional, Tuple
from pandas import DataFrame
from freqtrade.data.history import load_pair_history
from freqtrade.exceptions import OperationalException
from freqtrade.exchange import Exchange
from freqtrade.state import RunMode
@@ -18,9 +19,10 @@ logger = logging.getLogger(__name__)
class DataProvider:
def __init__(self, config: dict, exchange: Exchange) -> None:
def __init__(self, config: dict, exchange: Exchange, pairlists=None) -> None:
self._config = config
self._exchange = exchange
self._pairlists = pairlists
def refresh(self,
pairlist: List[Tuple[str, str]],
@@ -125,8 +127,8 @@ class DataProvider:
As available pairs does not show whitelist until after informative pairs have been cached.
:return: list of pairs in whitelist
"""
from freqtrade.pairlist.pairlistmanager import PairListManager
pairlists = PairListManager(self._exchange, self._config)
pairlists.refresh_pairlist()
return pairlists.whitelist
if self._pairlists:
return self._pairlists.whitelist
else:
raise OperationalException("Dataprovider was not initialized with a pairlist provider.")

View File

@@ -71,15 +71,15 @@ class FreqtradeBot:
self.wallets = Wallets(self.config, self.exchange)
self.dataprovider = DataProvider(self.config, self.exchange)
self.pairlists = PairListManager(self.exchange, self.config)
self.dataprovider = DataProvider(self.config, self.exchange, self.pairlists)
# Attach Dataprovider to Strategy baseclass
IStrategy.dp = self.dataprovider
# Attach Wallets to Strategy baseclass
IStrategy.wallets = self.wallets
self.pairlists = PairListManager(self.exchange, self.config)
# Initializing Edge only if enabled
self.edge = Edge(self.config, self.exchange, self.strategy) if \
self.config.get('edge', {}).get('enabled', False) else None