Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Last active September 21, 2023 04:37
Show Gist options
  • Save quantra-go-algo/21d8d623c0640e9e1e79ca0ba2cae468 to your computer and use it in GitHub Desktop.
Save quantra-go-algo/21d8d623c0640e9e1e79ca0ba2cae468 to your computer and use it in GitHub Desktop.
# 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)
@quantra-go-algo
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment