diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index f9f7dd9a1..912425d14 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -2136,6 +2136,21 @@ def test___now_is_time_to_refresh(default_conf, mocker, exchange_name, time_mach time_machine.move_to(start_dt + timedelta(minutes=5, seconds=1), tick=False) assert exchange._now_is_time_to_refresh(pair, "5m", candle_type) is True + # Test with 1d data + start_day_dt = datetime(2023, 12, 1, 0, 0, 0, tzinfo=timezone.utc) + last_closed_candle_1d = dt_ts(start_day_dt - timedelta(days=1)) + exchange._pairs_last_refresh_time[(pair, "1d", candle_type)] = last_closed_candle_1d + + time_machine.move_to(start_day_dt - timedelta(seconds=5), tick=False) + assert exchange._now_is_time_to_refresh(pair, "1d", candle_type) is False + + time_machine.move_to(start_day_dt + timedelta(hours=20, seconds=5), tick=False) + assert exchange._now_is_time_to_refresh(pair, "1d", candle_type) is False + + # Next candle closed - now we refresh. + time_machine.move_to(start_day_dt + timedelta(days=1, seconds=0), tick=False) + assert exchange._now_is_time_to_refresh(pair, "1d", candle_type) is True + @pytest.mark.parametrize("candle_type", ["mark", ""]) @pytest.mark.parametrize("exchange_name", EXCHANGES)