From 3f266e8c8cfafbcef39f87b06131294604f3e3eb Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 10 Dec 2021 06:46:35 +0100 Subject: [PATCH] Improve ccxt_mark_price_test --- tests/exchange/test_ccxt_compat.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/exchange/test_ccxt_compat.py b/tests/exchange/test_ccxt_compat.py index 8710463a6..0dda4ce52 100644 --- a/tests/exchange/test_ccxt_compat.py +++ b/tests/exchange/test_ccxt_compat.py @@ -213,24 +213,29 @@ class TestCCXTExchange(): assert rate[int(this_hour.timestamp() * 1000)] != 0.0 assert rate[int(prev_tick.timestamp() * 1000)] != 0.0 - @pytest.mark.skip("No futures support yet") - def test_fetch_mark_price_history(self, exchange_futures): + def test_ccxt_fetch_mark_price_history(self, exchange_futures): exchange, exchangename = exchange_futures if not exchange: # exchange_futures only returns values for supported exchanges return pair = EXCHANGES[exchangename].get('futures_pair', EXCHANGES[exchangename]['pair']) since = int((datetime.now(timezone.utc) - timedelta(days=5)).timestamp() * 1000) + pair_tf = (pair, '1h', CandleType.MARK) - mark_candles = exchange._get_mark_price_history(pair, since) + mark_ohlcv = exchange.refresh_latest_ohlcv( + [pair_tf], + since_ms=since, + drop_incomplete=False) - assert isinstance(mark_candles, dict) + assert isinstance(mark_ohlcv, dict) expected_tf = '1h' + mark_candles = mark_ohlcv[pair_tf] this_hour = timeframe_to_prev_date(expected_tf) - prev_tick = timeframe_to_prev_date(expected_tf, this_hour - timedelta(minutes=1)) - assert mark_candles[int(this_hour.timestamp() * 1000)] != 0.0 - assert mark_candles[int(prev_tick.timestamp() * 1000)] != 0.0 + prev_hour = timeframe_to_prev_date(expected_tf, this_hour - timedelta(minutes=1)) + + assert mark_candles[mark_candles['date'] == prev_hour].iloc[0]['open'] != 0.0 + assert mark_candles[mark_candles['date'] == this_hour].iloc[0]['open'] != 0.0 # TODO: tests fetch_trades (?)