From 2561cc67f0798fa6750222c9b678726e4092d6f5 Mon Sep 17 00:00:00 2001 From: froggleston Date: Wed, 17 Jul 2024 15:30:28 +0100 Subject: [PATCH] Add num orders to open table, fix general tab output --- ftui/ftui.py | 4 ++++ ftui/ftui_helpers.py | 14 ++++++-------- ftui/ftui_screens.py | 9 +++++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ftui/ftui.py b/ftui/ftui.py index 7e25fb0..87c903b 100644 --- a/ftui/ftui.py +++ b/ftui/ftui.py @@ -156,6 +156,8 @@ def _get_open_trade_dataframe(self, ftuic): else (t["open_order_id"] is not None) ) + num_orders = len(t["orders"]) if "orders" in t else 0 + suff = "" if open_orders and t["close_rate_requested"] is None: suff = " *" @@ -193,6 +195,7 @@ def _get_open_trade_dataframe(self, ftuic): t["open_date"], t["stake_amount"], t["leverage"], + num_orders, ) ) @@ -214,6 +217,7 @@ def _get_open_trade_dataframe(self, ftuic): "Open Date", "Stake Amount", "Leverage", + "# Orders", ], ) diff --git a/ftui/ftui_helpers.py b/ftui/ftui_helpers.py index 84bbe44..3042a25 100644 --- a/ftui/ftui_helpers.py +++ b/ftui/ftui_helpers.py @@ -224,6 +224,7 @@ def dash_open_trades_table(row_data, trading_mode="spot", colours=FtuiColours()) if trading_mode != "spot": table.add_column("Leverage", justify="left") + table.add_column("# Orders", no_wrap=True) table.add_column("Open Rate", style=colours.open_rate_col, no_wrap=True) table.add_column("Rate", style=colours.current_rate_col, no_wrap=True) table.add_column("Stop %", no_wrap=True) @@ -309,6 +310,7 @@ def bot_open_trades_table(row_data, trading_mode="spot", colours=FtuiColours()) if trading_mode != "spot": table.add_column("Leverage", justify="left") + table.add_column("# Orders", no_wrap=True) table.add_column("Open Rate", style=colours.open_rate_col, no_wrap=True) table.add_column("Rate", style=colours.current_rate_col, no_wrap=True) table.add_column("Stop %", no_wrap=True) @@ -426,27 +428,23 @@ def bot_general_metrics_table(client) -> str: table.add_column("Value", style="white", no_wrap=False, ratio=2) row_data = [ - ( - f"Avg Profit", - f"{round(t['profit_all_ratio_mean']*100, 2)}% " - f"(∑ {round(t['profit_all_ratio_sum']*100, 2)}%) in {trade_count} trades", - ), ( f"ROI closed trades", f"{round(t['profit_closed_coin'], 2)} {config['stake_currency']} " - f"({round(t['profit_closed_ratio_mean'], 2)}%)", + f"({chr(0x03BC)} {round(t['profit_closed_ratio_mean']*100, 2)}%) " + f"(∑ {round(t['profit_all_ratio_sum']*100, 2)}%)", ), ( f"ROI all trades", f"{round(t['profit_all_coin'], 2)} {config['stake_currency']} " - f"({round(t['profit_all_ratio_mean'], 2)}%)", + f"({chr(0x03BC)} {round(t['profit_all_ratio_mean']*100, 2)}%)", ), (f"Total Trade count", f"{trade_count}"), (f"Bot started", f"{t['bot_start_date']}"), (f"First Trade opened", f"{t['first_trade_date']}"), (f"Latest Trade opened", f"{t['latest_trade_date']}"), (f"Win / Loss", f"{t['winning_trades']} / {t['losing_trades']}"), - (f"Winrate", f"{round(t['winrate'], 3)}%"), + (f"Winrate", f"{round(t['winrate']* 100, 3)}%"), (f"Expectancy (ratio)", f"{round(t['expectancy'], 2)} ({round(t['expectancy_ratio'], 2)})"), (f"Avg. Duration", f"{t['avg_duration']}"), (f"Best performing", f"{t['best_pair']}: {t['best_rate']}%"), diff --git a/ftui/ftui_screens.py b/ftui/ftui_screens.py index e422171..49b9fbd 100644 --- a/ftui/ftui_screens.py +++ b/ftui/ftui_screens.py @@ -158,7 +158,8 @@ def _render_open_trade_data(self, data, trading_mode="spot"): render_data = render_data + (f"{v['Leverage']}") render_data = render_data + ( - f"{v['Open Rate']}", + f"{v['# Orders']}", + f"{round(v['Open Rate'], 3)}", f"{v['Current Rate']}", fth.red_or_green(float(v["Stop %"])), fth.red_or_green(float(v['Max %']), justify='left'), @@ -696,7 +697,8 @@ def update_select_options(self, bot_id=None): if bot_id is not None: sel.value = bot_id else: - sel.value = current_selection + if current_selection is not None and current_selection != "Select.BLANK": + sel.value = current_selection @work(group="tabswitch_workers", exclusive=False, thread=True) def update_tab(self, tab_id, bot_id): @@ -828,6 +830,8 @@ def _render_open_trade_summary(self, ftuic): t["has_open_orders"] if "has_open_orders" in t else (t["open_order_id"] is not None) ) + num_orders = len(t['orders']) if 'orders' in t else 0 + suff = "" if open_orders and t["close_rate_requested"] is None: suff = " *" @@ -858,6 +862,7 @@ def _render_open_trade_summary(self, ftuic): render_data = render_data + (f"{t['leverage']}") render_data = render_data + ( + f"{num_orders}", f"{t['open_rate']}", f"{t['current_rate']}", stp_txt,