Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ TICKERS = {
|
|
| 21 |
"Apple": "AAPL",
|
| 22 |
"Facebook": "META",
|
| 23 |
"Google": "GOOGL",
|
| 24 |
-
"NASDAQ": "^IXIC"
|
| 25 |
}
|
| 26 |
|
| 27 |
# --- FETCH STOCK PRICES ROBUSTLY ---
|
|
@@ -31,6 +31,10 @@ for company, ticker in TICKERS.items():
|
|
| 31 |
end_date = pd.Timestamp.today()
|
| 32 |
df_prices = yf.download(ticker, start=start_date, end=end_date)
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# Ensure 'Close' column exists
|
| 35 |
if 'Close' not in df_prices.columns:
|
| 36 |
if 'Adj Close' in df_prices.columns:
|
|
|
|
| 21 |
"Apple": "AAPL",
|
| 22 |
"Facebook": "META",
|
| 23 |
"Google": "GOOGL",
|
| 24 |
+
"NASDAQ": "^IXIC"
|
| 25 |
}
|
| 26 |
|
| 27 |
# --- FETCH STOCK PRICES ROBUSTLY ---
|
|
|
|
| 31 |
end_date = pd.Timestamp.today()
|
| 32 |
df_prices = yf.download(ticker, start=start_date, end=end_date)
|
| 33 |
|
| 34 |
+
# Flatten MultiIndex columns if present
|
| 35 |
+
if isinstance(df_prices.columns, pd.MultiIndex):
|
| 36 |
+
df_prices.columns = ['_'.join([str(c) for c in col]).strip() for col in df_prices.columns]
|
| 37 |
+
|
| 38 |
# Ensure 'Close' column exists
|
| 39 |
if 'Close' not in df_prices.columns:
|
| 40 |
if 'Adj Close' in df_prices.columns:
|