January 2020
Beginner to intermediate
432 pages
11h 24m
English
Follow these steps to implement the rolling three-factor model in Python.
import pandas as pdimport yfinance as yfimport statsmodels.formula.api as smfimport pandas_datareader.data as web
ASSETS = ['AMZN', 'GOOG', 'AAPL', 'MSFT']WEIGHTS = [0.25, 0.25, 0.25, 0.25]START_DATE = '2009-12-31'END_DATE = '2018-12-31'
df_three_factor = web.DataReader('F-F_Research_Data_Factors', 'famafrench', start=START_DATE)[0]df_three_factor = df_three_factor.div(100)df_three_factor.index = df_three_factor.index.format()
asset_df = yf.download(ASSETS, start=START_DATE, end=END_DATE, adjusted=True, progress=False) ...
Read now
Unlock full access