verify date on new candle before producing signal
This commit is contained in:
@@ -277,15 +277,20 @@ class IStrategy(ABC):
|
||||
|
||||
latest = dataframe.iloc[-1]
|
||||
|
||||
# Check if dataframe is out of date
|
||||
# Check if dataframe has new candle
|
||||
signal_date = arrow.get(latest['date'])
|
||||
interval_minutes = timeframe_to_minutes(interval)
|
||||
if (arrow.utcnow() - signal_date).total_seconds() // 60 >= interval_minutes:
|
||||
logger.warning('Old candle for pair %s. Last tick is %s minutes old',
|
||||
pair, (arrow.utcnow() - signal_date).total_seconds() // 60)
|
||||
|
||||
# Check if dataframe is out of date
|
||||
offset = self.config.get('exchange', {}).get('outdated_offset', 5)
|
||||
if signal_date < (arrow.utcnow().shift(minutes=-(interval_minutes * 2 + offset))):
|
||||
logger.warning(
|
||||
'Outdated history for pair %s. Last tick is %s minutes old',
|
||||
pair,
|
||||
(arrow.utcnow() - signal_date).seconds // 60
|
||||
(arrow.utcnow() - signal_date).total_seconds() // 60
|
||||
)
|
||||
return False, False
|
||||
|
||||
|
Reference in New Issue
Block a user