From 293ffeae67135fd767090070aef638c89f9d45ed Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 3 Jan 2022 20:18:43 +0100 Subject: [PATCH] Fix random test failure in funding test --- tests/exchange/test_ccxt_compat.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/exchange/test_ccxt_compat.py b/tests/exchange/test_ccxt_compat.py index 122e6e37c..fff565152 100644 --- a/tests/exchange/test_ccxt_compat.py +++ b/tests/exchange/test_ccxt_compat.py @@ -215,9 +215,19 @@ class TestCCXTExchange(): rate = funding_ohlcv[pair_tf] this_hour = timeframe_to_prev_date(timeframe_ff) - prev_hour = timeframe_to_prev_date(timeframe_ff, this_hour - timedelta(minutes=1)) - assert rate[rate['date'] == this_hour].iloc[0]['open'] != 0.0 - assert rate[rate['date'] == prev_hour].iloc[0]['open'] != 0.0 + hour1 = timeframe_to_prev_date(timeframe_ff, this_hour - timedelta(minutes=1)) + hour2 = timeframe_to_prev_date(timeframe_ff, hour1 - timedelta(minutes=1)) + hour3 = timeframe_to_prev_date(timeframe_ff, hour2 - timedelta(minutes=1)) + val0 = rate[rate['date'] == this_hour].iloc[0]['open'] + val1 = rate[rate['date'] == hour1].iloc[0]['open'] + val2 = rate[rate['date'] == hour2].iloc[0]['open'] + val3 = rate[rate['date'] == hour3].iloc[0]['open'] + + # Test For last 4 hours + # Avoids random test-failure when funding-fees are 0 for a few hours. + assert val0 != 0.0 or val1 != 0.0 or val2 != 0.0 or val3 != 0.0 + assert rate['open'].max() != 0.0 + assert rate['open'].min() != rate['open'].max() def test_ccxt_fetch_mark_price_history(self, exchange_futures): exchange, exchangename = exchange_futures