Skip to content

Commit 5c36555

Browse files
committed
Fix toml deps, fix chart refreshing
1 parent 7415ae2 commit 5c36555

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

ftui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.6"
1+
__version__ = "0.1.7"

ftui/freqtext.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@ ListView Label {
201201
link-color: goldenrod;
202202
}
203203

204+
#dsh-chart-header {
205+
dock: top;
206+
height: 1;
207+
background: #222;
208+
}
209+
210+
#dash-refresh-chart-button {
211+
dock: right;
212+
height: 1;
213+
border: none;
214+
margin-right: 1;
215+
}
216+
204217
#bot-chart-header {
205218
dock: top;
206219
height: 1;

ftui/ftui_helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def dash_closed_trades_table(row_data, colours=FtuiColours()) -> Table:
258258
def dash_cumulative_profit_plot_data(trades, bot_list=[], pair=None):
259259
if trades.shape[0] > 0 and bot_list:
260260
# Filter trades to what's in the bot_list
261-
# trades = trades.loc[trades["Bot"] == bot].copy()
262261
trades = trades.loc[trades['Bot'].apply(lambda x: x in bot_list)].copy()
263262

264263
# Filter trades to one pair

ftui/screens/dashboard_screen.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from rich.text import Text
66
from textual import on, work
77
from textual.app import ComposeResult
8-
from textual.containers import Container
8+
from textual.containers import Container, Horizontal
99
from textual.widgets import (
10+
Button,
1011
Collapsible,
1112
Digits,
1213
Footer,
@@ -71,6 +72,10 @@ def compose(self) -> ComposeResult:
7172

7273
with Collapsible(title="Cumulative Profit", id="dsh-cp-collap", collapsed=True):
7374
with Container(id="dsh-chart-container"):
75+
with Horizontal(id="dsh-chart-header"):
76+
yield Button(
77+
"Refresh", id="dash-refresh-chart-button", variant="success"
78+
)
7479
yield SelectionList(id="dsh-chart-bot-list", classes="bg-static-default")
7580
yield PlotextPlot(id="dash-cumprof-profit", classes="bg-static-default collap-update")
7681

@@ -125,8 +130,7 @@ async def update_per_five_sec(self):
125130

126131
dsh_cp_collap = self.query_one("#dsh-cp-collap")
127132
if dsh_cp_collap.collapsed is False:
128-
selected_bots = self.query_one("#dsh-chart-bot-list").selected
129-
self.update_cumulative_profit_plot(bot_list = selected_bots)
133+
self.update_cumulative_profit_plot()
130134

131135
def _render_open_trade_data(self, data, trading_mode="spot"):
132136
row_data = []
@@ -426,10 +430,12 @@ def update_dashboard_all_trade_summary(self):
426430
ats = self.query_one("#dash-all-trade-summary")
427431
ats.loading = False
428432

429-
@work(group="dash_chart_worker", exclusive=True, thread=True)
433+
@work(group="dash_chart_worker", exclusive=False, thread=True)
430434
def update_cumulative_profit_plot(self, bot_list=None):
431435
client_dfs = self.app.client_dfs
432436

437+
bot_list = self.query_one("#dsh-chart-bot-list").selected
438+
433439
all_cum_data = pd.DataFrame()
434440
if "all_closed" in client_dfs:
435441
if bot_list is None or not bot_list:
@@ -446,6 +452,7 @@ def update_cumulative_profit_plot(self, bot_list=None):
446452
chart_container = self.query_one("#dash-cumprof-profit")
447453
cplt = chart_container.plt
448454
cplt.clear_data()
455+
cplt.clf()
449456

450457
dfmt = "Y-m-d"
451458
cplt.date_form(dfmt)
@@ -466,6 +473,8 @@ def update_cumulative_profit_plot(self, bot_list=None):
466473
)
467474
cplt.ylabel("Profit")
468475

476+
self.app.call_from_thread(chart_container.refresh)
477+
469478
worker = get_current_worker()
470479
if not worker.is_cancelled:
471480
self.app.call_from_thread(chart_container.set_loading, False)
@@ -474,9 +483,11 @@ def update_cumulative_profit_plot(self, bot_list=None):
474483
def update_cum_plot_from_list(self) -> None:
475484
chart_container = self.query_one("#dash-cumprof-profit")
476485
chart_container.loading = True
486+
self.update_cumulative_profit_plot()
477487

478-
selected_bots = self.query_one("#dsh-chart-bot-list").selected
479-
self.update_cumulative_profit_plot(bot_list = selected_bots)
488+
@on(Button.Pressed, "#dash-refresh-chart-button")
489+
def refresh_dash_chart_button_pressed(self) -> None:
490+
self.update_cum_plot_from_list()
480491

481492
@on(Collapsible.Toggled)
482493
def toggle_collapsible(self, event: Collapsible.Toggled) -> None:

ftui/screens/main_bot_screen.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def _render_tag_summary(self, ftuic):
532532
self.app.call_from_thread(dt.update, table)
533533
dt.loading = False
534534

535-
@work(group="bot_chart_worker", exclusive=True, thread=True)
535+
@work(group="bot_chart_worker", exclusive=False, thread=True)
536536
def update_chart(self, bot_id, pair=None, refresh=False):
537537
client_dict = self.app.client_dict
538538
client_dfs = self.app.client_dfs
@@ -745,10 +745,7 @@ def _render_chart(self, ftuic, pair, data):
745745
severity="warning",
746746
)
747747

748-
#worker = get_current_worker()
749-
#if not worker.is_cancelled:
750-
# self.app.call_from_thread(chart_container.loading, False)
751-
chart_container.loading = False
748+
self.app.call_from_thread(chart_container.set_loading, False)
752749

753750
# bot performance tab
754751
@work(group="perf_summary_worker", exclusive=True, thread=True)

0 commit comments

Comments
 (0)