Revert unneeded formatting changes
This commit is contained in:
parent
0128b63c1c
commit
3928051baf
@ -30,8 +30,7 @@ class FeatherDataHandler(IDataHandler):
|
|||||||
:param candle_type: Any of the enum CandleType (must match trading mode!)
|
:param candle_type: Any of the enum CandleType (must match trading mode!)
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
filename = self._pair_data_filename(
|
filename = self._pair_data_filename(self._datadir, pair, timeframe, candle_type)
|
||||||
self._datadir, pair, timeframe, candle_type)
|
|
||||||
self.create_dir_if_needed(filename)
|
self.create_dir_if_needed(filename)
|
||||||
|
|
||||||
data.reset_index(drop=True).loc[:, self._columns].to_feather(
|
data.reset_index(drop=True).loc[:, self._columns].to_feather(
|
||||||
|
@ -20,31 +20,25 @@ from tests.conftest import log_has, log_has_re
|
|||||||
|
|
||||||
|
|
||||||
def test_datahandler_ohlcv_get_pairs(testdatadir):
|
def test_datahandler_ohlcv_get_pairs(testdatadir):
|
||||||
pairs = JsonDataHandler.ohlcv_get_pairs(
|
pairs = JsonDataHandler.ohlcv_get_pairs(testdatadir, '5m', candle_type=CandleType.SPOT)
|
||||||
testdatadir, '5m', candle_type=CandleType.SPOT)
|
|
||||||
# Convert to set to avoid failures due to sorting
|
# Convert to set to avoid failures due to sorting
|
||||||
assert set(pairs) == {'UNITTEST/BTC', 'XLM/BTC', 'ETH/BTC', 'TRX/BTC', 'LTC/BTC',
|
assert set(pairs) == {'UNITTEST/BTC', 'XLM/BTC', 'ETH/BTC', 'TRX/BTC', 'LTC/BTC',
|
||||||
'XMR/BTC', 'ZEC/BTC', 'ADA/BTC', 'ETC/BTC', 'NXT/BTC',
|
'XMR/BTC', 'ZEC/BTC', 'ADA/BTC', 'ETC/BTC', 'NXT/BTC',
|
||||||
'DASH/BTC', 'XRP/ETH'}
|
'DASH/BTC', 'XRP/ETH'}
|
||||||
|
|
||||||
pairs = JsonGzDataHandler.ohlcv_get_pairs(
|
pairs = JsonGzDataHandler.ohlcv_get_pairs(testdatadir, '8m', candle_type=CandleType.SPOT)
|
||||||
testdatadir, '8m', candle_type=CandleType.SPOT)
|
|
||||||
assert set(pairs) == {'UNITTEST/BTC'}
|
assert set(pairs) == {'UNITTEST/BTC'}
|
||||||
|
|
||||||
pairs = HDF5DataHandler.ohlcv_get_pairs(
|
pairs = HDF5DataHandler.ohlcv_get_pairs(testdatadir, '5m', candle_type=CandleType.SPOT)
|
||||||
testdatadir, '5m', candle_type=CandleType.SPOT)
|
|
||||||
assert set(pairs) == {'UNITTEST/BTC'}
|
assert set(pairs) == {'UNITTEST/BTC'}
|
||||||
|
|
||||||
pairs = JsonDataHandler.ohlcv_get_pairs(
|
pairs = JsonDataHandler.ohlcv_get_pairs(testdatadir, '1h', candle_type=CandleType.MARK)
|
||||||
testdatadir, '1h', candle_type=CandleType.MARK)
|
|
||||||
assert set(pairs) == {'UNITTEST/USDT:USDT', 'XRP/USDT:USDT'}
|
assert set(pairs) == {'UNITTEST/USDT:USDT', 'XRP/USDT:USDT'}
|
||||||
|
|
||||||
pairs = JsonGzDataHandler.ohlcv_get_pairs(
|
pairs = JsonGzDataHandler.ohlcv_get_pairs(testdatadir, '1h', candle_type=CandleType.FUTURES)
|
||||||
testdatadir, '1h', candle_type=CandleType.FUTURES)
|
|
||||||
assert set(pairs) == {'XRP/USDT:USDT'}
|
assert set(pairs) == {'XRP/USDT:USDT'}
|
||||||
|
|
||||||
pairs = HDF5DataHandler.ohlcv_get_pairs(
|
pairs = HDF5DataHandler.ohlcv_get_pairs(testdatadir, '1h', candle_type=CandleType.MARK)
|
||||||
testdatadir, '1h', candle_type=CandleType.MARK)
|
|
||||||
assert set(pairs) == {'UNITTEST/USDT:USDT'}
|
assert set(pairs) == {'UNITTEST/USDT:USDT'}
|
||||||
|
|
||||||
|
|
||||||
@ -85,8 +79,7 @@ def test_rebuild_pair_from_filename(input, expected):
|
|||||||
|
|
||||||
|
|
||||||
def test_datahandler_ohlcv_get_available_data(testdatadir):
|
def test_datahandler_ohlcv_get_available_data(testdatadir):
|
||||||
paircombs = JsonDataHandler.ohlcv_get_available_data(
|
paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, TradingMode.SPOT)
|
||||||
testdatadir, TradingMode.SPOT)
|
|
||||||
# Convert to set to avoid failures due to sorting
|
# Convert to set to avoid failures due to sorting
|
||||||
assert set(paircombs) == {
|
assert set(paircombs) == {
|
||||||
('UNITTEST/BTC', '5m', CandleType.SPOT),
|
('UNITTEST/BTC', '5m', CandleType.SPOT),
|
||||||
@ -108,8 +101,7 @@ def test_datahandler_ohlcv_get_available_data(testdatadir):
|
|||||||
('NOPAIR/XXX', '4m', CandleType.SPOT),
|
('NOPAIR/XXX', '4m', CandleType.SPOT),
|
||||||
}
|
}
|
||||||
|
|
||||||
paircombs = JsonDataHandler.ohlcv_get_available_data(
|
paircombs = JsonDataHandler.ohlcv_get_available_data(testdatadir, TradingMode.FUTURES)
|
||||||
testdatadir, TradingMode.FUTURES)
|
|
||||||
# Convert to set to avoid failures due to sorting
|
# Convert to set to avoid failures due to sorting
|
||||||
assert set(paircombs) == {
|
assert set(paircombs) == {
|
||||||
('UNITTEST/USDT:USDT', '1h', 'mark'),
|
('UNITTEST/USDT:USDT', '1h', 'mark'),
|
||||||
@ -120,11 +112,9 @@ def test_datahandler_ohlcv_get_available_data(testdatadir):
|
|||||||
('XRP/USDT:USDT', '8h', 'funding_rate'),
|
('XRP/USDT:USDT', '8h', 'funding_rate'),
|
||||||
}
|
}
|
||||||
|
|
||||||
paircombs = JsonGzDataHandler.ohlcv_get_available_data(
|
paircombs = JsonGzDataHandler.ohlcv_get_available_data(testdatadir, TradingMode.SPOT)
|
||||||
testdatadir, TradingMode.SPOT)
|
|
||||||
assert set(paircombs) == {('UNITTEST/BTC', '8m', CandleType.SPOT)}
|
assert set(paircombs) == {('UNITTEST/BTC', '8m', CandleType.SPOT)}
|
||||||
paircombs = HDF5DataHandler.ohlcv_get_available_data(
|
paircombs = HDF5DataHandler.ohlcv_get_available_data(testdatadir, TradingMode.SPOT)
|
||||||
testdatadir, TradingMode.SPOT)
|
|
||||||
assert set(paircombs) == {('UNITTEST/BTC', '5m', CandleType.SPOT)}
|
assert set(paircombs) == {('UNITTEST/BTC', '5m', CandleType.SPOT)}
|
||||||
|
|
||||||
|
|
||||||
@ -416,21 +406,18 @@ def test_hdf5datahandler_ohlcv_load_and_resave(
|
|||||||
|
|
||||||
assert not ohlcv[ohlcv['date'] < startdt].empty
|
assert not ohlcv[ohlcv['date'] < startdt].empty
|
||||||
|
|
||||||
timerange = TimeRange.parse_timerange(
|
timerange = TimeRange.parse_timerange(f"{startdt.replace('-', '')}-{enddt.replace('-', '')}")
|
||||||
f"{startdt.replace('-', '')}-{enddt.replace('-', '')}")
|
|
||||||
|
|
||||||
# Call private function to ensure timerange is filtered in hdf5
|
# Call private function to ensure timerange is filtered in hdf5
|
||||||
ohlcv = dh._ohlcv_load(pair, timeframe, timerange, candle_type=candle_type)
|
ohlcv = dh._ohlcv_load(pair, timeframe, timerange, candle_type=candle_type)
|
||||||
ohlcv1 = dh1._ohlcv_load('UNITTEST/NEW', timeframe,
|
ohlcv1 = dh1._ohlcv_load('UNITTEST/NEW', timeframe, timerange, candle_type=candle_type)
|
||||||
timerange, candle_type=candle_type)
|
|
||||||
assert len(ohlcv) == len(ohlcv1)
|
assert len(ohlcv) == len(ohlcv1)
|
||||||
assert ohlcv.equals(ohlcv1)
|
assert ohlcv.equals(ohlcv1)
|
||||||
assert ohlcv[ohlcv['date'] < startdt].empty
|
assert ohlcv[ohlcv['date'] < startdt].empty
|
||||||
assert ohlcv[ohlcv['date'] > enddt].empty
|
assert ohlcv[ohlcv['date'] > enddt].empty
|
||||||
|
|
||||||
# Try loading inexisting file
|
# Try loading inexisting file
|
||||||
ohlcv = dh.ohlcv_load('UNITTEST/NONEXIST', timeframe,
|
ohlcv = dh.ohlcv_load('UNITTEST/NONEXIST', timeframe, candle_type=candle_type)
|
||||||
candle_type=candle_type)
|
|
||||||
assert ohlcv.empty
|
assert ohlcv.empty
|
||||||
|
|
||||||
|
|
||||||
@ -465,8 +452,7 @@ def test_generic_datahandler_ohlcv_load_and_resave(
|
|||||||
# Get data to test
|
# Get data to test
|
||||||
dh = get_datahandler(testdatadir, datahandler)
|
dh = get_datahandler(testdatadir, datahandler)
|
||||||
|
|
||||||
file = tmpdir2 / \
|
file = tmpdir2 / f"UNITTEST_NEW-{timeframe}{candle_append}.{dh._get_file_extension()}"
|
||||||
f"UNITTEST_NEW-{timeframe}{candle_append}.{dh._get_file_extension()}"
|
|
||||||
assert not file.is_file()
|
assert not file.is_file()
|
||||||
|
|
||||||
dh1 = get_datahandler(tmpdir1, datahandler)
|
dh1 = get_datahandler(tmpdir1, datahandler)
|
||||||
@ -475,14 +461,11 @@ def test_generic_datahandler_ohlcv_load_and_resave(
|
|||||||
|
|
||||||
assert not ohlcv[ohlcv['date'] < startdt].empty
|
assert not ohlcv[ohlcv['date'] < startdt].empty
|
||||||
|
|
||||||
timerange = TimeRange.parse_timerange(
|
timerange = TimeRange.parse_timerange(f"{startdt.replace('-', '')}-{enddt.replace('-', '')}")
|
||||||
f"{startdt.replace('-', '')}-{enddt.replace('-', '')}")
|
|
||||||
|
|
||||||
ohlcv = dhbase.ohlcv_load(
|
ohlcv = dhbase.ohlcv_load(pair, timeframe, timerange=timerange, candle_type=candle_type)
|
||||||
pair, timeframe, timerange=timerange, candle_type=candle_type)
|
|
||||||
if datahandler == 'hdf5':
|
if datahandler == 'hdf5':
|
||||||
ohlcv1 = dh1._ohlcv_load(
|
ohlcv1 = dh1._ohlcv_load('UNITTEST/NEW', timeframe, timerange, candle_type=candle_type)
|
||||||
'UNITTEST/NEW', timeframe, timerange, candle_type=candle_type)
|
|
||||||
if candle_type == 'mark':
|
if candle_type == 'mark':
|
||||||
ohlcv1['volume'] = 0.0
|
ohlcv1['volume'] = 0.0
|
||||||
else:
|
else:
|
||||||
@ -495,8 +478,7 @@ def test_generic_datahandler_ohlcv_load_and_resave(
|
|||||||
assert ohlcv[ohlcv['date'] > enddt].empty
|
assert ohlcv[ohlcv['date'] > enddt].empty
|
||||||
|
|
||||||
# Try loading inexisting file
|
# Try loading inexisting file
|
||||||
ohlcv = dh.ohlcv_load('UNITTEST/NONEXIST', timeframe,
|
ohlcv = dh.ohlcv_load('UNITTEST/NONEXIST', timeframe, candle_type=candle_type)
|
||||||
candle_type=candle_type)
|
|
||||||
assert ohlcv.empty
|
assert ohlcv.empty
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user