feat: Update list-pairs command to use rich tables
This commit is contained in:
@@ -16,6 +16,7 @@ from freqtrade.exceptions import ConfigurationError
|
|||||||
from freqtrade.exchange import timeframe_to_minutes
|
from freqtrade.exchange import timeframe_to_minutes
|
||||||
from freqtrade.plugins.pairlist.pairlist_helpers import dynamic_expand_pairlist
|
from freqtrade.plugins.pairlist.pairlist_helpers import dynamic_expand_pairlist
|
||||||
from freqtrade.resolvers import ExchangeResolver
|
from freqtrade.resolvers import ExchangeResolver
|
||||||
|
from freqtrade.util import print_rich_table
|
||||||
from freqtrade.util.migrations import migrate_data
|
from freqtrade.util.migrations import migrate_data
|
||||||
|
|
||||||
|
|
||||||
@@ -119,8 +120,6 @@ def start_list_data(args: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
|
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
|
||||||
|
|
||||||
from tabulate import tabulate
|
|
||||||
|
|
||||||
from freqtrade.data.history import get_datahandler
|
from freqtrade.data.history import get_datahandler
|
||||||
|
|
||||||
dhc = get_datahandler(config["datadir"], config["dataformat_ohlcv"])
|
dhc = get_datahandler(config["datadir"], config["dataformat_ohlcv"])
|
||||||
@@ -131,8 +130,7 @@ def start_list_data(args: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
if args["pairs"]:
|
if args["pairs"]:
|
||||||
paircombs = [comb for comb in paircombs if comb[0] in args["pairs"]]
|
paircombs = [comb for comb in paircombs if comb[0] in args["pairs"]]
|
||||||
|
title = f"Found {len(paircombs)} pair / timeframe combinations."
|
||||||
print(f"Found {len(paircombs)} pair / timeframe combinations.")
|
|
||||||
if not config.get("show_timerange"):
|
if not config.get("show_timerange"):
|
||||||
groupedpair = defaultdict(list)
|
groupedpair = defaultdict(list)
|
||||||
for pair, timeframe, candle_type in sorted(
|
for pair, timeframe, candle_type in sorted(
|
||||||
@@ -141,40 +139,35 @@ def start_list_data(args: Dict[str, Any]) -> None:
|
|||||||
groupedpair[(pair, candle_type)].append(timeframe)
|
groupedpair[(pair, candle_type)].append(timeframe)
|
||||||
|
|
||||||
if groupedpair:
|
if groupedpair:
|
||||||
print(
|
print_rich_table(
|
||||||
tabulate(
|
[
|
||||||
[
|
(pair, ", ".join(timeframes), candle_type)
|
||||||
(pair, ", ".join(timeframes), candle_type)
|
for (pair, candle_type), timeframes in groupedpair.items()
|
||||||
for (pair, candle_type), timeframes in groupedpair.items()
|
],
|
||||||
],
|
("Pair", "Timeframe", "Type"),
|
||||||
headers=("Pair", "Timeframe", "Type"),
|
title,
|
||||||
tablefmt="psql",
|
table_kwargs={"min_width": 50},
|
||||||
stralign="right",
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
paircombs1 = [
|
paircombs1 = [
|
||||||
(pair, timeframe, candle_type, *dhc.ohlcv_data_min_max(pair, timeframe, candle_type))
|
(pair, timeframe, candle_type, *dhc.ohlcv_data_min_max(pair, timeframe, candle_type))
|
||||||
for pair, timeframe, candle_type in paircombs
|
for pair, timeframe, candle_type in paircombs
|
||||||
]
|
]
|
||||||
|
print_rich_table(
|
||||||
print(
|
[
|
||||||
tabulate(
|
(
|
||||||
[
|
pair,
|
||||||
(
|
timeframe,
|
||||||
pair,
|
candle_type,
|
||||||
timeframe,
|
start.strftime(DATETIME_PRINT_FORMAT),
|
||||||
candle_type,
|
end.strftime(DATETIME_PRINT_FORMAT),
|
||||||
start.strftime(DATETIME_PRINT_FORMAT),
|
str(length),
|
||||||
end.strftime(DATETIME_PRINT_FORMAT),
|
)
|
||||||
length,
|
for pair, timeframe, candle_type, start, end, length in sorted(
|
||||||
)
|
paircombs1, key=lambda x: (x[0], timeframe_to_minutes(x[1]), x[2])
|
||||||
for pair, timeframe, candle_type, start, end, length in sorted(
|
)
|
||||||
paircombs1, key=lambda x: (x[0], timeframe_to_minutes(x[1]), x[2])
|
],
|
||||||
)
|
("Pair", "Timeframe", "Type", "From", "To", "Candles"),
|
||||||
],
|
summary=title,
|
||||||
headers=("Pair", "Timeframe", "Type", "From", "To", "Candles"),
|
table_kwargs={"min_width": 50},
|
||||||
tablefmt="psql",
|
|
||||||
stralign="right",
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1633,8 +1633,8 @@ def test_start_list_data(testdatadir, capsys):
|
|||||||
start_list_data(pargs)
|
start_list_data(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert "Found 16 pair / timeframe combinations." in captured.out
|
assert "Found 16 pair / timeframe combinations." in captured.out
|
||||||
assert "\n| Pair | Timeframe | Type |\n" in captured.out
|
assert re.search(r".*Pair.*Timeframe.*Type.*\n", captured.out)
|
||||||
assert "\n| UNITTEST/BTC | 1m, 5m, 8m, 30m | spot |\n" in captured.out
|
assert re.search(r"\n.* UNITTEST/BTC .* 1m, 5m, 8m, 30m .* spot |\n", captured.out)
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"list-data",
|
"list-data",
|
||||||
@@ -1650,9 +1650,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 | Type |\n" in captured.out
|
assert re.search(r".*Pair.*Timeframe.*Type.*\n", captured.out)
|
||||||
assert "UNITTEST/BTC" not in captured.out
|
assert "UNITTEST/BTC" not in captured.out
|
||||||
assert "\n| XRP/ETH | 1m, 5m | spot |\n" in captured.out
|
assert re.search(r"\n.* XRP/ETH .* 1m, 5m .* spot |\n", captured.out)
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"list-data",
|
"list-data",
|
||||||
@@ -1667,9 +1667,9 @@ def test_start_list_data(testdatadir, capsys):
|
|||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
|
|
||||||
assert "Found 6 pair / timeframe combinations." in captured.out
|
assert "Found 6 pair / timeframe combinations." in captured.out
|
||||||
assert "\n| Pair | Timeframe | Type |\n" in captured.out
|
assert re.search(r".*Pair.*Timeframe.*Type.*\n", captured.out)
|
||||||
assert "\n| XRP/USDT:USDT | 5m, 1h | futures |\n" in captured.out
|
assert re.search(r"\n.* XRP/USDT:USDT .* 5m, 1h .* futures |\n", captured.out)
|
||||||
assert "\n| XRP/USDT:USDT | 1h, 8h | mark |\n" in captured.out
|
assert re.search(r"\n.* XRP/USDT:USDT .* 1h, 8h .* mark |\n", captured.out)
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"list-data",
|
"list-data",
|
||||||
@@ -1684,15 +1684,12 @@ 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 (
|
assert re.search(r".*Pair.*Timeframe.*Type.*From .* To .* Candles .*\n", captured.out)
|
||||||
"\n| Pair | Timeframe | Type "
|
|
||||||
"| From | To | Candles |\n"
|
|
||||||
) in captured.out
|
|
||||||
assert "UNITTEST/BTC" not in captured.out
|
assert "UNITTEST/BTC" not in captured.out
|
||||||
assert (
|
assert re.search(
|
||||||
"\n| XRP/ETH | 1m | spot | "
|
r"\n.* XRP/USDT .* 1m .* spot .* 2019-10-11 00:00:00 .* 2019-10-13 11:19:00 .* 2469 |\n",
|
||||||
"2019-10-11 00:00:00 | 2019-10-13 11:19:00 | 2469 |\n"
|
captured.out,
|
||||||
) in captured.out
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("init_persistence")
|
@pytest.mark.usefixtures("init_persistence")
|
||||||
|
|||||||
Reference in New Issue
Block a user