Added candle type to ohlcv_get_available_data

This commit is contained in:
Sam Germain 2021-11-20 22:46:47 -06:00
parent b4029533ec
commit 64a6abc541
5 changed files with 31 additions and 17 deletions

View File

@ -161,10 +161,16 @@ def start_list_data(args: Dict[str, Any]) -> None:
print(f"Found {len(paircombs)} pair / timeframe combinations.") print(f"Found {len(paircombs)} pair / timeframe combinations.")
groupedpair = defaultdict(list) groupedpair = defaultdict(list)
for pair, timeframe in sorted(paircombs, key=lambda x: (x[0], timeframe_to_minutes(x[1]))): for pair, timeframe, candle_type in sorted(
groupedpair[pair].append(timeframe) paircombs,
key=lambda x: (x[0], timeframe_to_minutes(x[1]), x[2])
):
groupedpair[(pair, candle_type)].append(timeframe)
if groupedpair: if groupedpair:
print(tabulate([(pair, ', '.join(timeframes)) for pair, timeframes in groupedpair.items()], print(tabulate([
headers=("Pair", "Timeframe"), (pair, ', '.join(timeframes), candle_type)
tablefmt='psql', stralign='right')) for (pair, candle_type), timeframes in groupedpair.items()
],
headers=("Pair", "Timeframe", "Type"),
tablefmt='psql', stralign='right'))

View File

@ -467,7 +467,7 @@ CANCEL_REASON = {
} }
# List of pairs with their timeframes # List of pairs with their timeframes
PairWithTimeframe = Tuple[str, str] PairWithTimeframe = Tuple[str, str, str]
ListPairsWithTimeframes = List[PairWithTimeframe] ListPairsWithTimeframes = List[PairWithTimeframe]
# Type for trades list # Type for trades list

View File

@ -28,9 +28,13 @@ class HDF5DataHandler(IDataHandler):
:param datadir: Directory to search for ohlcv files :param datadir: Directory to search for ohlcv files
:return: List of Tuples of (pair, timeframe) :return: List of Tuples of (pair, timeframe)
""" """
_tmp = [re.search(r'^([a-zA-Z_]+)\-(\d+\S+)(?=.h5)', p.name) _tmp = [
for p in datadir.glob("*.h5")] re.search(
return [(match[1].replace('_', '/'), match[2]) for match in _tmp r'^([a-zA-Z_]+)\-(\d+\S)\-?([a-zA-Z_]*)?(?=.h5)',
p.name
) for p in datadir.glob("*.h5")
]
return [(match[1].replace('_', '/'), match[2], match[3]) for match in _tmp
if match and len(match.groups()) > 1] if match and len(match.groups()) > 1]
@classmethod @classmethod

View File

@ -29,9 +29,12 @@ class JsonDataHandler(IDataHandler):
:param datadir: Directory to search for ohlcv files :param datadir: Directory to search for ohlcv files
:return: List of Tuples of (pair, timeframe) :return: List of Tuples of (pair, timeframe)
""" """
_tmp = [re.search(r'^([a-zA-Z_]+)\-(\d+\S+)(?=.json)', p.name) _tmp = [
for p in datadir.glob(f"*.{cls._get_file_extension()}")] re.search(
return [(match[1].replace('_', '/'), match[2]) for match in _tmp r'^([a-zA-Z_]+)\-(\d+\S)\-?([a-zA-Z_]*)?(?=.json)',
p.name
) for p in datadir.glob(f"*.{cls._get_file_extension()}")]
return [(match[1].replace('_', '/'), match[2], match[3]) for match in _tmp
if match and len(match.groups()) > 1] if match and len(match.groups()) > 1]
@classmethod @classmethod

View File

@ -1326,9 +1326,10 @@ def test_start_list_data(testdatadir, capsys):
pargs['config'] = None pargs['config'] = None
start_list_data(pargs) start_list_data(pargs)
captured = capsys.readouterr() captured = capsys.readouterr()
assert "Found 17 pair / timeframe combinations." in captured.out assert "Found 19 pair / timeframe combinations." in captured.out
assert "\n| Pair | Timeframe |\n" in captured.out assert "\n| Pair | Timeframe | Type |\n" in captured.out
assert "\n| UNITTEST/BTC | 1m, 5m, 8m, 30m |\n" in captured.out assert "\n| UNITTEST/BTC | 1m, 5m, 8m, 30m | |\n" in captured.out
assert "\n| UNITTEST/USDT | 1h | mark |\n" in captured.out
args = [ args = [
"list-data", "list-data",
@ -1343,9 +1344,9 @@ def test_start_list_data(testdatadir, capsys):
start_list_data(pargs) start_list_data(pargs)
captured = capsys.readouterr() captured = capsys.readouterr()
assert "Found 2 pair / timeframe combinations." in captured.out assert "Found 2 pair / timeframe combinations." in captured.out
assert "\n| Pair | Timeframe |\n" in captured.out assert "\n| Pair | Timeframe | Type |\n" in captured.out
assert "UNITTEST/BTC" not in captured.out assert "UNITTEST/BTC" not in captured.out
assert "\n| XRP/ETH | 1m, 5m |\n" in captured.out assert "\n| XRP/ETH | 1m, 5m | |\n" in captured.out
@pytest.mark.usefixtures("init_persistence") @pytest.mark.usefixtures("init_persistence")