diff --git a/.ipynb_checkpoints/ffm_regression2-checkpoint.ipynb b/.ipynb_checkpoints/ffm_regression2-checkpoint.ipynb
new file mode 100644
index 0000000..7334620
--- /dev/null
+++ b/.ipynb_checkpoints/ffm_regression2-checkpoint.ipynb
@@ -0,0 +1,940 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pandas as pd\n",
+ "import numpy as np\n",
+ "from sklearn import linear_model\n",
+ "from pathlib import Path\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "stock_csv_path = Path('monthly_data.csv')\n",
+ "monthly_df = pd.read_csv(stock_csv_path, index_col = 'Date')\n",
+ "monthly_df_daily_returns = monthly_df.pct_change()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " DXC | \n",
+ " BBY | \n",
+ " AMG | \n",
+ " CNP | \n",
+ " WMT | \n",
+ " MRK | \n",
+ " NEM | \n",
+ " VFC | \n",
+ " MDT | \n",
+ " HST | \n",
+ " ... | \n",
+ " UNH | \n",
+ " HSY | \n",
+ " FB | \n",
+ " EIX | \n",
+ " SBUX | \n",
+ " MCO | \n",
+ " HII | \n",
+ " RL | \n",
+ " LNT | \n",
+ " AXP | \n",
+ "
\n",
+ " \n",
+ " Date | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 2/27/2015 | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " ... | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ " 3/31/2015 | \n",
+ " -0.072857 | \n",
+ " -0.002622 | \n",
+ " -0.007578 | \n",
+ " -0.018278 | \n",
+ " -0.014131 | \n",
+ " -0.010162 | \n",
+ " -0.174545 | \n",
+ " -0.013202 | \n",
+ " 0.009122 | \n",
+ " -0.029476 | \n",
+ " ... | \n",
+ " 0.044493 | \n",
+ " -0.027654 | \n",
+ " 0.041155 | \n",
+ " -0.021137 | \n",
+ " 0.012942 | \n",
+ " 0.070765 | \n",
+ " -0.005552 | \n",
+ " -0.039418 | \n",
+ " -0.009434 | \n",
+ " -0.039329 | \n",
+ "
\n",
+ " \n",
+ " 4/30/2015 | \n",
+ " -0.012714 | \n",
+ " -0.083091 | \n",
+ " 0.052845 | \n",
+ " 0.027437 | \n",
+ " -0.051064 | \n",
+ " 0.036186 | \n",
+ " 0.220175 | \n",
+ " -0.038242 | \n",
+ " -0.045391 | \n",
+ " -0.001982 | \n",
+ " ... | \n",
+ " -0.058247 | \n",
+ " -0.089090 | \n",
+ " -0.041961 | \n",
+ " -0.024492 | \n",
+ " 0.047096 | \n",
+ " 0.035838 | \n",
+ " -0.061077 | \n",
+ " 0.014524 | \n",
+ " -0.031611 | \n",
+ " -0.008577 | \n",
+ "
\n",
+ " \n",
+ " 5/31/2015 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " ... | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " 6/30/2015 | \n",
+ " 0.025611 | \n",
+ " -0.052519 | \n",
+ " -0.033299 | \n",
+ " -0.081165 | \n",
+ " -0.085489 | \n",
+ " -0.036887 | \n",
+ " -0.117304 | \n",
+ " -0.032477 | \n",
+ " 0.000349 | \n",
+ " -0.005595 | \n",
+ " ... | \n",
+ " 0.099791 | \n",
+ " -0.028147 | \n",
+ " 0.088866 | \n",
+ " -0.081105 | \n",
+ " 0.084925 | \n",
+ " 0.007206 | \n",
+ " -0.141581 | \n",
+ " -0.004303 | \n",
+ " -0.045477 | \n",
+ " 0.007241 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
5 rows × 100 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " DXC BBY AMG CNP WMT MRK \\\n",
+ "Date \n",
+ "2/27/2015 NaN NaN NaN NaN NaN NaN \n",
+ "3/31/2015 -0.072857 -0.002622 -0.007578 -0.018278 -0.014131 -0.010162 \n",
+ "4/30/2015 -0.012714 -0.083091 0.052845 0.027437 -0.051064 0.036186 \n",
+ "5/31/2015 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n",
+ "6/30/2015 0.025611 -0.052519 -0.033299 -0.081165 -0.085489 -0.036887 \n",
+ "\n",
+ " NEM VFC MDT HST ... UNH HSY \\\n",
+ "Date ... \n",
+ "2/27/2015 NaN NaN NaN NaN ... NaN NaN \n",
+ "3/31/2015 -0.174545 -0.013202 0.009122 -0.029476 ... 0.044493 -0.027654 \n",
+ "4/30/2015 0.220175 -0.038242 -0.045391 -0.001982 ... -0.058247 -0.089090 \n",
+ "5/31/2015 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 \n",
+ "6/30/2015 -0.117304 -0.032477 0.000349 -0.005595 ... 0.099791 -0.028147 \n",
+ "\n",
+ " FB EIX SBUX MCO HII RL \\\n",
+ "Date \n",
+ "2/27/2015 NaN NaN NaN NaN NaN NaN \n",
+ "3/31/2015 0.041155 -0.021137 0.012942 0.070765 -0.005552 -0.039418 \n",
+ "4/30/2015 -0.041961 -0.024492 0.047096 0.035838 -0.061077 0.014524 \n",
+ "5/31/2015 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n",
+ "6/30/2015 0.088866 -0.081105 0.084925 0.007206 -0.141581 -0.004303 \n",
+ "\n",
+ " LNT AXP \n",
+ "Date \n",
+ "2/27/2015 NaN NaN \n",
+ "3/31/2015 -0.009434 -0.039329 \n",
+ "4/30/2015 -0.031611 -0.008577 \n",
+ "5/31/2015 0.000000 0.000000 \n",
+ "6/30/2015 -0.045477 0.007241 \n",
+ "\n",
+ "[5 rows x 100 columns]"
+ ]
+ },
+ "execution_count": 20,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "monthly_df_daily_returns.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(59, 100)"
+ ]
+ },
+ "execution_count": 21,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "monthly_df_daily_returns.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(58, 100)"
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "monthly_df_daily_returns.dropna(inplace = True)\n",
+ "monthly_df_daily_returns.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "monthly_df_daily_returns.index = pd.DatetimeIndex(monthly_df_daily_returns.index)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "DatetimeIndex(['2015-03-31', '2015-04-30', '2015-05-31', '2015-06-30',\n",
+ " '2015-07-31', '2015-08-31', '2015-09-30', '2015-10-31',\n",
+ " '2015-11-30', '2015-12-31', '2016-01-31', '2016-02-29',\n",
+ " '2016-03-31', '2016-04-30', '2016-05-31', '2016-06-30',\n",
+ " '2016-07-31', '2016-08-31', '2016-09-30', '2016-10-31',\n",
+ " '2016-11-30', '2016-12-31', '2017-01-31', '2017-02-28',\n",
+ " '2017-03-31', '2017-04-30', '2017-05-31', '2017-06-30',\n",
+ " '2017-07-31', '2017-08-31', '2017-09-30', '2017-10-31',\n",
+ " '2017-11-30', '2017-12-31', '2018-01-31', '2018-02-28',\n",
+ " '2018-03-31', '2018-04-30', '2018-05-31', '2018-06-30',\n",
+ " '2018-07-31', '2018-08-31', '2018-09-30', '2018-10-31',\n",
+ " '2018-11-30', '2018-12-31', '2019-01-31', '2019-02-28',\n",
+ " '2019-03-31', '2019-04-30', '2019-05-31', '2019-06-30',\n",
+ " '2019-07-31', '2019-08-31', '2019-09-30', '2019-10-31',\n",
+ " '2019-11-30', '2019-12-31'],\n",
+ " dtype='datetime64[ns]', name='Date', freq=None)"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "monthly_df_daily_returns.index"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(58, 4)"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "ffm_csv_path = Path('F-F_Research_Data_Factors.csv')\n",
+ "ffm_data = pd.read_csv(ffm_csv_path, index_col='Date')\n",
+ "ffm_data.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Index(['3/31/15', '4/30/15', '5/31/15', '6/30/15', '7/31/15', '8/31/15',\n",
+ " '9/30/15', '10/31/15', '11/30/15', '12/31/15', '1/31/16', '2/29/16',\n",
+ " '3/31/16', '4/30/16', '5/31/16', '6/30/16', '7/31/16', '8/31/16',\n",
+ " '9/30/16', '10/31/16', '11/30/16', '12/31/16', '1/31/17', '2/28/17',\n",
+ " '3/31/17', '4/30/17', '5/31/17', '6/30/17', '7/31/17', '8/31/17',\n",
+ " '9/30/17', '10/31/17', '11/30/17', '12/31/17', '1/31/18', '2/28/18',\n",
+ " '3/31/18', '4/30/18', '5/31/18', '6/30/18', '7/31/18', '8/31/18',\n",
+ " '9/30/18', '10/31/18', '11/30/18', '12/31/18', '1/31/19', '2/28/19',\n",
+ " '3/31/19', '4/30/19', '5/31/19', '6/30/19', '7/31/19', '8/31/19',\n",
+ " '9/30/19', '10/31/19', '11/30/19', '12/31/19'],\n",
+ " dtype='object', name='Date')"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "ffm_data.index"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ffm_data.index = pd.DatetimeIndex(ffm_data.index)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "reg = linear_model.LinearRegression()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "reg = linear_model.LinearRegression()\n",
+ "fit = reg.fit(X=ffm_data[['SMB','HML','RF']],\n",
+ " y=monthly_df_daily_returns.AAPL)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([ 0.00493159, -0.00134568, 0.15507276])"
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "fit.coef_"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import statsmodels.api as sm\n",
+ "from statsmodels.regression import linear_model as lm"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "temp_var = results_dict['AAPL']"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "results_dict = {}\n",
+ "params = {}\n",
+ "\n",
+ "for ticker in monthly_df_daily_returns.columns:\n",
+ " results_dict[ticker] = lm.OLS(endog=monthly_df_daily_returns.loc[:,ticker],\n",
+ " exog=sm.add_constant(ffm_data[['SMB','HML','RF']])).fit()\n",
+ " \n",
+ " params[ticker] = results_dict[ticker].params"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'DXC': const 0.054602\n",
+ " SMB 0.006667\n",
+ " HML -0.010830\n",
+ " RF -0.471852\n",
+ " dtype: float64, 'BBY': const 0.019541\n",
+ " SMB 0.002211\n",
+ " HML 0.004370\n",
+ " RF 0.037560\n",
+ " dtype: float64, 'AMG': const 0.000376\n",
+ " SMB 0.007329\n",
+ " HML 0.002759\n",
+ " RF -0.129089\n",
+ " dtype: float64, 'CNP': const 0.012997\n",
+ " SMB -0.001113\n",
+ " HML -0.000859\n",
+ " RF -0.048640\n",
+ " dtype: float64, 'WMT': const -0.000909\n",
+ " SMB -0.005975\n",
+ " HML 0.000550\n",
+ " RF 0.115350\n",
+ " dtype: float64, 'MRK': const 0.001373\n",
+ " SMB 0.000667\n",
+ " HML 0.000679\n",
+ " RF 0.121664\n",
+ " dtype: float64, 'NEM': const 0.016994\n",
+ " SMB -0.002308\n",
+ " HML -0.000540\n",
+ " RF -0.029715\n",
+ " dtype: float64, 'VFC': const -0.006049\n",
+ " SMB 0.001397\n",
+ " HML 0.002010\n",
+ " RF 0.197302\n",
+ " dtype: float64, 'MDT': const 0.003467\n",
+ " SMB 0.002080\n",
+ " HML -0.006028\n",
+ " RF 0.054285\n",
+ " dtype: float64, 'HST': const 0.001035\n",
+ " SMB 0.010113\n",
+ " HML 0.003301\n",
+ " RF 0.057921\n",
+ " dtype: float64, 'MTD': const 0.019620\n",
+ " SMB 0.003991\n",
+ " HML -0.003864\n",
+ " RF -0.018828\n",
+ " dtype: float64, 'CCI': const 0.007325\n",
+ " SMB -0.000576\n",
+ " HML -0.004602\n",
+ " RF 0.048203\n",
+ " dtype: float64, 'KMI': const -0.027913\n",
+ " SMB 0.011821\n",
+ " HML 0.005913\n",
+ " RF 0.321152\n",
+ " dtype: float64, 'RMD': const 0.009099\n",
+ " SMB 0.003927\n",
+ " HML -0.003076\n",
+ " RF 0.111120\n",
+ " dtype: float64, 'LUV': const 0.012251\n",
+ " SMB 0.005401\n",
+ " HML 0.000884\n",
+ " RF -0.036382\n",
+ " dtype: float64, 'NWS': const -0.002270\n",
+ " SMB 0.002310\n",
+ " HML 0.003681\n",
+ " RF 0.058211\n",
+ " dtype: float64, 'AMGN': const 0.009037\n",
+ " SMB 0.003206\n",
+ " HML -0.002195\n",
+ " RF 0.030524\n",
+ " dtype: float64, 'APD': const -0.001083\n",
+ " SMB 0.002608\n",
+ " HML 0.002296\n",
+ " RF 0.165393\n",
+ " dtype: float64, 'TGT': const -0.008147\n",
+ " SMB 0.001429\n",
+ " HML 0.009642\n",
+ " RF 0.302853\n",
+ " dtype: float64, 'MYL': const -0.002842\n",
+ " SMB 0.004527\n",
+ " HML 0.001895\n",
+ " RF -0.090977\n",
+ " dtype: float64, 'GPC': const 0.000800\n",
+ " SMB 0.005121\n",
+ " HML 0.000189\n",
+ " RF 0.062764\n",
+ " dtype: float64, 'FCX': const -0.001891\n",
+ " SMB 0.010998\n",
+ " HML 0.012395\n",
+ " RF 0.110709\n",
+ " dtype: float64, 'KO': const 0.000684\n",
+ " SMB -0.005419\n",
+ " HML 0.002014\n",
+ " RF 0.081595\n",
+ " dtype: float64, 'DISCK': const -0.009428\n",
+ " SMB 0.002983\n",
+ " HML 0.003645\n",
+ " RF 0.178962\n",
+ " dtype: float64, 'FISV': const 0.014536\n",
+ " SMB 0.002486\n",
+ " HML -0.001265\n",
+ " RF 0.064057\n",
+ " dtype: float64, 'ACN': const 0.016281\n",
+ " SMB 0.002845\n",
+ " HML -0.000670\n",
+ " RF 0.022446\n",
+ " dtype: float64, 'SRCL': const -0.022215\n",
+ " SMB 0.001094\n",
+ " HML 0.001069\n",
+ " RF 0.172978\n",
+ " dtype: float64, 'IT': const 0.013323\n",
+ " SMB 0.006997\n",
+ " HML 0.000762\n",
+ " RF 0.009617\n",
+ " dtype: float64, 'PHM': const 0.002120\n",
+ " SMB 0.005431\n",
+ " HML 0.002604\n",
+ " RF 0.145191\n",
+ " dtype: float64, 'ALB': const 0.033678\n",
+ " SMB 0.001754\n",
+ " HML -0.001914\n",
+ " RF -0.280653\n",
+ " dtype: float64, 'AAPL': const 0.005988\n",
+ " SMB 0.004932\n",
+ " HML -0.001346\n",
+ " RF 0.155073\n",
+ " dtype: float64, 'EFX': const 0.011079\n",
+ " SMB 0.005193\n",
+ " HML -0.005881\n",
+ " RF -0.013284\n",
+ " dtype: float64, 'FE': const -0.002451\n",
+ " SMB -0.001924\n",
+ " HML 0.000739\n",
+ " RF 0.145771\n",
+ " dtype: float64, 'COST': const 0.005980\n",
+ " SMB -0.001803\n",
+ " HML -0.000682\n",
+ " RF 0.102900\n",
+ " dtype: float64, 'GWW': const 0.002411\n",
+ " SMB 0.006431\n",
+ " HML 0.003227\n",
+ " RF 0.124559\n",
+ " dtype: float64, 'M': const -0.011542\n",
+ " SMB 0.005896\n",
+ " HML 0.004078\n",
+ " RF 0.025431\n",
+ " dtype: float64, 'CRM': const 0.014873\n",
+ " SMB -0.000074\n",
+ " HML -0.005548\n",
+ " RF -0.000396\n",
+ " dtype: float64, 'LKQ': const 0.014538\n",
+ " SMB 0.005347\n",
+ " HML 0.001513\n",
+ " RF -0.047619\n",
+ " dtype: float64, 'AON': const 0.006681\n",
+ " SMB 0.001586\n",
+ " HML 0.000944\n",
+ " RF 0.097052\n",
+ " dtype: float64, 'PEP': const 0.004087\n",
+ " SMB -0.002782\n",
+ " HML 0.000271\n",
+ " RF 0.053900\n",
+ " dtype: float64, 'RJF': const 0.018682\n",
+ " SMB 0.009820\n",
+ " HML 0.004638\n",
+ " RF -0.045672\n",
+ " dtype: float64, 'ORCL': const 0.001090\n",
+ " SMB 0.002700\n",
+ " HML 0.000762\n",
+ " RF 0.060270\n",
+ " dtype: float64, 'MHK': const 0.014373\n",
+ " SMB 0.009916\n",
+ " HML -0.006904\n",
+ " RF -0.202153\n",
+ " dtype: float64, 'PPL': const 0.006572\n",
+ " SMB -0.001814\n",
+ " HML -0.000341\n",
+ " RF 0.004824\n",
+ " dtype: float64, 'FMC': const 0.008033\n",
+ " SMB 0.010667\n",
+ " HML 0.000197\n",
+ " RF 0.104410\n",
+ " dtype: float64, 'OKE': const 0.013576\n",
+ " SMB 0.008781\n",
+ " HML 0.004585\n",
+ " RF 0.086364\n",
+ " dtype: float64, 'EQR': const -0.003910\n",
+ " SMB 0.001709\n",
+ " HML -0.000817\n",
+ " RF 0.124130\n",
+ " dtype: float64, 'RCL': const 0.019752\n",
+ " SMB 0.003941\n",
+ " HML -0.005637\n",
+ " RF -0.063044\n",
+ " dtype: float64, 'IRM': const 0.004095\n",
+ " SMB 0.003249\n",
+ " HML -0.001111\n",
+ " RF 0.015229\n",
+ " dtype: float64, 'BA': const 0.021117\n",
+ " SMB -0.000208\n",
+ " HML 0.000754\n",
+ " RF -0.027618\n",
+ " dtype: float64, 'ABC': const -0.001830\n",
+ " SMB 0.003802\n",
+ " HML -0.001026\n",
+ " RF 0.032676\n",
+ " dtype: float64, 'GIS': const 0.000944\n",
+ " SMB 0.000799\n",
+ " HML 0.001153\n",
+ " RF 0.046156\n",
+ " dtype: float64, 'SYF': const 0.001133\n",
+ " SMB 0.010176\n",
+ " HML 0.004036\n",
+ " RF 0.097664\n",
+ " dtype: float64, 'BMY': const 0.007596\n",
+ " SMB 0.004047\n",
+ " HML -0.001775\n",
+ " RF -0.017003\n",
+ " dtype: float64, 'ADBE': const 0.026194\n",
+ " SMB 0.003425\n",
+ " HML -0.005826\n",
+ " RF -0.008753\n",
+ " dtype: float64, 'SNPS': const 0.013601\n",
+ " SMB 0.004408\n",
+ " HML -0.001289\n",
+ " RF 0.087158\n",
+ " dtype: float64, 'BWA': const -0.007120\n",
+ " SMB 0.003750\n",
+ " HML 0.002314\n",
+ " RF 0.079303\n",
+ " dtype: float64, 'MSI': const 0.009732\n",
+ " SMB 0.005207\n",
+ " HML 0.002410\n",
+ " RF 0.119599\n",
+ " dtype: float64, 'COF': const 0.007187\n",
+ " SMB 0.007294\n",
+ " HML 0.006504\n",
+ " RF 0.053618\n",
+ " dtype: float64, 'LYB': const 0.010861\n",
+ " SMB 0.007371\n",
+ " HML 0.007171\n",
+ " RF 0.000326\n",
+ " dtype: float64, 'RTN': const 0.022820\n",
+ " SMB 0.002863\n",
+ " HML -0.002937\n",
+ " RF -0.092745\n",
+ " dtype: float64, 'FFIV': const 0.011258\n",
+ " SMB 0.000107\n",
+ " HML -0.000844\n",
+ " RF -0.081548\n",
+ " dtype: float64, 'HLT': const 0.003496\n",
+ " SMB 0.003717\n",
+ " HML -0.000632\n",
+ " RF 0.120956\n",
+ " dtype: float64, 'CVS': const -0.007681\n",
+ " SMB -0.001042\n",
+ " HML 0.000158\n",
+ " RF 0.069121\n",
+ " dtype: float64, 'NEE': const 0.012106\n",
+ " SMB -0.003592\n",
+ " HML -0.002758\n",
+ " RF 0.055872\n",
+ " dtype: float64, 'KMX': const -0.005108\n",
+ " SMB 0.003210\n",
+ " HML 0.003810\n",
+ " RF 0.166041\n",
+ " dtype: float64, 'INCY': const 0.011598\n",
+ " SMB 0.013601\n",
+ " HML -0.007199\n",
+ " RF -0.072670\n",
+ " dtype: float64, 'MGM': const 0.016231\n",
+ " SMB 0.003770\n",
+ " HML 0.000803\n",
+ " RF -0.048515\n",
+ " dtype: float64, 'AES': const -0.005298\n",
+ " SMB 0.004959\n",
+ " HML -0.000526\n",
+ " RF 0.218827\n",
+ " dtype: float64, 'GM': const 0.003766\n",
+ " SMB 0.008070\n",
+ " HML 0.002941\n",
+ " RF 0.052166\n",
+ " dtype: float64, 'FDX': const 0.013414\n",
+ " SMB 0.006983\n",
+ " HML 0.000363\n",
+ " RF -0.131301\n",
+ " dtype: float64, 'ADP': const 0.007503\n",
+ " SMB 0.004284\n",
+ " HML 0.000618\n",
+ " RF 0.090903\n",
+ " dtype: float64, 'HOLX': const 0.007978\n",
+ " SMB 0.002835\n",
+ " HML 0.001912\n",
+ " RF 0.034877\n",
+ " dtype: float64, 'NRG': const 0.004716\n",
+ " SMB 0.003993\n",
+ " HML -0.001240\n",
+ " RF 0.141942\n",
+ " dtype: float64, 'NBL': const -0.012247\n",
+ " SMB 0.012066\n",
+ " HML 0.010516\n",
+ " RF 0.152819\n",
+ " dtype: float64, 'MSFT': const 0.022565\n",
+ " SMB -0.002318\n",
+ " HML 0.001699\n",
+ " RF 0.042636\n",
+ " dtype: float64, 'COG': const -0.002901\n",
+ " SMB 0.007995\n",
+ " HML -0.000315\n",
+ " RF -0.012510\n",
+ " dtype: float64, 'OXY': const 0.005643\n",
+ " SMB 0.007829\n",
+ " HML -0.000082\n",
+ " RF -0.105655\n",
+ " dtype: float64, 'GOOGL': const 0.023360\n",
+ " SMB -0.001914\n",
+ " HML -0.004818\n",
+ " RF -0.094033\n",
+ " dtype: float64, 'GS': const 0.009674\n",
+ " SMB 0.003897\n",
+ " HML 0.008605\n",
+ " RF 0.009771\n",
+ " dtype: float64, 'HRB': const -0.002286\n",
+ " SMB 0.000981\n",
+ " HML -0.005757\n",
+ " RF 0.000230\n",
+ " dtype: float64, 'AJG': const 0.009557\n",
+ " SMB 0.000763\n",
+ " HML 0.001040\n",
+ " RF 0.074273\n",
+ " dtype: float64, 'CINF': const 0.010693\n",
+ " SMB 0.001783\n",
+ " HML 0.002503\n",
+ " RF 0.071726\n",
+ " dtype: float64, 'TXN': const 0.015741\n",
+ " SMB 0.004391\n",
+ " HML 0.000626\n",
+ " RF 0.034913\n",
+ " dtype: float64, 'ETN': const 0.003890\n",
+ " SMB 0.007716\n",
+ " HML 0.002059\n",
+ " RF 0.090844\n",
+ " dtype: float64, 'EXPE': const 0.015295\n",
+ " SMB -0.000372\n",
+ " HML -0.002536\n",
+ " RF -0.114739\n",
+ " dtype: float64, 'TMO': const 0.010901\n",
+ " SMB 0.000543\n",
+ " HML -0.004054\n",
+ " RF 0.068159\n",
+ " dtype: float64, 'BSX': const 0.015858\n",
+ " SMB 0.003105\n",
+ " HML -0.007019\n",
+ " RF 0.014305\n",
+ " dtype: float64, 'CTAS': const 0.016999\n",
+ " SMB 0.006533\n",
+ " HML 0.000280\n",
+ " RF 0.082512\n",
+ " dtype: float64, 'WBA': const 0.003260\n",
+ " SMB -0.002313\n",
+ " HML 0.001379\n",
+ " RF -0.054945\n",
+ " dtype: float64, 'UNH': const 0.023115\n",
+ " SMB 0.004480\n",
+ " HML -0.002035\n",
+ " RF -0.043002\n",
+ " dtype: float64, 'HSY': const -0.002364\n",
+ " SMB -0.007383\n",
+ " HML -0.001692\n",
+ " RF 0.122579\n",
+ " dtype: float64, 'FB': const 0.024876\n",
+ " SMB 0.005878\n",
+ " HML -0.007652\n",
+ " RF -0.084624\n",
+ " dtype: float64, 'EIX': const 0.005676\n",
+ " SMB -0.006059\n",
+ " HML 0.001479\n",
+ " RF 0.030555\n",
+ " dtype: float64, 'SBUX': const 0.004142\n",
+ " SMB -0.000443\n",
+ " HML 0.001478\n",
+ " RF 0.120032\n",
+ " dtype: float64, 'MCO': const 0.010974\n",
+ " SMB 0.006066\n",
+ " HML -0.003062\n",
+ " RF 0.091236\n",
+ " dtype: float64, 'HII': const 0.019722\n",
+ " SMB 0.001667\n",
+ " HML -0.000449\n",
+ " RF -0.071924\n",
+ " dtype: float64, 'RL': const -0.008081\n",
+ " SMB 0.009828\n",
+ " HML 0.004103\n",
+ " RF 0.161168\n",
+ " dtype: float64, 'LNT': const 0.009055\n",
+ " SMB -0.001988\n",
+ " HML -0.001094\n",
+ " RF 0.039521\n",
+ " dtype: float64, 'AXP': const 0.001631\n",
+ " SMB 0.002037\n",
+ " HML 0.003925\n",
+ " RF 0.117401\n",
+ " dtype: float64}"
+ ]
+ },
+ "execution_count": 41,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "params"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.7.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
diff --git a/ffm_regression2.ipynb b/ffm_regression2.ipynb
new file mode 100644
index 0000000..7334620
--- /dev/null
+++ b/ffm_regression2.ipynb
@@ -0,0 +1,940 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pandas as pd\n",
+ "import numpy as np\n",
+ "from sklearn import linear_model\n",
+ "from pathlib import Path\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "stock_csv_path = Path('monthly_data.csv')\n",
+ "monthly_df = pd.read_csv(stock_csv_path, index_col = 'Date')\n",
+ "monthly_df_daily_returns = monthly_df.pct_change()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " DXC | \n",
+ " BBY | \n",
+ " AMG | \n",
+ " CNP | \n",
+ " WMT | \n",
+ " MRK | \n",
+ " NEM | \n",
+ " VFC | \n",
+ " MDT | \n",
+ " HST | \n",
+ " ... | \n",
+ " UNH | \n",
+ " HSY | \n",
+ " FB | \n",
+ " EIX | \n",
+ " SBUX | \n",
+ " MCO | \n",
+ " HII | \n",
+ " RL | \n",
+ " LNT | \n",
+ " AXP | \n",
+ "
\n",
+ " \n",
+ " Date | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 2/27/2015 | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " ... | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ " NaN | \n",
+ "
\n",
+ " \n",
+ " 3/31/2015 | \n",
+ " -0.072857 | \n",
+ " -0.002622 | \n",
+ " -0.007578 | \n",
+ " -0.018278 | \n",
+ " -0.014131 | \n",
+ " -0.010162 | \n",
+ " -0.174545 | \n",
+ " -0.013202 | \n",
+ " 0.009122 | \n",
+ " -0.029476 | \n",
+ " ... | \n",
+ " 0.044493 | \n",
+ " -0.027654 | \n",
+ " 0.041155 | \n",
+ " -0.021137 | \n",
+ " 0.012942 | \n",
+ " 0.070765 | \n",
+ " -0.005552 | \n",
+ " -0.039418 | \n",
+ " -0.009434 | \n",
+ " -0.039329 | \n",
+ "
\n",
+ " \n",
+ " 4/30/2015 | \n",
+ " -0.012714 | \n",
+ " -0.083091 | \n",
+ " 0.052845 | \n",
+ " 0.027437 | \n",
+ " -0.051064 | \n",
+ " 0.036186 | \n",
+ " 0.220175 | \n",
+ " -0.038242 | \n",
+ " -0.045391 | \n",
+ " -0.001982 | \n",
+ " ... | \n",
+ " -0.058247 | \n",
+ " -0.089090 | \n",
+ " -0.041961 | \n",
+ " -0.024492 | \n",
+ " 0.047096 | \n",
+ " 0.035838 | \n",
+ " -0.061077 | \n",
+ " 0.014524 | \n",
+ " -0.031611 | \n",
+ " -0.008577 | \n",
+ "
\n",
+ " \n",
+ " 5/31/2015 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " ... | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " 6/30/2015 | \n",
+ " 0.025611 | \n",
+ " -0.052519 | \n",
+ " -0.033299 | \n",
+ " -0.081165 | \n",
+ " -0.085489 | \n",
+ " -0.036887 | \n",
+ " -0.117304 | \n",
+ " -0.032477 | \n",
+ " 0.000349 | \n",
+ " -0.005595 | \n",
+ " ... | \n",
+ " 0.099791 | \n",
+ " -0.028147 | \n",
+ " 0.088866 | \n",
+ " -0.081105 | \n",
+ " 0.084925 | \n",
+ " 0.007206 | \n",
+ " -0.141581 | \n",
+ " -0.004303 | \n",
+ " -0.045477 | \n",
+ " 0.007241 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
5 rows × 100 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " DXC BBY AMG CNP WMT MRK \\\n",
+ "Date \n",
+ "2/27/2015 NaN NaN NaN NaN NaN NaN \n",
+ "3/31/2015 -0.072857 -0.002622 -0.007578 -0.018278 -0.014131 -0.010162 \n",
+ "4/30/2015 -0.012714 -0.083091 0.052845 0.027437 -0.051064 0.036186 \n",
+ "5/31/2015 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n",
+ "6/30/2015 0.025611 -0.052519 -0.033299 -0.081165 -0.085489 -0.036887 \n",
+ "\n",
+ " NEM VFC MDT HST ... UNH HSY \\\n",
+ "Date ... \n",
+ "2/27/2015 NaN NaN NaN NaN ... NaN NaN \n",
+ "3/31/2015 -0.174545 -0.013202 0.009122 -0.029476 ... 0.044493 -0.027654 \n",
+ "4/30/2015 0.220175 -0.038242 -0.045391 -0.001982 ... -0.058247 -0.089090 \n",
+ "5/31/2015 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 \n",
+ "6/30/2015 -0.117304 -0.032477 0.000349 -0.005595 ... 0.099791 -0.028147 \n",
+ "\n",
+ " FB EIX SBUX MCO HII RL \\\n",
+ "Date \n",
+ "2/27/2015 NaN NaN NaN NaN NaN NaN \n",
+ "3/31/2015 0.041155 -0.021137 0.012942 0.070765 -0.005552 -0.039418 \n",
+ "4/30/2015 -0.041961 -0.024492 0.047096 0.035838 -0.061077 0.014524 \n",
+ "5/31/2015 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 \n",
+ "6/30/2015 0.088866 -0.081105 0.084925 0.007206 -0.141581 -0.004303 \n",
+ "\n",
+ " LNT AXP \n",
+ "Date \n",
+ "2/27/2015 NaN NaN \n",
+ "3/31/2015 -0.009434 -0.039329 \n",
+ "4/30/2015 -0.031611 -0.008577 \n",
+ "5/31/2015 0.000000 0.000000 \n",
+ "6/30/2015 -0.045477 0.007241 \n",
+ "\n",
+ "[5 rows x 100 columns]"
+ ]
+ },
+ "execution_count": 20,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "monthly_df_daily_returns.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(59, 100)"
+ ]
+ },
+ "execution_count": 21,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "monthly_df_daily_returns.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(58, 100)"
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "monthly_df_daily_returns.dropna(inplace = True)\n",
+ "monthly_df_daily_returns.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "monthly_df_daily_returns.index = pd.DatetimeIndex(monthly_df_daily_returns.index)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "DatetimeIndex(['2015-03-31', '2015-04-30', '2015-05-31', '2015-06-30',\n",
+ " '2015-07-31', '2015-08-31', '2015-09-30', '2015-10-31',\n",
+ " '2015-11-30', '2015-12-31', '2016-01-31', '2016-02-29',\n",
+ " '2016-03-31', '2016-04-30', '2016-05-31', '2016-06-30',\n",
+ " '2016-07-31', '2016-08-31', '2016-09-30', '2016-10-31',\n",
+ " '2016-11-30', '2016-12-31', '2017-01-31', '2017-02-28',\n",
+ " '2017-03-31', '2017-04-30', '2017-05-31', '2017-06-30',\n",
+ " '2017-07-31', '2017-08-31', '2017-09-30', '2017-10-31',\n",
+ " '2017-11-30', '2017-12-31', '2018-01-31', '2018-02-28',\n",
+ " '2018-03-31', '2018-04-30', '2018-05-31', '2018-06-30',\n",
+ " '2018-07-31', '2018-08-31', '2018-09-30', '2018-10-31',\n",
+ " '2018-11-30', '2018-12-31', '2019-01-31', '2019-02-28',\n",
+ " '2019-03-31', '2019-04-30', '2019-05-31', '2019-06-30',\n",
+ " '2019-07-31', '2019-08-31', '2019-09-30', '2019-10-31',\n",
+ " '2019-11-30', '2019-12-31'],\n",
+ " dtype='datetime64[ns]', name='Date', freq=None)"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "monthly_df_daily_returns.index"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(58, 4)"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "ffm_csv_path = Path('F-F_Research_Data_Factors.csv')\n",
+ "ffm_data = pd.read_csv(ffm_csv_path, index_col='Date')\n",
+ "ffm_data.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Index(['3/31/15', '4/30/15', '5/31/15', '6/30/15', '7/31/15', '8/31/15',\n",
+ " '9/30/15', '10/31/15', '11/30/15', '12/31/15', '1/31/16', '2/29/16',\n",
+ " '3/31/16', '4/30/16', '5/31/16', '6/30/16', '7/31/16', '8/31/16',\n",
+ " '9/30/16', '10/31/16', '11/30/16', '12/31/16', '1/31/17', '2/28/17',\n",
+ " '3/31/17', '4/30/17', '5/31/17', '6/30/17', '7/31/17', '8/31/17',\n",
+ " '9/30/17', '10/31/17', '11/30/17', '12/31/17', '1/31/18', '2/28/18',\n",
+ " '3/31/18', '4/30/18', '5/31/18', '6/30/18', '7/31/18', '8/31/18',\n",
+ " '9/30/18', '10/31/18', '11/30/18', '12/31/18', '1/31/19', '2/28/19',\n",
+ " '3/31/19', '4/30/19', '5/31/19', '6/30/19', '7/31/19', '8/31/19',\n",
+ " '9/30/19', '10/31/19', '11/30/19', '12/31/19'],\n",
+ " dtype='object', name='Date')"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "ffm_data.index"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ffm_data.index = pd.DatetimeIndex(ffm_data.index)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "reg = linear_model.LinearRegression()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "reg = linear_model.LinearRegression()\n",
+ "fit = reg.fit(X=ffm_data[['SMB','HML','RF']],\n",
+ " y=monthly_df_daily_returns.AAPL)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([ 0.00493159, -0.00134568, 0.15507276])"
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "fit.coef_"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import statsmodels.api as sm\n",
+ "from statsmodels.regression import linear_model as lm"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "temp_var = results_dict['AAPL']"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "results_dict = {}\n",
+ "params = {}\n",
+ "\n",
+ "for ticker in monthly_df_daily_returns.columns:\n",
+ " results_dict[ticker] = lm.OLS(endog=monthly_df_daily_returns.loc[:,ticker],\n",
+ " exog=sm.add_constant(ffm_data[['SMB','HML','RF']])).fit()\n",
+ " \n",
+ " params[ticker] = results_dict[ticker].params"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'DXC': const 0.054602\n",
+ " SMB 0.006667\n",
+ " HML -0.010830\n",
+ " RF -0.471852\n",
+ " dtype: float64, 'BBY': const 0.019541\n",
+ " SMB 0.002211\n",
+ " HML 0.004370\n",
+ " RF 0.037560\n",
+ " dtype: float64, 'AMG': const 0.000376\n",
+ " SMB 0.007329\n",
+ " HML 0.002759\n",
+ " RF -0.129089\n",
+ " dtype: float64, 'CNP': const 0.012997\n",
+ " SMB -0.001113\n",
+ " HML -0.000859\n",
+ " RF -0.048640\n",
+ " dtype: float64, 'WMT': const -0.000909\n",
+ " SMB -0.005975\n",
+ " HML 0.000550\n",
+ " RF 0.115350\n",
+ " dtype: float64, 'MRK': const 0.001373\n",
+ " SMB 0.000667\n",
+ " HML 0.000679\n",
+ " RF 0.121664\n",
+ " dtype: float64, 'NEM': const 0.016994\n",
+ " SMB -0.002308\n",
+ " HML -0.000540\n",
+ " RF -0.029715\n",
+ " dtype: float64, 'VFC': const -0.006049\n",
+ " SMB 0.001397\n",
+ " HML 0.002010\n",
+ " RF 0.197302\n",
+ " dtype: float64, 'MDT': const 0.003467\n",
+ " SMB 0.002080\n",
+ " HML -0.006028\n",
+ " RF 0.054285\n",
+ " dtype: float64, 'HST': const 0.001035\n",
+ " SMB 0.010113\n",
+ " HML 0.003301\n",
+ " RF 0.057921\n",
+ " dtype: float64, 'MTD': const 0.019620\n",
+ " SMB 0.003991\n",
+ " HML -0.003864\n",
+ " RF -0.018828\n",
+ " dtype: float64, 'CCI': const 0.007325\n",
+ " SMB -0.000576\n",
+ " HML -0.004602\n",
+ " RF 0.048203\n",
+ " dtype: float64, 'KMI': const -0.027913\n",
+ " SMB 0.011821\n",
+ " HML 0.005913\n",
+ " RF 0.321152\n",
+ " dtype: float64, 'RMD': const 0.009099\n",
+ " SMB 0.003927\n",
+ " HML -0.003076\n",
+ " RF 0.111120\n",
+ " dtype: float64, 'LUV': const 0.012251\n",
+ " SMB 0.005401\n",
+ " HML 0.000884\n",
+ " RF -0.036382\n",
+ " dtype: float64, 'NWS': const -0.002270\n",
+ " SMB 0.002310\n",
+ " HML 0.003681\n",
+ " RF 0.058211\n",
+ " dtype: float64, 'AMGN': const 0.009037\n",
+ " SMB 0.003206\n",
+ " HML -0.002195\n",
+ " RF 0.030524\n",
+ " dtype: float64, 'APD': const -0.001083\n",
+ " SMB 0.002608\n",
+ " HML 0.002296\n",
+ " RF 0.165393\n",
+ " dtype: float64, 'TGT': const -0.008147\n",
+ " SMB 0.001429\n",
+ " HML 0.009642\n",
+ " RF 0.302853\n",
+ " dtype: float64, 'MYL': const -0.002842\n",
+ " SMB 0.004527\n",
+ " HML 0.001895\n",
+ " RF -0.090977\n",
+ " dtype: float64, 'GPC': const 0.000800\n",
+ " SMB 0.005121\n",
+ " HML 0.000189\n",
+ " RF 0.062764\n",
+ " dtype: float64, 'FCX': const -0.001891\n",
+ " SMB 0.010998\n",
+ " HML 0.012395\n",
+ " RF 0.110709\n",
+ " dtype: float64, 'KO': const 0.000684\n",
+ " SMB -0.005419\n",
+ " HML 0.002014\n",
+ " RF 0.081595\n",
+ " dtype: float64, 'DISCK': const -0.009428\n",
+ " SMB 0.002983\n",
+ " HML 0.003645\n",
+ " RF 0.178962\n",
+ " dtype: float64, 'FISV': const 0.014536\n",
+ " SMB 0.002486\n",
+ " HML -0.001265\n",
+ " RF 0.064057\n",
+ " dtype: float64, 'ACN': const 0.016281\n",
+ " SMB 0.002845\n",
+ " HML -0.000670\n",
+ " RF 0.022446\n",
+ " dtype: float64, 'SRCL': const -0.022215\n",
+ " SMB 0.001094\n",
+ " HML 0.001069\n",
+ " RF 0.172978\n",
+ " dtype: float64, 'IT': const 0.013323\n",
+ " SMB 0.006997\n",
+ " HML 0.000762\n",
+ " RF 0.009617\n",
+ " dtype: float64, 'PHM': const 0.002120\n",
+ " SMB 0.005431\n",
+ " HML 0.002604\n",
+ " RF 0.145191\n",
+ " dtype: float64, 'ALB': const 0.033678\n",
+ " SMB 0.001754\n",
+ " HML -0.001914\n",
+ " RF -0.280653\n",
+ " dtype: float64, 'AAPL': const 0.005988\n",
+ " SMB 0.004932\n",
+ " HML -0.001346\n",
+ " RF 0.155073\n",
+ " dtype: float64, 'EFX': const 0.011079\n",
+ " SMB 0.005193\n",
+ " HML -0.005881\n",
+ " RF -0.013284\n",
+ " dtype: float64, 'FE': const -0.002451\n",
+ " SMB -0.001924\n",
+ " HML 0.000739\n",
+ " RF 0.145771\n",
+ " dtype: float64, 'COST': const 0.005980\n",
+ " SMB -0.001803\n",
+ " HML -0.000682\n",
+ " RF 0.102900\n",
+ " dtype: float64, 'GWW': const 0.002411\n",
+ " SMB 0.006431\n",
+ " HML 0.003227\n",
+ " RF 0.124559\n",
+ " dtype: float64, 'M': const -0.011542\n",
+ " SMB 0.005896\n",
+ " HML 0.004078\n",
+ " RF 0.025431\n",
+ " dtype: float64, 'CRM': const 0.014873\n",
+ " SMB -0.000074\n",
+ " HML -0.005548\n",
+ " RF -0.000396\n",
+ " dtype: float64, 'LKQ': const 0.014538\n",
+ " SMB 0.005347\n",
+ " HML 0.001513\n",
+ " RF -0.047619\n",
+ " dtype: float64, 'AON': const 0.006681\n",
+ " SMB 0.001586\n",
+ " HML 0.000944\n",
+ " RF 0.097052\n",
+ " dtype: float64, 'PEP': const 0.004087\n",
+ " SMB -0.002782\n",
+ " HML 0.000271\n",
+ " RF 0.053900\n",
+ " dtype: float64, 'RJF': const 0.018682\n",
+ " SMB 0.009820\n",
+ " HML 0.004638\n",
+ " RF -0.045672\n",
+ " dtype: float64, 'ORCL': const 0.001090\n",
+ " SMB 0.002700\n",
+ " HML 0.000762\n",
+ " RF 0.060270\n",
+ " dtype: float64, 'MHK': const 0.014373\n",
+ " SMB 0.009916\n",
+ " HML -0.006904\n",
+ " RF -0.202153\n",
+ " dtype: float64, 'PPL': const 0.006572\n",
+ " SMB -0.001814\n",
+ " HML -0.000341\n",
+ " RF 0.004824\n",
+ " dtype: float64, 'FMC': const 0.008033\n",
+ " SMB 0.010667\n",
+ " HML 0.000197\n",
+ " RF 0.104410\n",
+ " dtype: float64, 'OKE': const 0.013576\n",
+ " SMB 0.008781\n",
+ " HML 0.004585\n",
+ " RF 0.086364\n",
+ " dtype: float64, 'EQR': const -0.003910\n",
+ " SMB 0.001709\n",
+ " HML -0.000817\n",
+ " RF 0.124130\n",
+ " dtype: float64, 'RCL': const 0.019752\n",
+ " SMB 0.003941\n",
+ " HML -0.005637\n",
+ " RF -0.063044\n",
+ " dtype: float64, 'IRM': const 0.004095\n",
+ " SMB 0.003249\n",
+ " HML -0.001111\n",
+ " RF 0.015229\n",
+ " dtype: float64, 'BA': const 0.021117\n",
+ " SMB -0.000208\n",
+ " HML 0.000754\n",
+ " RF -0.027618\n",
+ " dtype: float64, 'ABC': const -0.001830\n",
+ " SMB 0.003802\n",
+ " HML -0.001026\n",
+ " RF 0.032676\n",
+ " dtype: float64, 'GIS': const 0.000944\n",
+ " SMB 0.000799\n",
+ " HML 0.001153\n",
+ " RF 0.046156\n",
+ " dtype: float64, 'SYF': const 0.001133\n",
+ " SMB 0.010176\n",
+ " HML 0.004036\n",
+ " RF 0.097664\n",
+ " dtype: float64, 'BMY': const 0.007596\n",
+ " SMB 0.004047\n",
+ " HML -0.001775\n",
+ " RF -0.017003\n",
+ " dtype: float64, 'ADBE': const 0.026194\n",
+ " SMB 0.003425\n",
+ " HML -0.005826\n",
+ " RF -0.008753\n",
+ " dtype: float64, 'SNPS': const 0.013601\n",
+ " SMB 0.004408\n",
+ " HML -0.001289\n",
+ " RF 0.087158\n",
+ " dtype: float64, 'BWA': const -0.007120\n",
+ " SMB 0.003750\n",
+ " HML 0.002314\n",
+ " RF 0.079303\n",
+ " dtype: float64, 'MSI': const 0.009732\n",
+ " SMB 0.005207\n",
+ " HML 0.002410\n",
+ " RF 0.119599\n",
+ " dtype: float64, 'COF': const 0.007187\n",
+ " SMB 0.007294\n",
+ " HML 0.006504\n",
+ " RF 0.053618\n",
+ " dtype: float64, 'LYB': const 0.010861\n",
+ " SMB 0.007371\n",
+ " HML 0.007171\n",
+ " RF 0.000326\n",
+ " dtype: float64, 'RTN': const 0.022820\n",
+ " SMB 0.002863\n",
+ " HML -0.002937\n",
+ " RF -0.092745\n",
+ " dtype: float64, 'FFIV': const 0.011258\n",
+ " SMB 0.000107\n",
+ " HML -0.000844\n",
+ " RF -0.081548\n",
+ " dtype: float64, 'HLT': const 0.003496\n",
+ " SMB 0.003717\n",
+ " HML -0.000632\n",
+ " RF 0.120956\n",
+ " dtype: float64, 'CVS': const -0.007681\n",
+ " SMB -0.001042\n",
+ " HML 0.000158\n",
+ " RF 0.069121\n",
+ " dtype: float64, 'NEE': const 0.012106\n",
+ " SMB -0.003592\n",
+ " HML -0.002758\n",
+ " RF 0.055872\n",
+ " dtype: float64, 'KMX': const -0.005108\n",
+ " SMB 0.003210\n",
+ " HML 0.003810\n",
+ " RF 0.166041\n",
+ " dtype: float64, 'INCY': const 0.011598\n",
+ " SMB 0.013601\n",
+ " HML -0.007199\n",
+ " RF -0.072670\n",
+ " dtype: float64, 'MGM': const 0.016231\n",
+ " SMB 0.003770\n",
+ " HML 0.000803\n",
+ " RF -0.048515\n",
+ " dtype: float64, 'AES': const -0.005298\n",
+ " SMB 0.004959\n",
+ " HML -0.000526\n",
+ " RF 0.218827\n",
+ " dtype: float64, 'GM': const 0.003766\n",
+ " SMB 0.008070\n",
+ " HML 0.002941\n",
+ " RF 0.052166\n",
+ " dtype: float64, 'FDX': const 0.013414\n",
+ " SMB 0.006983\n",
+ " HML 0.000363\n",
+ " RF -0.131301\n",
+ " dtype: float64, 'ADP': const 0.007503\n",
+ " SMB 0.004284\n",
+ " HML 0.000618\n",
+ " RF 0.090903\n",
+ " dtype: float64, 'HOLX': const 0.007978\n",
+ " SMB 0.002835\n",
+ " HML 0.001912\n",
+ " RF 0.034877\n",
+ " dtype: float64, 'NRG': const 0.004716\n",
+ " SMB 0.003993\n",
+ " HML -0.001240\n",
+ " RF 0.141942\n",
+ " dtype: float64, 'NBL': const -0.012247\n",
+ " SMB 0.012066\n",
+ " HML 0.010516\n",
+ " RF 0.152819\n",
+ " dtype: float64, 'MSFT': const 0.022565\n",
+ " SMB -0.002318\n",
+ " HML 0.001699\n",
+ " RF 0.042636\n",
+ " dtype: float64, 'COG': const -0.002901\n",
+ " SMB 0.007995\n",
+ " HML -0.000315\n",
+ " RF -0.012510\n",
+ " dtype: float64, 'OXY': const 0.005643\n",
+ " SMB 0.007829\n",
+ " HML -0.000082\n",
+ " RF -0.105655\n",
+ " dtype: float64, 'GOOGL': const 0.023360\n",
+ " SMB -0.001914\n",
+ " HML -0.004818\n",
+ " RF -0.094033\n",
+ " dtype: float64, 'GS': const 0.009674\n",
+ " SMB 0.003897\n",
+ " HML 0.008605\n",
+ " RF 0.009771\n",
+ " dtype: float64, 'HRB': const -0.002286\n",
+ " SMB 0.000981\n",
+ " HML -0.005757\n",
+ " RF 0.000230\n",
+ " dtype: float64, 'AJG': const 0.009557\n",
+ " SMB 0.000763\n",
+ " HML 0.001040\n",
+ " RF 0.074273\n",
+ " dtype: float64, 'CINF': const 0.010693\n",
+ " SMB 0.001783\n",
+ " HML 0.002503\n",
+ " RF 0.071726\n",
+ " dtype: float64, 'TXN': const 0.015741\n",
+ " SMB 0.004391\n",
+ " HML 0.000626\n",
+ " RF 0.034913\n",
+ " dtype: float64, 'ETN': const 0.003890\n",
+ " SMB 0.007716\n",
+ " HML 0.002059\n",
+ " RF 0.090844\n",
+ " dtype: float64, 'EXPE': const 0.015295\n",
+ " SMB -0.000372\n",
+ " HML -0.002536\n",
+ " RF -0.114739\n",
+ " dtype: float64, 'TMO': const 0.010901\n",
+ " SMB 0.000543\n",
+ " HML -0.004054\n",
+ " RF 0.068159\n",
+ " dtype: float64, 'BSX': const 0.015858\n",
+ " SMB 0.003105\n",
+ " HML -0.007019\n",
+ " RF 0.014305\n",
+ " dtype: float64, 'CTAS': const 0.016999\n",
+ " SMB 0.006533\n",
+ " HML 0.000280\n",
+ " RF 0.082512\n",
+ " dtype: float64, 'WBA': const 0.003260\n",
+ " SMB -0.002313\n",
+ " HML 0.001379\n",
+ " RF -0.054945\n",
+ " dtype: float64, 'UNH': const 0.023115\n",
+ " SMB 0.004480\n",
+ " HML -0.002035\n",
+ " RF -0.043002\n",
+ " dtype: float64, 'HSY': const -0.002364\n",
+ " SMB -0.007383\n",
+ " HML -0.001692\n",
+ " RF 0.122579\n",
+ " dtype: float64, 'FB': const 0.024876\n",
+ " SMB 0.005878\n",
+ " HML -0.007652\n",
+ " RF -0.084624\n",
+ " dtype: float64, 'EIX': const 0.005676\n",
+ " SMB -0.006059\n",
+ " HML 0.001479\n",
+ " RF 0.030555\n",
+ " dtype: float64, 'SBUX': const 0.004142\n",
+ " SMB -0.000443\n",
+ " HML 0.001478\n",
+ " RF 0.120032\n",
+ " dtype: float64, 'MCO': const 0.010974\n",
+ " SMB 0.006066\n",
+ " HML -0.003062\n",
+ " RF 0.091236\n",
+ " dtype: float64, 'HII': const 0.019722\n",
+ " SMB 0.001667\n",
+ " HML -0.000449\n",
+ " RF -0.071924\n",
+ " dtype: float64, 'RL': const -0.008081\n",
+ " SMB 0.009828\n",
+ " HML 0.004103\n",
+ " RF 0.161168\n",
+ " dtype: float64, 'LNT': const 0.009055\n",
+ " SMB -0.001988\n",
+ " HML -0.001094\n",
+ " RF 0.039521\n",
+ " dtype: float64, 'AXP': const 0.001631\n",
+ " SMB 0.002037\n",
+ " HML 0.003925\n",
+ " RF 0.117401\n",
+ " dtype: float64}"
+ ]
+ },
+ "execution_count": 41,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "params"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.7.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}