Remove auto-refresh (rate limit fix). Static page, data cached 5 min.
This commit is contained in:
+6
-6
@@ -31,7 +31,6 @@ st.markdown("""
|
|||||||
|
|
||||||
# ─── Import strategy ───
|
# ─── Import strategy ───
|
||||||
from strategies.xau_scalp import add_indicators_xau, generate_signals_xau, calculate_performance_xau
|
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 ───
|
# ─── Fetch XAU/USD data directly ───
|
||||||
def fetch_gold(tf="5m", days=3):
|
def fetch_gold(tf="5m", days=3):
|
||||||
@@ -50,11 +49,12 @@ def fetch_gold(tf="5m", days=3):
|
|||||||
def format_price(v):
|
def format_price(v):
|
||||||
return f"${v:,.2f}" if v == v else "—"
|
return f"${v:,.2f}" if v == v else "—"
|
||||||
|
|
||||||
# ─── Auto-refresh every 3 seconds ───
|
# ─── Load & compute (cached to avoid rate limits) ───
|
||||||
st_autorefresh(interval=3000, key="goldrefresh", limit=None)
|
@st.cache_data(ttl=300)
|
||||||
|
def load_gold():
|
||||||
|
return fetch_gold("5m", 3)
|
||||||
|
|
||||||
# ─── Load & compute ───
|
df = load_gold()
|
||||||
df = fetch_gold("5m", 3)
|
|
||||||
if df is None or len(df) < 60:
|
if df is None or len(df) < 60:
|
||||||
st.error("Failed to load XAU/USD data. Try again in a minute.")
|
st.error("Failed to load XAU/USD data. Try again in a minute.")
|
||||||
st.stop()
|
st.stop()
|
||||||
@@ -203,4 +203,4 @@ else:
|
|||||||
|
|
||||||
# ─── Footer ───
|
# ─── Footer ───
|
||||||
st.markdown("---")
|
st.markdown("---")
|
||||||
st.markdown("<p style='text-align:center;color:#3D4048;font-size:0.6rem;'>Data: Yahoo Finance GC=F · Live auto-refresh</p>", unsafe_allow_html=True)
|
st.markdown("<p style='text-align:center;color:#3D4048;font-size:0.6rem;'>Data: Yahoo Finance GC=F · Refreshes every 5 min · Pull down to reload</p>", unsafe_allow_html=True)
|
||||||
|
|||||||
@@ -8,4 +8,3 @@ yfinance>=0.2.28
|
|||||||
scikit-learn>=1.3
|
scikit-learn>=1.3
|
||||||
scipy>=1.11
|
scipy>=1.11
|
||||||
python-dotenv>=1.0
|
python-dotenv>=1.0
|
||||||
streamlit-autorefresh>=1.0
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ st.markdown("""
|
|||||||
|
|
||||||
# ─── Import strategy ───
|
# ─── Import strategy ───
|
||||||
from strategies.xau_scalp import add_indicators_xau, generate_signals_xau, calculate_performance_xau
|
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 ───
|
# ─── Fetch XAU/USD data directly ───
|
||||||
def fetch_gold(tf="5m", days=3):
|
def fetch_gold(tf="5m", days=3):
|
||||||
@@ -50,11 +49,12 @@ def fetch_gold(tf="5m", days=3):
|
|||||||
def format_price(v):
|
def format_price(v):
|
||||||
return f"${v:,.2f}" if v == v else "—"
|
return f"${v:,.2f}" if v == v else "—"
|
||||||
|
|
||||||
# ─── Auto-refresh every 3 seconds ───
|
# ─── Load & compute (cached to avoid rate limits) ───
|
||||||
st_autorefresh(interval=3000, key="goldrefresh", limit=None)
|
@st.cache_data(ttl=300)
|
||||||
|
def load_gold():
|
||||||
|
return fetch_gold("5m", 3)
|
||||||
|
|
||||||
# ─── Load & compute ───
|
df = load_gold()
|
||||||
df = fetch_gold("5m", 3)
|
|
||||||
if df is None or len(df) < 60:
|
if df is None or len(df) < 60:
|
||||||
st.error("Failed to load XAU/USD data. Try again in a minute.")
|
st.error("Failed to load XAU/USD data. Try again in a minute.")
|
||||||
st.stop()
|
st.stop()
|
||||||
@@ -203,4 +203,4 @@ else:
|
|||||||
|
|
||||||
# ─── Footer ───
|
# ─── Footer ───
|
||||||
st.markdown("---")
|
st.markdown("---")
|
||||||
st.markdown("<p style='text-align:center;color:#3D4048;font-size:0.6rem;'>Data: Yahoo Finance GC=F · Live auto-refresh</p>", unsafe_allow_html=True)
|
st.markdown("<p style='text-align:center;color:#3D4048;font-size:0.6rem;'>Data: Yahoo Finance GC=F · Refreshes every 5 min · Pull down to reload</p>", unsafe_allow_html=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user