Monte Carlo Markov Chain Simulations for Portfolio Optimization

This project was in collaboration with Spriha Bankata Mishra and Anvita Brahman as part of our ISYE 6644 Final Report at Georgia Tech

Abstract

This project investigates the application of Monte Carlo simulations in optimizing investment portfolios, leveraging historical data to assess and refine the process of allocating assets. Using historical data from ten major companies – Apple, IBM, Cisco, Amazon, Meta, AMD, Tesla, Microsoft, Qualcomm, and Netflix – spanning from 2014 to 2018, we conducted numerous simulations to evaluate various portfolio combinations. This approach allowed us to analyze the risk and return of each portfolio, helping us identify the optimal asset mix. This project confirms the utility of Monte Carlo simulations within the context of Modern Portfolio Theory (MPT), demonstrating its effectiveness in achieving a balanced portfolio that aligns with specific risk tolerances.

Background & Description of the Problem

Portfolio optimization is a fundamental aspect of financial planning. The goal is to identify the best portfolio (asset distribution) from a set of all possible portfolios, guided by specific objectives such as maximizing expected return and minimizing associated costs like financial risk. Traditional methods like those proposed by Harry Markowitz’s MPT in 1952 [13] use diversification to mitigate risk but often fall short in the face of real-world complexities such as non-normal asset return distributions and dynamic market conditions. Our project aims to overcome these limitations through the use of advanced Monte Carlo simulation techniques, which enable a more comprehensive exploration of possible investment scenarios. These allow us to explore a vast array of investment scenarios, enabling a statistical determination of the optimal portfolio based on predefined risk tolerances, thus providing a more robust solution. In addressing the shortcomings of traditional portfolio management strategies, we’re able to see the effectiveness of MCMC simulations in providing a deeper, probabilistic understanding of portfolio behaviors, which significantly enhances our ability to forecast and mitigate risks in an ever-changing investment landscape.

Literature Review

As a simulation method, MCMC is useful in parameter estimation and exploring posterior distributions in Bayesian models [4]. It is a powerful method that is well suited for scenarios where the distribution is high-dimensional or difficult to sample from directly [6]. Additionally, MCMC methods can be used to address incomplete datasets by simulating missing data and generating accurate estimates [4]. Among the MCMC algorithms discussed in our sources, Gibbs sampling and the Metropolis-Hastings algorithm are particularly noteworthy. Gibbs sampling is often used in situations with high-dimensional spaces where traditional methods, such as numerical integration, are not practical. It works by sequentially sampling from the conditional distributions of each variable in the system [9]. On the other hand, the Metropolis algorithm creates a random walk, where each step is independent of the previous one, allowing for a diverse exploration of the parameter space [4].

MCMC methods have various analytical applications and have been gaining popularity recently. Some of these applications include simulating particle systems in thermodynamic equilibrium (statistical physics), estimating posterior distributions when prior and likelihood probabilities are complex (Bayesian statistics), and training models with complex likelihood functions (machine learning) [6].

To use MCMC methods effectively, it is essential to first define the model, which includes specifying the prior distribution and the likelihood function, before selecting an appropriate MCMC algorithm – such as Metropolis-Hastings, Gibbs sampling, or Hamiltonian Monte Carlo – that best aligns with the objectives [6]. Then, the algorithm must be initialized with starting values for the parameters and run for a specified number of iterations. To assess whether the algorithm has converged to the target distribution, convergence diagnostics such as trace plots and the Gelman-Rubin statistic (R-hat) are then used. Once the MCMC algorithm has achieved convergence, the samples generated by the can be used to estimate summary statistics, make predictions, and perform hypothesis testing [6][10].

Monte Carlo Markov Chain methods are well-suited to applications in financial fields. These methods are well-suited for continuous-time finance applications as they can handle high-dimensional complex distributions, deal with unseen variables, and manage unusual distributions and patterns [5]. They are more effective than classical methods when models involve numerous parameters with intricate distributions, and are well-suited for dealing with Bayesian frameworks and updating beliefs based on new data [8]. MCMC can be used to simulate data for risk prediction [1], for the estimation and testing of conditional asset pricing models in finance [2], in evaluating biases in option pricing models in the context of financial markets [3], and for portfolio optimization and risk management [5].

In this project, we aim to explore the use of MCMC methods for portfolio optimization by considering 10 popular stock options over the period of 2014-2018.

Monte Carlo Simulation in Portfolio Optimization

Monte Carlo simulation is a powerful tool for portfolio optimization, enabling detailed analysis of financial market behaviors under a wide array of hypothetical conditions and stress scenarios. This probabilistic model uses random sampling to generate possible outcomes for asset returns, thereby providing a comprehensive view of potential risks and returns.

Applications of Monte Carlo Simulation:

Methodology

Data Acquisition & Pre-processing:

We compiled the historical daily closing prices of ten selected stocks: Apple, IBM, Cisco, Amazon, Meta, AMD, Tesla, Microsoft, Qualcomm, and Netflix. We obtained the data from the NASDAQ database at https://www.nasdaq.com/market-activity/quotes/historical.

