chore: remove pointless else
This commit is contained in:
@@ -246,88 +246,87 @@ def start_list_markets(args: dict[str, Any], pairs_only: bool = False) -> None:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise OperationalException(f"Cannot get markets. Reason: {e}") from e
|
raise OperationalException(f"Cannot get markets. Reason: {e}") from e
|
||||||
|
|
||||||
else:
|
summary_str = (
|
||||||
summary_str = (
|
(f"Exchange {exchange.name} has {len(pairs)} ")
|
||||||
(f"Exchange {exchange.name} has {len(pairs)} ")
|
+ ("active " if active_only else "")
|
||||||
+ ("active " if active_only else "")
|
+ (plural(len(pairs), "pair" if pairs_only else "market"))
|
||||||
+ (plural(len(pairs), "pair" if pairs_only else "market"))
|
+ (
|
||||||
+ (
|
f" with {', '.join(base_currencies)} as base "
|
||||||
f" with {', '.join(base_currencies)} as base "
|
f"{plural(len(base_currencies), 'currency', 'currencies')}"
|
||||||
f"{plural(len(base_currencies), 'currency', 'currencies')}"
|
if base_currencies
|
||||||
if base_currencies
|
else ""
|
||||||
else ""
|
|
||||||
)
|
|
||||||
+ (" and" if base_currencies and quote_currencies else "")
|
|
||||||
+ (
|
|
||||||
f" with {', '.join(quote_currencies)} as quote "
|
|
||||||
f"{plural(len(quote_currencies), 'currency', 'currencies')}"
|
|
||||||
if quote_currencies
|
|
||||||
else ""
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
+ (" and" if base_currencies and quote_currencies else "")
|
||||||
|
+ (
|
||||||
|
f" with {', '.join(quote_currencies)} as quote "
|
||||||
|
f"{plural(len(quote_currencies), 'currency', 'currencies')}"
|
||||||
|
if quote_currencies
|
||||||
|
else ""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
headers = [
|
headers = [
|
||||||
"Id",
|
"Id",
|
||||||
"Symbol",
|
"Symbol",
|
||||||
"Base",
|
"Base",
|
||||||
"Quote",
|
"Quote",
|
||||||
"Active",
|
"Active",
|
||||||
"Spot",
|
"Spot",
|
||||||
"Margin",
|
"Margin",
|
||||||
"Future",
|
"Future",
|
||||||
"Leverage",
|
"Leverage",
|
||||||
]
|
]
|
||||||
|
|
||||||
tabular_data = [
|
tabular_data = [
|
||||||
{
|
{
|
||||||
"Id": v["id"],
|
"Id": v["id"],
|
||||||
"Symbol": v["symbol"],
|
"Symbol": v["symbol"],
|
||||||
"Base": v["base"],
|
"Base": v["base"],
|
||||||
"Quote": v["quote"],
|
"Quote": v["quote"],
|
||||||
"Active": market_is_active(v),
|
"Active": market_is_active(v),
|
||||||
"Spot": "Spot" if exchange.market_is_spot(v) else "",
|
"Spot": "Spot" if exchange.market_is_spot(v) else "",
|
||||||
"Margin": "Margin" if exchange.market_is_margin(v) else "",
|
"Margin": "Margin" if exchange.market_is_margin(v) else "",
|
||||||
"Future": "Future" if exchange.market_is_future(v) else "",
|
"Future": "Future" if exchange.market_is_future(v) else "",
|
||||||
"Leverage": exchange.get_max_leverage(v["symbol"], 20),
|
"Leverage": exchange.get_max_leverage(v["symbol"], 20),
|
||||||
}
|
}
|
||||||
for _, v in pairs.items()
|
for _, v in pairs.items()
|
||||||
]
|
]
|
||||||
|
|
||||||
if (
|
if (
|
||||||
args.get("print_one_column", False)
|
args.get("print_one_column", False)
|
||||||
or args.get("list_pairs_print_json", False)
|
or args.get("list_pairs_print_json", False)
|
||||||
or args.get("print_csv", False)
|
or args.get("print_csv", False)
|
||||||
):
|
):
|
||||||
# Print summary string in the log in case of machine-readable
|
# Print summary string in the log in case of machine-readable
|
||||||
# regular formats.
|
# regular formats.
|
||||||
logger.info(f"{summary_str}.")
|
logger.info(f"{summary_str}.")
|
||||||
|
else:
|
||||||
|
# Print empty string separating leading logs and output in case of
|
||||||
|
# human-readable formats.
|
||||||
|
print()
|
||||||
|
|
||||||
|
if pairs:
|
||||||
|
if args.get("print_list", False):
|
||||||
|
# print data as a list, with human-readable summary
|
||||||
|
print(f"{summary_str}: {', '.join(pairs.keys())}.")
|
||||||
|
elif args.get("print_one_column", False):
|
||||||
|
print("\n".join(pairs.keys()))
|
||||||
|
elif args.get("list_pairs_print_json", False):
|
||||||
|
import rapidjson
|
||||||
|
|
||||||
|
print(rapidjson.dumps(list(pairs.keys()), default=str))
|
||||||
|
elif args.get("print_csv", False):
|
||||||
|
writer = csv.DictWriter(sys.stdout, fieldnames=headers)
|
||||||
|
writer.writeheader()
|
||||||
|
writer.writerows(tabular_data)
|
||||||
else:
|
else:
|
||||||
# Print empty string separating leading logs and output in case of
|
print_rich_table(tabular_data, headers, summary_str)
|
||||||
# human-readable formats.
|
elif not (
|
||||||
print()
|
args.get("print_one_column", False)
|
||||||
|
or args.get("list_pairs_print_json", False)
|
||||||
if pairs:
|
or args.get("print_csv", False)
|
||||||
if args.get("print_list", False):
|
):
|
||||||
# print data as a list, with human-readable summary
|
print(f"{summary_str}.")
|
||||||
print(f"{summary_str}: {', '.join(pairs.keys())}.")
|
|
||||||
elif args.get("print_one_column", False):
|
|
||||||
print("\n".join(pairs.keys()))
|
|
||||||
elif args.get("list_pairs_print_json", False):
|
|
||||||
import rapidjson
|
|
||||||
|
|
||||||
print(rapidjson.dumps(list(pairs.keys()), default=str))
|
|
||||||
elif args.get("print_csv", False):
|
|
||||||
writer = csv.DictWriter(sys.stdout, fieldnames=headers)
|
|
||||||
writer.writeheader()
|
|
||||||
writer.writerows(tabular_data)
|
|
||||||
else:
|
|
||||||
print_rich_table(tabular_data, headers, summary_str)
|
|
||||||
elif not (
|
|
||||||
args.get("print_one_column", False)
|
|
||||||
or args.get("list_pairs_print_json", False)
|
|
||||||
or args.get("print_csv", False)
|
|
||||||
):
|
|
||||||
print(f"{summary_str}.")
|
|
||||||
|
|
||||||
|
|
||||||
def start_show_trades(args: dict[str, Any]) -> None:
|
def start_show_trades(args: dict[str, Any]) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user