From 6b7a6d2e5090d7b577890294db4c6c6b531924ae Mon Sep 17 00:00:00 2001 From: addychai355-create Date: Tue, 12 May 2026 22:38:16 +0800 Subject: [PATCH] Remove auto-refresh (rate limit fix). Static page, data cached 5 min. --- dashboard/app.py | 12 ++++++------ dashboard/requirements.txt | 1 - dashboard/xau_monitor.py | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/dashboard/app.py b/dashboard/app.py index d0e36e1..2c74df4 100644 --- a/dashboard/app.py +++ b/dashboard/app.py @@ -31,7 +31,6 @@ st.markdown(""" # ─── Import strategy ─── from strategies.xau_scalp import add_indicators_xau, generate_signals_xau, calculate_performance_xau -from streamlit_autorefresh import st_autorefresh # ─── Fetch XAU/USD data directly ─── def fetch_gold(tf="5m", days=3): @@ -50,11 +49,12 @@ def fetch_gold(tf="5m", days=3): def format_price(v): return f"${v:,.2f}" if v == v else "—" -# ─── Auto-refresh every 3 seconds ─── -st_autorefresh(interval=3000, key="goldrefresh", limit=None) +# ─── Load & compute (cached to avoid rate limits) ─── +@st.cache_data(ttl=300) +def load_gold(): + return fetch_gold("5m", 3) -# ─── Load & compute ─── -df = fetch_gold("5m", 3) +df = load_gold() if df is None or len(df) < 60: st.error("Failed to load XAU/USD data. Try again in a minute.") st.stop() @@ -203,4 +203,4 @@ else: # ─── Footer ─── st.markdown("---") -st.markdown("

Data: Yahoo Finance GC=F · Live auto-refresh

", unsafe_allow_html=True) +st.markdown("

Data: Yahoo Finance GC=F · Refreshes every 5 min · Pull down to reload

", unsafe_allow_html=True) diff --git a/dashboard/requirements.txt b/dashboard/requirements.txt index 0006979..3424326 100644 --- a/dashboard/requirements.txt +++ b/dashboard/requirements.txt @@ -8,4 +8,3 @@ yfinance>=0.2.28 scikit-learn>=1.3 scipy>=1.11 python-dotenv>=1.0 -streamlit-autorefresh>=1.0 diff --git a/dashboard/xau_monitor.py b/dashboard/xau_monitor.py index d0e36e1..2c74df4 100644 --- a/dashboard/xau_monitor.py +++ b/dashboard/xau_monitor.py @@ -31,7 +31,6 @@ st.markdown(""" # ─── Import strategy ─── from strategies.xau_scalp import add_indicators_xau, generate_signals_xau, calculate_performance_xau -from streamlit_autorefresh import st_autorefresh # ─── Fetch XAU/USD data directly ─── def fetch_gold(tf="5m", days=3): @@ -50,11 +49,12 @@ def fetch_gold(tf="5m", days=3): def format_price(v): return f"${v:,.2f}" if v == v else "—" -# ─── Auto-refresh every 3 seconds ─── -st_autorefresh(interval=3000, key="goldrefresh", limit=None) +# ─── Load & compute (cached to avoid rate limits) ─── +@st.cache_data(ttl=300) +def load_gold(): + return fetch_gold("5m", 3) -# ─── Load & compute ─── -df = fetch_gold("5m", 3) +df = load_gold() if df is None or len(df) < 60: st.error("Failed to load XAU/USD data. Try again in a minute.") st.stop() @@ -203,4 +203,4 @@ else: # ─── Footer ─── st.markdown("---") -st.markdown("

Data: Yahoo Finance GC=F · Live auto-refresh

", unsafe_allow_html=True) +st.markdown("

Data: Yahoo Finance GC=F · Refreshes every 5 min · Pull down to reload

", unsafe_allow_html=True)