Price-jump detection should only run once

This commit is contained in:
Matthias 2022-10-22 08:43:37 +02:00
parent 0ff7a0771d
commit 547fd28811
2 changed files with 10 additions and 9 deletions

View File

@ -303,7 +303,7 @@ class IDataHandler(ABC):
timerange=timerange_startup, timerange=timerange_startup,
candle_type=candle_type candle_type=candle_type
) )
if self._check_empty_df(pairdf, pair, timeframe, candle_type, warn_no_data): if self._check_empty_df(pairdf, pair, timeframe, candle_type, warn_no_data, True):
return pairdf return pairdf
else: else:
enddate = pairdf.iloc[-1]['date'] enddate = pairdf.iloc[-1]['date']
@ -323,8 +323,9 @@ class IDataHandler(ABC):
self._check_empty_df(pairdf, pair, timeframe, candle_type, warn_no_data) self._check_empty_df(pairdf, pair, timeframe, candle_type, warn_no_data)
return pairdf return pairdf
def _check_empty_df(self, pairdf: DataFrame, pair: str, timeframe: str, def _check_empty_df(
candle_type: CandleType, warn_no_data: bool): self, pairdf: DataFrame, pair: str, timeframe: str, candle_type: CandleType,
warn_no_data: bool, warn_price: bool = False) -> bool:
""" """
Warn on empty dataframe Warn on empty dataframe
""" """
@ -335,7 +336,7 @@ class IDataHandler(ABC):
"Use `freqtrade download-data` to download the data" "Use `freqtrade download-data` to download the data"
) )
return True return True
else: elif warn_price:
candle_price_gap = 0 candle_price_gap = 0
if (candle_type in (CandleType.SPOT, CandleType.FUTURES) and if (candle_type in (CandleType.SPOT, CandleType.FUTURES) and
not pairdf.empty not pairdf.empty
@ -346,8 +347,8 @@ class IDataHandler(ABC):
if len(gaps): if len(gaps):
candle_price_gap = max(abs(gaps)) candle_price_gap = max(abs(gaps))
if candle_price_gap > 0.1: if candle_price_gap > 0.1:
logger.info(f"Price jump in {pair} between two candles of " logger.info(f"Price jump in {pair}, {timeframe}, {candle_type} between two candles "
f"{candle_price_gap:.2%} detected.") f"of {candle_price_gap:.2%} detected.")
return False return False

View File

@ -156,7 +156,7 @@ def test_jsondatahandler_ohlcv_load(testdatadir, caplog):
def test_datahandler__check_empty_df(testdatadir, caplog): def test_datahandler__check_empty_df(testdatadir, caplog):
dh = JsonDataHandler(testdatadir) dh = JsonDataHandler(testdatadir)
expected_text = r"Price jump in UNITTEST/USDT between" expected_text = r"Price jump in UNITTEST/USDT, 1h, spot between"
df = DataFrame([ df = DataFrame([
[ [
1511686200000, # 8:50:00 1511686200000, # 8:50:00
@ -192,7 +192,7 @@ def test_datahandler__check_empty_df(testdatadir, caplog):
] ]
], columns=['date', 'open', 'high', 'low', 'close', 'volume']) ], columns=['date', 'open', 'high', 'low', 'close', 'volume'])
dh._check_empty_df(df, 'UNITTEST/USDT', '1h', CandleType.SPOT, True) dh._check_empty_df(df, 'UNITTEST/USDT', '1h', CandleType.SPOT, True, True)
assert not log_has_re(expected_text, caplog) assert not log_has_re(expected_text, caplog)
df = DataFrame([ df = DataFrame([
[ [
@ -229,7 +229,7 @@ def test_datahandler__check_empty_df(testdatadir, caplog):
] ]
], columns=['date', 'open', 'high', 'low', 'close', 'volume']) ], columns=['date', 'open', 'high', 'low', 'close', 'volume'])
dh._check_empty_df(df, 'UNITTEST/USDT', '1h', CandleType.SPOT, True) dh._check_empty_df(df, 'UNITTEST/USDT', '1h', CandleType.SPOT, True, True)
assert log_has_re(expected_text, caplog) assert log_has_re(expected_text, caplog)