verify date on new candle before producing signal
This commit is contained in:
parent
84f0bb9a5d
commit
54bde6ac11
@ -390,14 +390,17 @@ class FreqtradeBot:
|
|||||||
"""
|
"""
|
||||||
logger.debug(f"create_trade for pair {pair}")
|
logger.debug(f"create_trade for pair {pair}")
|
||||||
|
|
||||||
|
dataframe = self.dataprovider.ohlcv(pair, self.strategy.ticker_interval)
|
||||||
|
latest = dataframe.iloc[-1]
|
||||||
|
# Check if dataframe is out of date
|
||||||
|
signal_date = arrow.get(latest['date'])
|
||||||
|
|
||||||
if self.strategy.is_pair_locked(pair):
|
if self.strategy.is_pair_locked(pair):
|
||||||
logger.info(f"Pair {pair} is currently locked.")
|
logger.info(f"Pair {pair} is currently locked.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# running get_signal on historical data fetched
|
# running get_signal on historical data fetched
|
||||||
(buy, sell) = self.strategy.get_signal(
|
(buy, sell) = self.strategy.get_signal(pair, self.strategy.ticker_interval, dataframe)
|
||||||
pair, self.strategy.ticker_interval,
|
|
||||||
self.dataprovider.ohlcv(pair, self.strategy.ticker_interval))
|
|
||||||
|
|
||||||
if buy and not sell:
|
if buy and not sell:
|
||||||
if not self.get_free_open_trades():
|
if not self.get_free_open_trades():
|
||||||
|
@ -277,15 +277,20 @@ class IStrategy(ABC):
|
|||||||
|
|
||||||
latest = dataframe.iloc[-1]
|
latest = dataframe.iloc[-1]
|
||||||
|
|
||||||
# Check if dataframe is out of date
|
# Check if dataframe has new candle
|
||||||
signal_date = arrow.get(latest['date'])
|
signal_date = arrow.get(latest['date'])
|
||||||
interval_minutes = timeframe_to_minutes(interval)
|
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)
|
offset = self.config.get('exchange', {}).get('outdated_offset', 5)
|
||||||
if signal_date < (arrow.utcnow().shift(minutes=-(interval_minutes * 2 + offset))):
|
if signal_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() - signal_date).total_seconds() // 60
|
||||||
)
|
)
|
||||||
return False, False
|
return False, False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user