Khiry McCurn commited on
Commit
d8e6d12
·
unverified ·
1 Parent(s): 67f035b

Update update_data.py

Browse files
Files changed (1) hide show
  1. update_data.py +11 -1
update_data.py CHANGED
@@ -160,8 +160,18 @@ def download_ticker_data(ticker, start_date, end_date, retry_count=0):
160
 
161
  if data.empty:
162
  return None
 
 
 
 
 
 
 
 
 
 
163
 
164
- return data
165
 
166
  except Exception as e:
167
  if retry_count < MAX_RETRIES:
 
160
 
161
  if data.empty:
162
  return None
163
+
164
+ # Flatten MultiIndex columns if present (yfinance returns this format now)
165
+ if isinstance(data.columns, pd.MultiIndex):
166
+ data.columns = data.columns.get_level_values(0)
167
+
168
+ # Ensure we have the expected columns
169
+ expected_cols = ['Open', 'High', 'Low', 'Close', 'Volume']
170
+ if not all(col in data.columns for col in expected_cols):
171
+ print(f" ⚠️ {ticker}: Missing expected columns, got {data.columns.tolist()}")
172
+ return None
173
 
174
+ return data[expected_cols]
175
 
176
  except Exception as e:
177
  if retry_count < MAX_RETRIES: