mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
feat: edge-cli output to rich
This commit is contained in:
@@ -52,4 +52,4 @@ class EdgeCli:
|
|||||||
result = self.edge.calculate(self.config["exchange"]["pair_whitelist"])
|
result = self.edge.calculate(self.config["exchange"]["pair_whitelist"])
|
||||||
if result:
|
if result:
|
||||||
print("") # blank line for readability
|
print("") # blank line for readability
|
||||||
print(generate_edge_table(self.edge._cached_pairs))
|
generate_edge_table(self.edge._cached_pairs)
|
||||||
|
|||||||
@@ -475,7 +475,6 @@ def show_sorted_pairlist(config: Config, backtest_stats: BacktestResultType):
|
|||||||
|
|
||||||
|
|
||||||
def generate_edge_table(results: dict) -> str:
|
def generate_edge_table(results: dict) -> str:
|
||||||
floatfmt = ("s", ".10g", ".2f", ".2f", ".2f", ".2f", "d", "d", "d")
|
|
||||||
tabular_data = []
|
tabular_data = []
|
||||||
headers = [
|
headers = [
|
||||||
"Pair",
|
"Pair",
|
||||||
@@ -493,17 +492,13 @@ def generate_edge_table(results: dict) -> str:
|
|||||||
tabular_data.append(
|
tabular_data.append(
|
||||||
[
|
[
|
||||||
result[0],
|
result[0],
|
||||||
result[1].stoploss,
|
f"{result[1].stoploss:.10g}",
|
||||||
result[1].winrate,
|
f"{result[1].winrate:.2f}",
|
||||||
result[1].risk_reward_ratio,
|
f"{result[1].risk_reward_ratio:.2f}",
|
||||||
result[1].required_risk_reward,
|
f"{result[1].required_risk_reward:.2f}",
|
||||||
result[1].expectancy,
|
f"{result[1].expectancy:.2f}",
|
||||||
result[1].nb_trades,
|
result[1].nb_trades,
|
||||||
round(result[1].avg_trade_duration),
|
round(result[1].avg_trade_duration),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
print_rich_table(tabular_data, headers, summary="EDGE TABLE")
|
||||||
# Ignore type as floatfmt does allow tuples but mypy does not know that
|
|
||||||
return tabulate(
|
|
||||||
tabular_data, headers=headers, floatfmt=floatfmt, tablefmt="orgtbl", stralign="right"
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -538,12 +538,12 @@ def test_text_table_strategy(testdatadir, capsys):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_generate_edge_table():
|
def test_generate_edge_table(capsys):
|
||||||
results = {}
|
results = {}
|
||||||
results["ETH/BTC"] = PairInfo(-0.01, 0.60, 2, 1, 3, 10, 60)
|
results["ETH/BTC"] = PairInfo(-0.01, 0.60, 2, 1, 3, 10, 60)
|
||||||
text = generate_edge_table(results)
|
generate_edge_table(results)
|
||||||
assert text.count("+") == 7
|
text = capsys.readouterr().out
|
||||||
assert text.count("| ETH/BTC |") == 1
|
assert re.search(r".* ETH/BTC .*", text)
|
||||||
assert re.search(r".* Risk Reward Ratio .* Required Risk Reward .* Expectancy .*", text)
|
assert re.search(r".* Risk Reward Ratio .* Required Risk Reward .* Expectancy .*", text)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user