Updated for latest changes yfinance
Browse filesCode updated to adapt to latest changes in finance -- columns, adj close price, datetime index
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",
|
| 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 |
-
|
| 41 |
-
|
|
|
|
| 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)
|