As part of our initial data cleaning, we aggregated the data from these ten stocks into a single, cohesive dataset and dropped additional columns that we deemed irrelevant within the scope of this project. The resulting “stocks” dataframe consists of the closing values of our selected stocks along with their corresponding dates. While our collected data spanned ten years, we focused on daily closing prices over the four financial years from April 1st, 2014, to March 31st, 2018.

Final Dataframe

Return and Risk Calculation:

In this project, returns were calculated using logarithmic returns to stabilize variance, thereby improving the model’s accuracy. We then constructed a covariance matrix, which is instrumental in assessing how the log returns for two stocks may correlate or not, thus providing insight into the collective behavior of two portfolio assets.

Monte Carlo Simulation for All Stocks:

Random sampling techniques were used to generate an extensive set of 15,000 potential portfolios, each representing a unique combination of asset allocations. For each simulation iteration, we assigned random investment weights to the different stocks. For each iteration, we ensured the collective sum of these weights equalled one to normalize this process and ensure we had a proper portfolio structure.

For each simulated portfolio, we calculated metrics such as the expected return, expected volatility, and Sharpe ratio. The Sharpe ratio is a metric that evaluates the return of an investment compared to its risk, which is crucial for comparing the desirability of one portfolio over another. In the context of this project, we used the Sharpe ratio as the primary metric to gauge the success of our portfolios. Since the Sharpe ratio provides us with a standardized way to determine how well a return compensates for the risk taken, we used it as the primary metric for comparison of portfolio performance across our simulations.

Next, we visualized the results of our simulations, plotting the return for each simulated portfolio against its volatility, as seen in the figure below. The color of each point represents the Sharpe Ratio of that portfolio, with warmer colors (yellow) indicating higher ratios and cooler colors (purple) indicating lower ratios. The green dashed line represents the efficient frontier, which is a set of optimal portfolios that offer the highest expected return for a given level of risk. Portfolios on this line are considered to be efficiently balanced in terms of risk and return. The efficient frontier is typically calculated by varying the expected return and finding the portfolio that minimizes volatility for that return level.

Return and Volatility of Simulated Portfolios

Monte Carlo Simulation for Four Stocks:

We then performed a more focused Monte Carlo simulation, modifying our original simulation to select just four stocks from the original ten to create a portfolio with the highest Sharpe ratio. The simulation setup remained the same, but we added additional steps to select the best combination of four stocks.

With each iteration, our algorithm randomly chose four unique stock indices from the set of ten stocks, each subset becoming a unique portfolio. The associated expected return, volatility, and Sharpe ratio for each portfolio were then saved in their respective arrays. As the iterations progressed, our algorithm continuously tracked and updated the best portfolio, defined as the combination of stocks with the highest Sharpe ratio found up until that point, saving the best values of Sharpe ratio, portfolio composition (as stock names), weights, return, and volatility.

After conducting our simulation, we found that the best portfolio is composed of stocks from Apple, Amazon, Microsoft, and Netflix, with their respective weights being 0.208, 0.466, 0.115, and 0.212. This optimized combination not only reflects a weighted emphasis on Amazon, but also highlights the effectiveness of using the Sharpe ratio in thes MCMC simulations as a measure of portfolio efficiency.

Result of Portfolio Analysis

Return & Volatility for Simulation of Sets of 4 Stocks

Findings & Discussion

Monte Carlo simulations provide a deeper insight into potential investment outcomes, allowing for a more nuanced approach to portfolio optimization. The ability to simulate numerous scenarios helps in understanding potential outcomes under different market conditions. This is crucial when making investment decisions that are both informed and resilient.

In our examination of historical stock data for 10 high-performing companies – Apple, IBM, Cisco, Amazon, Meta, AMD, Tesla, Microsoft, Qualcomm, and Netflix – we generated plots to highlight the evolving trends of these companies from 2014 to 2018. The histograms for daily logarithmic returns below show the distribution of returns, providing a visualization of risk and return features for each company.

Normalized Stock Prices over Time

Daily Logarithmic Returns

From the histograms generated for each of the ten stocks, we observe a range of volatility and return profiles. The histograms suggest that while some stocks exhibit high volatility, characterized by wider return distributions which indicate a higher risk and potentially higher return profile. Conversely, other stocks show more stability, with narrower return distributions that suggest more consistent performance. This variation is critical in constructing a balanced, diverse portfolio that can withstand market fluctuations and provide consistent long-term growth.

Running a Monte Carlo simulation for portfolio optimization enabled us to construct a portfolio with a notably high Sharpe ratio (1.49), indicating the risk taken on by this particular asset allocation is well-compensated by the returns. Our case study of ten stocks results in a best portfolio composed of stocks from Apple, Amazon, Microsoft, and Netflix, with their respective weights being 0.208, 0.466, 0.115, and 0.212. The weight allocation demonstrates a substantial lean towards Amazon, suggesting a strong confidence in its performance relative to the others.

