Move _create_pair_whitelist to dataprovider

This commit is contained in:
hroff-1902 2020-05-16 11:25:32 +03:00
parent bf25746965
commit 035a12ce61
2 changed files with 10 additions and 9 deletions

View File

@ -25,6 +25,7 @@ class DataProvider:
self._config = config self._config = config
self._exchange = exchange self._exchange = exchange
self._pairlists = pairlists self._pairlists = pairlists
self._timeframe = self._config['ticker_interval']
def refresh(self, def refresh(self,
pairlist: ListPairsWithTimeframes, pairlist: ListPairsWithTimeframes,
@ -45,6 +46,12 @@ class DataProvider:
""" """
return list(self._exchange._klines.keys()) return list(self._exchange._klines.keys())
def create_pair_list(self, pairs: List[str], timeframe: str = None) -> ListPairsWithTimeframes:
"""
Create list of pair tuples with (pair, ticker_interval)
"""
return [(pair, timeframe or self._timeframe) for pair in pairs]
def ohlcv(self, pair: str, timeframe: str = None, copy: bool = True) -> DataFrame: def ohlcv(self, pair: str, timeframe: str = None, copy: bool = True) -> DataFrame:
""" """
Get candle (OHLCV) data for the given pair as DataFrame Get candle (OHLCV) data for the given pair as DataFrame
@ -55,7 +62,7 @@ class DataProvider:
Use False only for read-only operations (where the dataframe is not modified) Use False only for read-only operations (where the dataframe is not modified)
""" """
if self.runmode in (RunMode.DRY_RUN, RunMode.LIVE): if self.runmode in (RunMode.DRY_RUN, RunMode.LIVE):
return self._exchange.klines((pair, timeframe or self._config['ticker_interval']), return self._exchange.klines((pair, timeframe or self._timeframe),
copy=copy) copy=copy)
else: else:
return DataFrame() return DataFrame()
@ -67,7 +74,7 @@ class DataProvider:
:param timeframe: timeframe to get data for :param timeframe: timeframe to get data for
""" """
return load_pair_history(pair=pair, return load_pair_history(pair=pair,
timeframe=timeframe or self._config['ticker_interval'], timeframe=timeframe or self._timeframe,
datadir=self._config['datadir'] datadir=self._config['datadir']
) )

View File

@ -145,7 +145,7 @@ class FreqtradeBot:
self.active_pair_whitelist = self._refresh_whitelist(trades) self.active_pair_whitelist = self._refresh_whitelist(trades)
# Refreshing candles # Refreshing candles
self.dataprovider.refresh(self._create_pair_whitelist(self.active_pair_whitelist), self.dataprovider.refresh(self.dataprovider.create_pair_list(self.active_pair_whitelist),
self.strategy.informative_pairs()) self.strategy.informative_pairs())
with self._sell_lock: with self._sell_lock:
@ -184,12 +184,6 @@ class FreqtradeBot:
_whitelist.extend([trade.pair for trade in trades if trade.pair not in _whitelist]) _whitelist.extend([trade.pair for trade in trades if trade.pair not in _whitelist])
return _whitelist return _whitelist
def _create_pair_whitelist(self, pairs: List[str]) -> List[Tuple[str, str]]:
"""
Create pair-whitelist tuple with (pair, ticker_interval)
"""
return [(pair, self.config['ticker_interval']) for pair in pairs]
def get_free_open_trades(self): def get_free_open_trades(self):
""" """
Return the number of free open trades slots or 0 if Return the number of free open trades slots or 0 if