don't flag data as outdated which isn't
This commit is contained in:
parent
7c8c8e83d3
commit
8dd6e29426
@ -2,7 +2,7 @@
|
|||||||
Functions to analyze ticker data with indicators and produce buy and sell signals
|
Functions to analyze ticker data with indicators and produce buy and sell signals
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Dict, List, Tuple
|
from typing import Dict, List, Tuple
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class Analyze(object):
|
|||||||
# Check if dataframe is out of date
|
# Check if dataframe is out of date
|
||||||
signal_date = arrow.get(latest['date'])
|
signal_date = arrow.get(latest['date'])
|
||||||
interval_minutes = constants.TICKER_INTERVAL_MINUTES[interval]
|
interval_minutes = constants.TICKER_INTERVAL_MINUTES[interval]
|
||||||
if signal_date < (arrow.utcnow() - timedelta(minutes=(interval_minutes + 5))):
|
if signal_date < (arrow.utcnow().shift(minutes=-(interval_minutes * 2 + 5))):
|
||||||
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,
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
Unit test file for analyse.py
|
Unit test file for analyse.py
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
|
||||||
import logging
|
import logging
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
@ -148,8 +147,9 @@ def test_get_signal_old_dataframe(default_conf, mocker, caplog):
|
|||||||
caplog.set_level(logging.INFO)
|
caplog.set_level(logging.INFO)
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_ticker_history', return_value=1)
|
mocker.patch('freqtrade.exchange.Exchange.get_ticker_history', return_value=1)
|
||||||
exchange = get_patched_exchange(mocker, default_conf)
|
exchange = get_patched_exchange(mocker, default_conf)
|
||||||
# FIX: The get_signal function has hardcoded 10, which we must inturn hardcode
|
# default_conf defines a 5m interval. we check interval * 2 + 5m
|
||||||
oldtime = arrow.utcnow() - datetime.timedelta(minutes=11)
|
# this is necessary as the last candle is removed (partial candles) by default
|
||||||
|
oldtime = arrow.utcnow().shift(minutes=-16)
|
||||||
ticks = DataFrame([{'buy': 1, 'date': oldtime}])
|
ticks = DataFrame([{'buy': 1, 'date': oldtime}])
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.analyze.Analyze',
|
'freqtrade.analyze.Analyze',
|
||||||
@ -159,7 +159,7 @@ def test_get_signal_old_dataframe(default_conf, mocker, caplog):
|
|||||||
)
|
)
|
||||||
assert (False, False) == _ANALYZE.get_signal(exchange, 'xyz', default_conf['ticker_interval'])
|
assert (False, False) == _ANALYZE.get_signal(exchange, 'xyz', default_conf['ticker_interval'])
|
||||||
assert log_has(
|
assert log_has(
|
||||||
'Outdated history for pair xyz. Last tick is 11 minutes old',
|
'Outdated history for pair xyz. Last tick is 16 minutes old',
|
||||||
caplog.record_tuples
|
caplog.record_tuples
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user