For investors seeking to balance risk and reward, utilizing Monte Carlo simulations to inform their portfolio selection offers a significant advantage. By accounting for the stochastic nature of market returns, these simulations aid in identifying optimal portfolio configurations with a solid degree of confidence in its future performance. These simulations are based on historical data and assumptions, and thus, the actual future performance may differ due to unforeseen market dynamics, but these simulations provide a good baseline for portfolio optimization.

In summary, the Monte Carlo simulation method can be an indispensable tool for investors, allowing for data-driven decisions and strategic asset allocation. It provides a robust framework for quantifying and managing risk while striving for optimal returns.

Conclusion & Future Work

This project has provided us with an incredible introduction to Monte Carlo Markov Chains and has shown their broad applicability across various scenarios when it comes to portfolio optimization. Throughout our research, we have deepened our understanding of MCMC methods and the math that is at their foundation. By applying Monte Carlo simulations to portfolio optimization, we were able to identify the best portfolio from a set of ten stocks, based on the Sharpe ratio. This ideal portfolio consisted of Apple, Amazon, Microsoft, and Netflix, with respective weights of 0.208, 0.466, 0.115, and 0.212.

As with most methods of data analysis, the reliability of Monte Carlo simulations is contingent upon the quality of historical data and the assumptions about market behavior. Through this project, we saw firsthand how MCMC methods are able to adeptly capture the stochastic nature of financial markets. This enables the development of investment strategies that are both theoretically robust and practically applicable across diverse economic scenarios. However, as the complexity of the models increases or as more assets are incorporated, the computational demands also escalate.

Looking ahead, future research could focus on incorporating real-time data into the model training, allowing the simulations to adjust more rapidly to current market conditions. This would help to increase the accuracy and relevance of the portfolio optimization process. Additionally, further research could delve into the development of more sophisticated models that are better able to capture the nuances of asset return distributions, or simulation models that are robust enough to handle additional information such as transaction costs. This continuous refinement and expansion of methodologies will undoubtedly enhance the precision and applicability of investment strategies in the dynamic world of finance.

References/Works Cited

[1] Zhang Yuanfang, “Optimization of financial market risk prediction system based on computer data simulation and Markov chain Monte Carlo,” Soft computing, May 2023, doi: https://doi.org/10.1007/s00500-023-08370-y.

[2] M. Ammann and M. Verhofen, “Testing Conditional Asset Pricing Models Using a Markov Chain Monte Carlo Approach,” European Financial Management, vol. 14, no. 3, pp. 391–418, Jun. 2008, doi: https://doi.org/10.1111/j.1468-036x.2007.00359.x.

[3] S. Mozumder, T. Choudhry, and M. Dempsey, “Option Pricing Model Biases: Bayesian and Markov Chain Monte Carlo Regression Analysis,” Computational Economics, Jul. 2020, doi: https://doi.org/10.1007/s10614-020-10029-x.

[4] [1]“Markov Chain Monte Carlo | Columbia Public Health,” www.publichealth.columbia.edu. https://www.publichealth.columbia.edu/research/population-health-methods/markov-chain-monte-carlo

[5] M. Johannes and N. G. Polson, “MCMC Methods for Continuous-Time Financial Econometrics,” pp. 1–72, Jan. 2010, doi: https://doi.org/10.1016/b978-0-444-53548-1.50003-9.

‌[6] “Statistical Rethinking 2022 Lecture 08 - Markov chain Monte Carlo,” www.youtube.com. https://www.youtube.com/watch?v=Qqz5AJjyugM (accessed Apr. 23, 2024).

[7] A. G. Korteweg, “Markov Chain Monte Carlo Methods in Corporate Finance,” SSRN Electronic Journal, 2011, doi: https://doi.org/10.2139/ssrn.1964923.

[8] “Markov Chain Monte Carlo (MCMC) and AI for Investors,” www.youtube.com. https://www.youtube.com/watch?v=bD1LHTLvlRw (accessed Apr. 23, 2024).

[9] M. Johannes and N. G. Polson, “MCMC Methods for Continuous-Time Financial Econometrics,” pp. 1–50, Jan. 2010, doi: https://doi.org/10.1016/b978-0-444-53548-1.50003-9.

[10] A. Gelman, J. B. Carlin, H. S. Stern, D. B. Dunson, Aki Vehtari, and D. B. Rubin, Bayesian data analysis. Boca Raton, Fl: Chapman & Hall/Crc, 2014.

[11] D. J. Hand and E. Al, A Handbook of small data sets. London…Etc.: Chapman & Hall, Cop, 1994.

[12] S. Brooks, Handbook of Markov chain Monte Carlo. Boca Raton: Taylor & Francis.

[13] A. D. Roy and H. M. Markowitz, “Portfolio Selection,” Econometrica, vol. 29, no. 1, p. 99, Jan. 1961, doi: https://doi.org/10.2307/1907702.

[14] A. Mishra, “akashprem12/Portfolio-Optimisation-using-Monte-Carlo-Simulation,” GitHub, Mar. 26, 2024. https://github.com/akashprem12/Portfolio-Optimisation-using-Monte-Carlo-Simulation/tree/master (accessed Apr. 24, 2024)