Skip to content

Commit

Permalink
Add num orders to open table, fix general tab output
Browse files Browse the repository at this point in the history
  • Loading branch information
froggleston committed Jul 17, 2024
1 parent 510664e commit 2561cc6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
4 changes: 4 additions & 0 deletions ftui/ftui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = " *"
Expand Down Expand Up @@ -193,6 +195,7 @@ def _get_open_trade_dataframe(self, ftuic):
t["open_date"],
t["stake_amount"],
t["leverage"],
num_orders,
)
)

Expand All @@ -214,6 +217,7 @@ def _get_open_trade_dataframe(self, ftuic):
"Open Date",
"Stake Amount",
"Leverage",
"# Orders",
],
)

Expand Down
14 changes: 6 additions & 8 deletions ftui/ftui_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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']}%"),
Expand Down
9 changes: 7 additions & 2 deletions ftui/ftui_screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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 = " *"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2561cc6

Please sign in to comment.