From 37b013c1573630c06b79bb23543c04782af3eec6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 7 Dec 2021 19:49:48 +0100 Subject: [PATCH] Update hdf5 test --- tests/data/test_history.py | 29 ++++++++++-------- .../testdata/futures/UNITTEST_USDT-1h-mark.h5 | Bin 0 -> 37751 bytes 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 tests/testdata/futures/UNITTEST_USDT-1h-mark.h5 diff --git a/tests/data/test_history.py b/tests/data/test_history.py index b95757561..18f9dc194 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -902,10 +902,11 @@ def test_hdf5datahandler_trades_purge(mocker, testdatadir): assert unlinkmock.call_count == 1 -@pytest.mark.parametrize('pair, timeframe, candle_type, candle_append', [ - ('UNITTEST/BTC', '5m', '', ''), - # TODO-lev: The test below - # ('UNITTEST/USDT', '1h', 'mark', '-mark'), +@pytest.mark.parametrize('pair,timeframe,candle_type,candle_append,startdt,enddt', [ + # Data goes from 2018-01-10 - 2018-01-30 + ('UNITTEST/BTC', '5m', '', '', '2018-01-15', '2018-01-19'), + # Mark data goes from to 2021-11-15 2021-11-19 + ('UNITTEST/USDT', '1h', 'mark', '-mark', '2021-11-16', '2021-11-18'), ]) def test_hdf5datahandler_ohlcv_load_and_resave( testdatadir, @@ -913,33 +914,37 @@ def test_hdf5datahandler_ohlcv_load_and_resave( pair, timeframe, candle_type, - candle_append + candle_append, + startdt, enddt ): tmpdir1 = Path(tmpdir) + tmpdir2 = tmpdir1 + if candle_type not in ('', 'spot'): + tmpdir2 = tmpdir1 / 'futures' + tmpdir2.mkdir() dh = HDF5DataHandler(testdatadir) - ohlcv = dh.ohlcv_load(pair, timeframe, candle_type=candle_type) + ohlcv = dh._ohlcv_load(pair, timeframe, candle_type=candle_type) assert isinstance(ohlcv, DataFrame) assert len(ohlcv) > 0 - file = tmpdir1 / f"UNITTEST_NEW-{timeframe}{candle_append}.h5" + file = tmpdir2 / f"UNITTEST_NEW-{timeframe}{candle_append}.h5" assert not file.is_file() dh1 = HDF5DataHandler(tmpdir1) dh1.ohlcv_store('UNITTEST/NEW', timeframe, ohlcv, candle_type=candle_type) assert file.is_file() - assert not ohlcv[ohlcv['date'] < '2018-01-15'].empty + assert not ohlcv[ohlcv['date'] < startdt].empty - # Data gores from 2018-01-10 - 2018-01-30 - timerange = TimeRange.parse_timerange('20180115-20180119') + timerange = TimeRange.parse_timerange(f"{startdt.replace('-', '')}-{enddt.replace('-', '')}") # Call private function to ensure timerange is filtered in hdf5 ohlcv = dh._ohlcv_load(pair, timeframe, timerange, candle_type=candle_type) ohlcv1 = dh1._ohlcv_load('UNITTEST/NEW', timeframe, timerange, candle_type=candle_type) assert len(ohlcv) == len(ohlcv1) assert ohlcv.equals(ohlcv1) - assert ohlcv[ohlcv['date'] < '2018-01-15'].empty - assert ohlcv[ohlcv['date'] > '2018-01-19'].empty + assert ohlcv[ohlcv['date'] < startdt].empty + assert ohlcv[ohlcv['date'] > enddt].empty # Try loading inexisting file ohlcv = dh.ohlcv_load('UNITTEST/NONEXIST', timeframe, candle_type=candle_type) diff --git a/tests/testdata/futures/UNITTEST_USDT-1h-mark.h5 b/tests/testdata/futures/UNITTEST_USDT-1h-mark.h5 new file mode 100644 index 0000000000000000000000000000000000000000..ce17eb9e104af3472fbdb121cd4453a34bad6088 GIT binary patch literal 37751 zcmeG_2V4}#*Lxfyo^(XOwr5lV7McZ7z(aZ!>0*Hcjt+N$quLNfQHUZ$L}LYGz+Mpn z6)c!&RP2fhh#d<8_JDjdyE}IWh)NRw$)`8JA3Hnc&6|1e&6~F~Z;r**=9aRIJ`4;7 zX=zLnQy^Z^qm>G=nPd)1qjDeWg+|3GRGcS4zR)l!43?=;`3h9~OgfoSL*=_VTUcPA zCTbtWR54a6MZQU+3~~HTQNY^5)CmsQlNvRWr{5?!L&R`%v~hK{aB)RxB$q6d(ZyJi zlGpZfErT(MmY{sYS>tNsY7Yb$QwGxq;so6ydM1Nuiqw9tGEpXcN&B%}<~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