diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 3527fba81..08eda2843 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -327,13 +327,18 @@ class FreqtradeBot(object): if not whitelist: raise DependencyException('No currency pairs in whitelist') + th = {} + for _pair in whitelist: + th[_pair] = self.exchange.get_ticker_history(_pair, interval) # Pick pair based on buy signals + bought_at_least_one = False for _pair in whitelist: - (buy, sell) = self.strategy.get_signal(self.exchange, _pair, interval) + (buy, sell) = self.strategy.get_signal(_pair, interval, th[_pair]) + if buy and not sell: - return self.execute_buy(_pair, stake_amount) - return False + bought_at_least_one |= self.execute_buy(_pair, stake_amount) + return bought_at_least_one def execute_buy(self, pair: str, stake_amount: float) -> bool: """ diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 9120d3e04..23b0563a2 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -107,14 +107,13 @@ class IStrategy(ABC): dataframe = self.populate_sell_trend(dataframe) return dataframe - def get_signal(self, exchange: Exchange, pair: str, interval: str) -> Tuple[bool, bool]: + def get_signal(self, pair: str, interval: str, ticker_hist: List[Dict]) -> Tuple[bool, bool]: """ Calculates current signal based several technical analysis indicators :param pair: pair in format ANT/BTC :param interval: Interval to use (in min) :return: (Buy, Sell) A bool-tuple indicating buy/sell signal """ - ticker_hist = exchange.get_ticker_history(pair, interval) if not ticker_hist: logger.warning('Empty ticker history for pair %s', pair) return False, False