Last active
September 21, 2023 04:37
-
-
Save quantra-go-algo/21d8d623c0640e9e1e79ca0ba2cae468 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the ticker list | |
tickers_list = ['AAPL', 'AMZN', 'MSFT', 'WMT'] | |
# Import pandas and create a placeholder for the data | |
import pandas as pd | |
data = pd.DataFrame(columns=tickers_list) | |
# Fetch the data | |
import yfinance as yf | |
for ticker in tickers_list: | |
data[ticker] = yf.download(ticker, period='5y',)['Adj Close'] | |
# Compute the returns of individual stocks and then compute the daily mean returns. | |
# The mean return is the daily portfolio returns with the above four stocks. | |
data = data.pct_change().dropna().mean(axis=1) | |
# Import Pyfolio | |
import pyfolio as pf | |
# Get the full tear sheet | |
pf.create_full_tear_sheet(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
The error is due to some issue with the pyfolio library. We have modified the code and replaced pyfolio with pyfolio-reloaded. You can remove the existing version of pyfolio from your system, install pyfolio-reloaded and then rerun the code. It should run fine. The steps to remove the existing pyfolio library have been provided in the previous code cell in the blog.