Last Update: December 15, 2020
Asset pricing models consist of estimating asset expected return through its expected risk premium linear relationship with factors portfolios expected risk premiums and macroeconomic factors.
This topic is part of Investment Portfolio Analysis with Python course. Feel free to take a look at Course Curriculum.
This tutorial has an educational and informational purpose and doesn’t constitute any type of trading or investment advice. All content, including code and data, is presented for personal educational use exclusively and with no guarantee of exactness of completeness. Past performance doesn’t guarantee future results. Please read full Disclaimer.
An example of asset pricing models is arbitrage pricing theory APT  which consists of estimating asset expected return through its expected risk premium linear relationship with market portfolio expected risk premium and macroeconomic factors.
1. Formula notation.
1.1. Arbitrage pricing theory APT asset risk premium formula notation.
- Note: macroeconomic factor not fixed and only included for educational purposes.
Where = asset realized risk premiums, = asset realized returns, = realized risk free returns, = asset average realized excess return, = asset market beta coefficient, = market realized risk premiums, = market realized returns, = asset macroeconomic factor beta coefficient, = realized consumer price index percentage changes macroeconomic factor, = linear regression residuals or forecasting errors.
1.2. Arbitrage pricing theory APT model formula notation.
- Note: APT formula recasting using expected returns (ex-ante) instead of average realized returns (ex-post). For full reference, please read The Arbitrage Theory of Capital Asset Pricing .
Where = asset expected return, = expected risk-free return, = asset market beta coefficient, = market expected risk premium, = market expected return, = asset macroeconomic factor beta coefficient, = expected percentage change in consumer price index macroeconomic factor.
2. Python code example.
2.1. Import Python packages .
import pandas as pd import statsmodels.regression.linear_model as lm import statsmodels.tools.tools as ct
2.2. APT multiple factors model data reading.
- Data: S&P 500® index replicating ETF (ticker symbol: SPY) adjusted close prices and market portfolio  monthly arithmetic returns risk premiums, U.S. consumer price index monthly arithmetic change (2007-2016).
data = pd.read_csv('Data//APT-Multiple-Factors-Model-Data.txt', index_col='Date', parse_dates=True)
2.3. APT multiple factors model multiple linear regression calculation and output.
In: data.loc[:, 'CT'] = ct.add_constant(data) apt = lm.OLS(data['SPY-RF'], data[['CT', 'MKT-RF', 'CPI']], hasconst=bool).fit() print('== APT Multiple Regression Summary ==') print('') print(apt.summary())
Out: == APT Multiple Regression Summary == OLS Regression Results ============================================================================== Dep. Variable: SPY-RF R-squared: 0.992 Model: OLS Adj. R-squared: 0.992 Method: Least Squares F-statistic: 7425. Date: Fri, 06 Nov 2020 Prob (F-statistic): 5.54e-124 Time: 18:45:52 Log-Likelihood: 495.70 No. Observations: 120 AIC: -985.4 Df Residuals: 117 BIC: -977.0 Df Model: 2 Covariance Type: nonrobust ============================================================================== coef std err t P>|t| [0.025 0.975] ------------------------------------------------------------------------------ CT 4.202e-05 0.000 0.106 0.916 -0.001 0.001 MKT-RF 0.9715 0.008 120.892 0.000 0.956 0.987 CPI -0.1420 0.114 -1.241 0.217 -0.369 0.085 ============================================================================== Omnibus: 0.439 Durbin-Watson: 2.173 Prob(Omnibus): 0.803 Jarque-Bera (JB): 0.433 Skew: 0.140 Prob(JB): 0.805 Kurtosis: 2.910 Cond. No. 318. ============================================================================== Warnings:  Standard Errors assume that the covariance matrix of the errors is correctly specified.
 Stephen Ross. “The Arbitrage Theory of Capital Asset Pricing”. Journal of Economic Theory. 1976.
 Wes McKinney. “Data Structures for Statistical Computing in Python.” Proceedings of the 9th Python in Science Conference. 2010.
Seabold, Skipper, and Josef Perktold. “Statsmodels: Econometric and statistical modeling with python.” Proceedings of the 9th Python in Science Conference. 2010.
 Eugene F. Fama and Kenneth F. French. “Common Risk Factors in the Returns on Stocks and Bonds,” Journal of Financial Economics. 1993.