From e45ba60acff910fc37b095edb8451450a60a8458 Mon Sep 17 00:00:00 2001 From: orehunt Date: Sun, 25 Oct 2020 06:47:06 +0100 Subject: [PATCH] add strategy_safe_wrapper --- freqtrade/freqtradebot.py | 3 ++- freqtrade/strategy/interface.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index b56a3550f..00682bd53 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -433,7 +433,8 @@ class FreqtradeBot: Trade.total_open_trades_stakes() ) else: - stake_amount = self.strategy.get_stake_amount(pair) + stake_amount = strategy_safe_wrapper(self.strategy.get_stake_amount, + default_retval=0)(pair) if stake_amount == constants.UNLIMITED_STAKE_AMOUNT: stake_amount = self._calculate_unlimited_stake_amount() diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index c70b4bdd2..2109f0567 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -436,13 +436,13 @@ class IStrategy(ABC): :param pair: pair in format ANT/BTC :param timeframe: timeframe to use :param dataframe: Analyzed dataframe to get signal from. - :return: (Buy, Sell, Date) A tuple indicating buy/sell signal for the latest date + :return: (Buy, Sell) A bool-tuple indicating buy/sell signal """ if not isinstance(dataframe, DataFrame) or dataframe.empty: logger.warning(f'Empty candle (OHLCV) data for pair {pair}') return False, False - latest_date: datetime = dataframe['date'].max() + latest_date = dataframe['date'].max() latest = dataframe.loc[dataframe['date'] == latest_date].iloc[-1] # Explicitly convert to arrow object to ensure the below comparison does not fail latest_date = arrow.get(latest_date) @@ -459,7 +459,7 @@ class IStrategy(ABC): (buy, sell) = latest[SignalType.BUY.value] == 1, latest[SignalType.SELL.value] == 1 logger.debug('trigger: %s (pair=%s) buy=%s sell=%s', - latest['date'], pair, str(buy), str(sell)) + latest['date'], pair, str(buy), str(sell)) return buy, sell def should_sell(self, trade: Trade, rate: float, date: datetime, buy: bool,