extract get_history_data from get_signal

This commit is contained in:
Matthias 2018-07-26 18:22:23 +01:00
parent 6e437a7290
commit 484103b957
2 changed files with 9 additions and 5 deletions

View File

@ -327,13 +327,18 @@ class FreqtradeBot(object):
if not whitelist: if not whitelist:
raise DependencyException('No currency pairs in 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 # Pick pair based on buy signals
bought_at_least_one = False
for _pair in whitelist: 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: if buy and not sell:
return self.execute_buy(_pair, stake_amount) bought_at_least_one |= self.execute_buy(_pair, stake_amount)
return False return bought_at_least_one
def execute_buy(self, pair: str, stake_amount: float) -> bool: def execute_buy(self, pair: str, stake_amount: float) -> bool:
""" """

View File

@ -107,14 +107,13 @@ class IStrategy(ABC):
dataframe = self.populate_sell_trend(dataframe) dataframe = self.populate_sell_trend(dataframe)
return 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 Calculates current signal based several technical analysis indicators
:param pair: pair in format ANT/BTC :param pair: pair in format ANT/BTC
:param interval: Interval to use (in min) :param interval: Interval to use (in min)
:return: (Buy, Sell) A bool-tuple indicating buy/sell signal :return: (Buy, Sell) A bool-tuple indicating buy/sell signal
""" """
ticker_hist = exchange.get_ticker_history(pair, interval)
if not ticker_hist: if not ticker_hist:
logger.warning('Empty ticker history for pair %s', pair) logger.warning('Empty ticker history for pair %s', pair)
return False, False return False, False