From 6778d1b5908a4f5583bba5ffee9b99ccc88eb090 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Apr 2026 13:52:37 +1000 Subject: [PATCH] fix: auto-refresh and open positions columns on Live MT5 EAs page view_live_mt5_eas.py: - Auto-refresh: added sleep+rerun loop at end of render so page keeps itself alive without user interaction - Initialise ftp_last_auto_refresh to now on first page load so timer starts correctly rather than triggering immediately - Open positions table: updated columns to match MT5 HTML report (Time, Position, Symbol, Type, Volume, Price, S/L, T/P, Market Price, Swap, Profit, Comment) mt5_parser.py: - parse_open_positions: added market_price, swap, profit, comment columns to match all 11 columns in MT5 HTML Open Positions table --- view_live_mt5_eas.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/view_live_mt5_eas.py b/view_live_mt5_eas.py index 592f842..309aecb 100644 --- a/view_live_mt5_eas.py +++ b/view_live_mt5_eas.py @@ -509,18 +509,6 @@ cache/ st.success(f"✓ Refreshed {len(acc_cfgs)} accounts") st.rerun() - # Keep the page alive for auto-refresh — sleep then rerun if interval is set - # and the page is open. This runs after all content is rendered. - import time as _time - if poll_interval > 0 and not do_refresh and not auto_refresh and not no_cache: - last_auto = st.session_state.get("ftp_last_auto_refresh", 0) - now_ts = datetime.now().timestamp() - elapsed = now_ts - last_auto - remaining = max(1, int(poll_interval * 60 - elapsed)) - # Sleep in small increments so Streamlit doesn't time out the connection - _time.sleep(min(remaining, 30)) - st.rerun() - # ── Load all cached data ────────────────────────────────────────────────── all_data = [] for acfg in acc_cfgs: @@ -1365,4 +1353,14 @@ def _render_year_grid(year, day_map, today, unit, balance): f'
' f'' f'{hdr}{body}
', - unsafe_allow_html=True) \ No newline at end of file + unsafe_allow_html=True) + + # ── Auto-refresh loop — runs after all content is rendered ──────────────── + import time as _time + if poll_interval > 0 and not do_refresh and not auto_refresh and not no_cache: + last_auto = st.session_state.get("ftp_last_auto_refresh", 0) + now_ts = datetime.now().timestamp() + elapsed = now_ts - last_auto + remaining = max(1, int(poll_interval * 60 - elapsed)) + _time.sleep(min(remaining, 30)) + st.rerun() \ No newline at end of file