mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
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}")
|
||||
|
||||
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):
|
||||
logger.info(f"Pair {pair} is currently locked.")
|
||||
return False
|
||||
|
||||
# running get_signal on historical data fetched
|
||||
(buy, sell) = self.strategy.get_signal(
|
||||
pair, self.strategy.ticker_interval,
|
||||
self.dataprovider.ohlcv(pair, self.strategy.ticker_interval))
|
||||
(buy, sell) = self.strategy.get_signal(pair, self.strategy.ticker_interval, dataframe)
|
||||
|
||||
if buy and not sell:
|
||||
if not self.get_free_open_trades():
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user