Shantala commited on
Commit
78ccdd9
·
verified ·
1 Parent(s): 721b972

Updated for latest changes yfinance

Browse files

Code updated to adapt to latest changes in finance -- columns, adj close price, datetime index

Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -33,16 +33,17 @@ tickers = ['EWA', 'EWH', 'EWJ', 'ENZL', 'EWS']
33
  mkt_idx = 'IPAC'
34
 
35
  # Download historical data (daily) for the tickers and market index ETF
36
- data = yf.download(tickers, start="2010-09-30", end="2024-09-30", group_by='ticker')
37
- idx_data = yf.download(mkt_idx, start="2010-09-30", end="2024-09-30")
38
 
39
  # Extract the closing prices (adjusted for splits and dividends)
40
- prices = pd.DataFrame({ticker: data[ticker]['Adj Close'] for ticker in tickers})
41
- idx_prices = pd.DataFrame({mkt_idx: idx_data['Adj Close']})
 
42
 
43
  # Format the index to display only the date
44
- prices.index = prices.index.strftime('%Y-%m-%d')
45
- idx_prices.index = idx_prices.index.strftime('%Y-%m-%d')
46
 
47
  # Obtain the series of daily returns
48
  X = prices_to_returns(prices)
 
33
  mkt_idx = 'IPAC'
34
 
35
  # Download historical data (daily) for the tickers and market index ETF
36
+ data = yf.download(tickers, start="2010-09-30", end="2024-09-30", auto_adjust=False)
37
+ idx_data = yf.download(mkt_idx, start="2010-09-30", end="2024-09-30", auto_adjust=False)
38
 
39
  # Extract the closing prices (adjusted for splits and dividends)
40
+
41
+ prices = pd.DataFrame(data['Adj Close'])
42
+ idx_prices = pd.DataFrame(idx_data['Adj Close'])
43
 
44
  # Format the index to display only the date
45
+ #prices.index = prices.index.strftime('%Y-%m-%d')
46
+ #idx_prices.index = idx_prices.index.strftime('%Y-%m-%d')
47
 
48
  # Obtain the series of daily returns
49
  X = prices_to_returns(prices)