From b3afca2a9d47c69bb79d8ea5e573e412bb442e1c Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 14 Nov 2021 13:37:09 +0100 Subject: [PATCH] Improve ccxt_compat test for funding rate --- tests/exchange/test_ccxt_compat.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/exchange/test_ccxt_compat.py b/tests/exchange/test_ccxt_compat.py index c3aee7e92..b14df070c 100644 --- a/tests/exchange/test_ccxt_compat.py +++ b/tests/exchange/test_ccxt_compat.py @@ -49,11 +49,16 @@ EXCHANGES = { 'hasQuoteVolume': True, 'timeframe': '5m', 'futures': True, + 'futures_fundingrate_tf': '8h', + 'futures_pair': 'BTC/USDT:USDT', }, 'okex': { 'pair': 'BTC/USDT', 'hasQuoteVolume': True, 'timeframe': '5m', + 'futures_fundingrate_tf': '8h', + 'futures_pair': 'BTC/USDT:USDT', + 'futures': True, }, } @@ -178,10 +183,11 @@ class TestCCXTExchange(): rate = exchange.get_funding_rate_history(pair, since) assert isinstance(rate, dict) - this_hour = timeframe_to_prev_date('1h') - prev_hour = this_hour - timedelta(hours=1) + expected_tf = EXCHANGES[exchangename].get('futures_fundingrate_tf', '1h') + this_hour = timeframe_to_prev_date(expected_tf) + prev_tick = timeframe_to_prev_date(expected_tf, this_hour - timedelta(minutes=1)) assert rate[int(this_hour.timestamp() * 1000)] != 0.0 - assert rate[int(prev_hour.timestamp() * 1000)] != 0.0 + assert rate[int(prev_tick.timestamp() * 1000)] != 0.0 # TODO: tests fetch_trades (?)