Minor: cleanup in get_signal()

This commit is contained in:
hroff-1902 2020-05-19 22:20:53 +03:00
parent d438af342c
commit a8b1dcf3c8

View File

@ -310,7 +310,6 @@ class IStrategy(ABC):
logger.warning('Empty candle (OHLCV) data for pair %s', pair) logger.warning('Empty candle (OHLCV) data for pair %s', pair)
return False, False return False, False
latest_date = dataframe['date'].max()
try: try:
df_len, df_close, df_date = self.preserve_df(dataframe) df_len, df_close, df_date = self.preserve_df(dataframe)
dataframe = strategy_safe_wrapper( dataframe = strategy_safe_wrapper(
@ -326,17 +325,17 @@ class IStrategy(ABC):
logger.warning('Empty dataframe for pair %s', pair) logger.warning('Empty dataframe for pair %s', pair)
return False, False return False, False
latest_date = dataframe['date'].max()
latest = dataframe.loc[dataframe['date'] == latest_date].iloc[-1] latest = dataframe.loc[dataframe['date'] == latest_date].iloc[-1]
# Check if dataframe is out of date # Check if dataframe is out of date
signal_date = arrow.get(latest['date'])
interval_minutes = timeframe_to_minutes(interval) interval_minutes = timeframe_to_minutes(interval)
offset = self.config.get('exchange', {}).get('outdated_offset', 5) offset = self.config.get('exchange', {}).get('outdated_offset', 5)
if signal_date < (arrow.utcnow().shift(minutes=-(interval_minutes * 2 + offset))): if latest_date < (arrow.utcnow().shift(minutes=-(interval_minutes * 2 + offset))):
logger.warning( logger.warning(
'Outdated history for pair %s. Last tick is %s minutes old', 'Outdated history for pair %s. Last tick is %s minutes old',
pair, pair,
(arrow.utcnow() - signal_date).seconds // 60 (arrow.utcnow() - latest_date).seconds // 60
) )
return False, False return False, False