mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
feat: edge-cli output to rich
This commit is contained in:
parent
2d31314eb4
commit
f9af659153
|
@ -52,4 +52,4 @@ class EdgeCli:
|
|||
result = self.edge.calculate(self.config["exchange"]["pair_whitelist"])
|
||||
if result:
|
||||
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:
|
||||
floatfmt = ("s", ".10g", ".2f", ".2f", ".2f", ".2f", "d", "d", "d")
|
||||
tabular_data = []
|
||||
headers = [
|
||||
"Pair",
|
||||
|
@ -493,17 +492,13 @@ def generate_edge_table(results: dict) -> str:
|
|||
tabular_data.append(
|
||||
[
|
||||
result[0],
|
||||
result[1].stoploss,
|
||||
result[1].winrate,
|
||||
result[1].risk_reward_ratio,
|
||||
result[1].required_risk_reward,
|
||||
result[1].expectancy,
|
||||
f"{result[1].stoploss:.10g}",
|
||||
f"{result[1].winrate:.2f}",
|
||||
f"{result[1].risk_reward_ratio:.2f}",
|
||||
f"{result[1].required_risk_reward:.2f}",
|
||||
f"{result[1].expectancy:.2f}",
|
||||
result[1].nb_trades,
|
||||
round(result[1].avg_trade_duration),
|
||||
]
|
||||
)
|
||||
|
||||
# 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"
|
||||
)
|
||||
print_rich_table(tabular_data, headers, summary="EDGE TABLE")
|
||||
|
|
|
@ -538,12 +538,12 @@ def test_text_table_strategy(testdatadir, capsys):
|
|||
)
|
||||
|
||||
|
||||
def test_generate_edge_table():
|
||||
def test_generate_edge_table(capsys):
|
||||
results = {}
|
||||
results["ETH/BTC"] = PairInfo(-0.01, 0.60, 2, 1, 3, 10, 60)
|
||||
text = generate_edge_table(results)
|
||||
assert text.count("+") == 7
|
||||
assert text.count("| ETH/BTC |") == 1
|
||||
generate_edge_table(results)
|
||||
text = capsys.readouterr().out
|
||||
assert re.search(r".* ETH/BTC .*", text)
|
||||
assert re.search(r".* Risk Reward Ratio .* Required Risk Reward .* Expectancy .*", text)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user