Skip to content

Arbitrage Pricing Theory Model with Python

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 [1] 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.

r_{a,t}-r_{f,t}=\alpha_{a}+\beta1(r_{m,t}-r_{f,t})+\beta2(\Delta CPI_{t})+e_{t}

Where r_{a,t}-r_{f,t} = asset realized risk premiums, r_{a,t} = asset realized returns, r_{f,t} = realized risk free returns, \alpha_{a} = asset average realized excess return, \beta1 = asset market beta coefficient, r_{m,t}-r_{f,t} = market realized risk premiums, r_{m,t} = market realized returns, \beta2 = asset macroeconomic factor beta coefficient, \Delta CPI_{t} = realized consumer price index percentage changes macroeconomic factor, e_{t} = 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 [1].

E(r_{a})=E(r_{f})+\beta1(E(r_{m})-E(r_{f}))+\beta2(E(\Delta CPI))

Where E(r_{a}) = asset expected return, E(r_{f}) = expected risk-free return, \beta1 = asset market beta coefficient, E(r_{m})-E(r_{f}) = market expected risk premium, E(r_{m}) = market expected return, \beta2 = asset macroeconomic factor beta coefficient, E(\Delta CPI) = expected percentage change in consumer price index macroeconomic factor.

2. Python code example.

2.1. Import Python packages [2].

import pandas as pd
import statsmodels.regression.linear_model as lm
import 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 [3] 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.


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 ==')

== 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.

[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
3. References

[1] Stephen Ross. “The Arbitrage Theory of Capital Asset Pricing”. Journal of Economic Theory. 1976.

[2] 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.

[3] Eugene F. Fama and Kenneth F. French. “Common Risk Factors in the Returns on Stocks and Bonds,” Journal of Financial Economics. 1993.

My online courses are closed for enrollment.