add strategy_safe_wrapper
This commit is contained in:
parent
bc143a5b68
commit
e45ba60acf
@ -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()
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user