Skip to content

sourish-cmi/sparse_portfolio_Bayes_multiple_test

Repository files navigation

Sparse Portfolio Selection via Bayesian Multiple Testing

All codes of the paper titled "Sparse Portfolio Selection via Multiple Testing" are available here. This is a joint project of Sourish Das and Rituparna Sen. The paper is being accepted in Sankhya - B. The preprint of the paper can be found here: Preprint

Following R-packages are required:

  1. snowfall
  2. mvtnorm
  3. MCMCpack
  4. tseries
  5. lars
  6. xts
  7. xtable

Back testing of the Bayesian Sparse Portfolio

Back_testing.R is the main file which tests all the methodology described in the paper with data on 500 stocks which are mostly part of S&P 500 index and listed with NYSE (around 2018). The file Back_testing.R calls all the files described below. The 500 stocks which are part of S&P 500 are typically liquid in nature. We pretend that the market consists of these 500 stocks and we are going to select 25 stocks using described methodologies using one month data. Then we pretend as if we invest in those 25 selected stocks for next one month and accept the portfolio return from the investment. We start our back-testing from 2006-Jan-01.

For backtesting, the adjusted close prices of 500 stocks were downloaded from Yahoo and stored as RData file: yahoo_snp500_adj_close_return_20181101.RData The data downloaded on 1st Nov 2018.

Capital Asset Pricing Model (CAPM) with MLE

  1. CAPM_MLE_Back_testing.R compute the α, β, and σ of CAPM for jth training period for month t to select the stocks for portfolio. Based on α it select the ns(=25) stocks. Then compute the out-sample portfolio return for month t+1. The parameters of CAPM α β and σ estimated using MLE method.

Capital Asset Pricing Model (CAPM) with LARS-LASSO method by Fang etal.

  1. CAPM_Fang_Back_testing.R compute the α, β, and σ of CAPM for jth training period for month t to select the stocks for portfolio. Based on α it select the ns(=25) stocks. Then compute the out-sample portfolio return for month t+1. The parameters of CAPM α β and σ estimated using LARS-LASSO method.

Bayes Oracle test with Discrete Mixture prior for Portfolio Selection and Back testing of K-factor model

  1. Factor_Model_BO_Back_testing.R compute the Bayes Oracle statistics Si for the ith stock. Then it select the ns(=25) many stocks for portfolio for largest ns(=25) Si's. The function implements the portfolio selection for the jth training period for month t to select the stock's for portfolio and then test the performance for the month t+1.

Hierarchical Bayes with Horse Shoe Prior model for Portfolio Selection and Back testing of K-factor model

  1. Factor_Model_HB_selection.R file contain a function named 'Factor_Model_HB_selection'. It implement the Gibbs sampling for β and Metropolis update for scale parameters σc and Σ with Horse Shoe prior on shrinkage parameter. The function uses parallel processing to simulate stock specific β and σ using snowfall R-package. The function uses three R-packages: (1) snowfall, (2) mvtnorm and (3) MCMCpack

4a) run_Factor_Model_HB_selection.R runs the portfolio selction with Factor_Model_HB_selection function for given month and return the stock specific MCMC samples of α, β σ and posterior estimates of the P(α > 0| data).

4b) Factor_Model_HB_Back_testing.R file contain a function named 'Factor_Model_HB_Back_testing'. It takes the output from run_Factor_Model_HB_selection for a specific month and build the portfolio using the highest posterior estimates of the P(α > 0| data) for ns(=25) stocks. One can use either 'equal weight' portfolio or 'Markowitz weight' portfolio strategy on the selected ns(=25) stocks. It computes the portfolio return for next month (as out-of-sample or test-sample portfolio return) for portfolio selected with ns(=25) stocks.

4c) simulate_theta_sigma.R file contain a function named 'simulate_theta_sigma'. The function is called in Factor_Model_HB_selection and used in Gibbs steps to simulate stock specific β and σ in 'Factor_Model_HB_selection' function.

4d) proposal_4_HC.R file contain a function named 'proposal_4_HC'. The function simulate proposal value for Global shrinkage parameter τ from uniform distribution in the Metropolis-Hastings step for τ in 'Factor_Model_HB_selection' function.

4e) dHCauchy.R file contain a function named 'dHCauchy'. The function evaluate the density of the Half-Cauchy distribution.

4f) dinvGamma.R file contain a function named 'dinvGamma'. The function evaluate the density of the Inverse-Gamma distribution.

4g) log_posterior_parallel.R file contain a function named 'log_posterior_parallel'. The function evaluate the log-posterior for Metropolis step in 'Factor_Model_HB_selection' function.

About

Sparse Portfolio Selection via Bayesian Multiple Testing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages