Skip to content

Commit

Permalink
fix: avoid 1st crash on "settings" view
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Aug 24, 2024
1 parent 61e1a8b commit 83ebace
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions ftui/ftui_screens.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from datetime import datetime, timezone
from pathlib import Path

Expand Down Expand Up @@ -39,7 +38,6 @@


class DashboardScreen(Screen):

timers = {}

COLLAP_FUNC_MAP = {
Expand Down Expand Up @@ -153,8 +151,8 @@ def _render_open_trade_data(self, data, trading_mode="spot"):
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'),
fth.red_or_green(float(v['Profit %']), justify='right'),
fth.red_or_green(float(v["Max %"]), justify="left"),
fth.red_or_green(float(v["Profit %"]), justify="right"),
fth.red_or_green(float(v["Profit"]), justify="left"),
str(v["Dur."]).split(".")[0].replace("0 days ", ""),
f"{v['S/L']}",
Expand Down Expand Up @@ -483,7 +481,6 @@ def toggle_collapsible(self, event: Collapsible.Toggled) -> None:


class MainBotScreen(Screen):

timers = {}

TAB_FUNC_MAP = {
Expand Down Expand Up @@ -531,7 +528,6 @@ def compose(self) -> ComposeResult:
yield PlotextPlot(id="bot-chart", classes="bg-static-default")

with TabbedContent(initial="open-trades-tab"):

with TabPane("Open Trades", id="open-trades-tab"):
yield Static(id="open-trades-table", classes="bg-static-default")

Expand Down Expand Up @@ -821,7 +817,7 @@ 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
num_orders = len(t["orders"]) if "orders" in t else 0

suff = ""
if open_orders and t["close_rate_requested"] is None:
Expand Down Expand Up @@ -1322,7 +1318,6 @@ def debug(self, msg):


class SettingsScreen(Screen):

timers = {}

def compose(self) -> ComposeResult:
Expand Down Expand Up @@ -1377,14 +1372,13 @@ def update_settings(self, s):
for server in s[setting]:
t = Checkbox(
f"{server['name']} [{server['ip']}:{server['port']}]",
server["enabled"],
server.get("enabled", True),
)
c.mount(t)
settings_left.mount(c)


class HelpScreen(Screen):

timers = {}

help_file_path = Path(__file__).parent / "md" / "help.md"
Expand Down Expand Up @@ -1473,7 +1467,6 @@ def compose(self) -> ComposeResult:
yield Static("[Esc] to close")

def build_trade_info(self, trade_info):

main_text = (
f"[b]Trade Id : {self.trade_id}\n"
f"[b]Pair : {trade_info['pair']}\n"
Expand Down

0 comments on commit 83ebace

Please sign in to comment.