Fix XAU/USD data: hard-coded GC=F ticker, fix deprecated params

This commit is contained in:
addychai355-create
2026-05-12 22:08:45 +08:00
parent 29814de211
commit 35e24cf9ea
2 changed files with 9 additions and 8 deletions
+4 -4
View File
@@ -216,7 +216,7 @@ if data is not None:
margin=dict(l=0, r=0, t=30, b=0),
legend=dict(orientation="h", y=1.02, x=0))
fig.update_xaxes(rangeslider_visible=False)
st.plotly_chart(fig, use_container_width=True)
st.plotly_chart(fig, width="stretch")
with col2:
perf = calculate_performance_xau(data) if is_gold else (
@@ -300,7 +300,7 @@ if data is not None:
fig.update_layout(height=350, template="plotly_dark", hovermode="x unified",
margin=dict(l=0, r=0, t=10, b=0), legend=dict(orientation="h", y=1.02, x=0))
st.plotly_chart(fig, use_container_width=True)
st.plotly_chart(fig, width="stretch")
st.markdown("---")
@@ -338,7 +338,7 @@ if data is not None:
display_cols = ["Time", "Price", "RSI", "ATR%", "Signal"]
st.markdown("**Recent candles & signals**")
st.dataframe(recent[display_cols], use_container_width=True, hide_index=True)
st.dataframe(recent[display_cols], width="stretch", hide_index=True)
with col2:
if is_gold and not data[data["signal"] != 0].empty:
@@ -364,7 +364,7 @@ if data is not None:
exit_display = exit_data[["time", "close", "exit_reason"]].tail(10).copy()
exit_display["time"] = exit_display["time"].dt.strftime("%H:%M")
exit_display = exit_display.rename(columns={"time": "Time", "close": "Price", "exit_reason": "Exit"})
st.dataframe(exit_display, use_container_width=True, hide_index=True)
st.dataframe(exit_display, width="stretch", hide_index=True)
else:
st.info("No exits yet in recent data.")
else:
+5 -4
View File
@@ -22,8 +22,8 @@ from config import RAW_DIR, OANDA_KEY, OANDA_ACCOUNT, OANDA_ENV
# ──────────────────────────────────────────────
# Yahoo ticker format for forex: EURUSD=X
# Gold/silver use futures tickers (GC=F, SI=F) — mapped directly in get_yahoo_data
YAHOO_PAIRS = {
# Forex pairs
"EUR_USD": "EURUSD=X",
"GBP_USD": "GBPUSD=X",
"USD_JPY": "USDJPY=X",
@@ -38,8 +38,7 @@ YAHOO_PAIRS = {
"AUD_JPY": "AUDJPY=X",
"CHF_JPY": "CHFJPY=X",
"EUR_CHF": "EURCHF=X",
# Commodities
"XAU_USD": "GC=F", # Gold Futures (~= spot XAU/USD)
"XAU_USD": "GC=F", # Gold Futures
"XAG_USD": "SI=F", # Silver Futures
"BTC_USD": "BTC-USD", # Bitcoin
}
@@ -65,7 +64,9 @@ def get_yahoo_data(
"""
import yfinance as yf
ticker = YAHOO_PAIRS.get(pair, pair.replace("_", "") + "=X")
# Hard-coded commodity tickers (bypass potential YAHOO_PAIRS mismatches on Streamlit Cloud)
_COMMODITY_TICKERS = {"XAU_USD": "GC=F", "XAG_USD": "SI=F", "BTC_USD": "BTC-USD"}
ticker = _COMMODITY_TICKERS.get(pair) or YAHOO_PAIRS.get(pair, pair.replace("_", "") + "=X")
yahoo_tf = TIMEFRAMES_YAHOO.get(tf, tf)
cache_file = RAW_DIR / f"yahoo_{ticker}_{tf}.parquet"