From 60cb11a44d30c92b87117e21b12ac73f2cbb349d Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 20 Oct 2022 19:36:28 +0200 Subject: [PATCH] Add price jump warning --- docs/faq.md | 6 ++++++ freqtrade/data/converter.py | 8 ++++++++ tests/data/test_converter.py | 9 +++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index a72268ef9..bcceaf898 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -102,6 +102,12 @@ If this happens for all pairs in the pairlist, this might indicate a recent exch Irrespectively of the reason, Freqtrade will fill up these candles with "empty" candles, where open, high, low and close are set to the previous candle close - and volume is empty. In a chart, this will look like a `_` - and is aligned with how exchanges usually represent 0 volume candles. +### I'm getting "Price jump between 2 candles detected" + +This message is a warning that the candles had a price jump of > 30%. +This might be a sign that the pair stopped trading, and some token exchange took place (e.g. COCOS in 2021 - where price jumped from 0.0000154 to 0.01621). +This message is often accompanied by ["Missing data fillup"](#im-getting-missing-data-fillup-messages-in-the-log) - as trading on such pairs is often stopped for some time. + ### I'm getting "Outdated history for pair xxx" in the log The bot is trying to tell you that it got an outdated last candle (not the last complete candle). diff --git a/freqtrade/data/converter.py b/freqtrade/data/converter.py index 98ed15489..7f7e79445 100644 --- a/freqtrade/data/converter.py +++ b/freqtrade/data/converter.py @@ -119,6 +119,14 @@ def ohlcv_fill_up_missing_data(dataframe: DataFrame, timeframe: str, pair: str) else: # Don't be verbose if only a small amount is missing logger.debug(message) + candle_price_gap = 0 + if not df.empty and 'close' in df.columns: + returns = df['close'].pct_change().dropna() + if len(returns): + candle_price_gap = max(abs(returns)) + if candle_price_gap > 0.3: + logger.info(f"Price jump in {pair} between two candles of {candle_price_gap:.2%} detected.") + return df diff --git a/tests/data/test_converter.py b/tests/data/test_converter.py index f74383d15..83429bb38 100644 --- a/tests/data/test_converter.py +++ b/tests/data/test_converter.py @@ -80,10 +80,10 @@ def test_ohlcv_fill_up_missing_data2(caplog): ticks = [ [ 1511686200000, # 8:50:00 - 8.794e-05, # open - 8.948e-05, # high - 8.794e-05, # low - 8.88e-05, # close + 8.794e-07, # open + 8.948e-07, # high + 8.794e-07, # low + 8.88e-07, # close 2255, # volume (in quote currency) ], [ @@ -118,6 +118,7 @@ def test_ohlcv_fill_up_missing_data2(caplog): assert len(data) == 3 caplog.set_level(logging.DEBUG) data2 = ohlcv_fill_up_missing_data(data, timeframe, "UNITTEST/BTC") + assert log_has_re(r"Price jump in .* between two candles .* detected\.", caplog) assert len(data2) == 4 # 3rd candle has been filled row = data2.loc[2, :]