diff --git a/dashboard/app.py b/dashboard/app.py index 69911d7..d1c94bc 100644 --- a/dashboard/app.py +++ b/dashboard/app.py @@ -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: diff --git a/data/fx_data.py b/data/fx_data.py index f633c01..b0c3ee2 100644 --- a/data/fx_data.py +++ b/data/fx_data.py @@ -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"