-
Notifications
You must be signed in to change notification settings - Fork 959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fama-french 3 and fama-french 5 factors (can be also 4 or 6) for expected returns #595
Comments
This is final revised code (feel free to change what you want, I'm a python [and statistician] beginner): import pandas as pd def ff_expected_returns(df, modello, frequency):
|
python def ff_expected_returns(df, modello, frequency):
|
I trying to be more reliable on expected returns calculation by using Fama-French 3 and 5 factors-
Add a new functionality as (mean_historical_return, ema_historical_return or capm_return) to return ff3 or ff5 expected return.
Below code could be a starting point:
import pandas as pd
import numpy as np
import statsmodels.api as sm
import getfactormodels as gfm
#df is a panda dataframe same of input for mean_historical_return, ema_historical_return or capm_return
#model can be 'ff3' or 'ff5'
#frequency is usually 252 or what you want
#return is a series (tickers, expected returns) same as mean_historical_return, ema_historical_return or capm_return
def ff_expected_returns(df, model, frequency):
factors = gfm.get_factors(model=model, frequency='d', start_date="2000-01-01")
df.index = pd.to_datetime(df.index)
The text was updated successfully, but these errors were encountered: