Optimizing Investment Portfolios with Machine Learning and Mean-Variance Analysis
Optimizing Investment Portfolios with Machine Learning and Mean-Variance Analysis
Investing has always been about balancing risk and reward. Whether you're managing a personal portfolio or overseeing millions in institutional investments, finding the right allocation of assets to maximize returns while minimizing risk is crucial. In this post, we’ll dive into how Machine Learning (ML) and Mean-Variance Optimization (MVO) can revolutionize portfolio management, using Dividend Kings as our investment universe.
Why Dividend Kings?
By default, the repository focuses on Dividend Kings—stocks that have increased dividends for at least 50 consecutive years. These companies are renowned for their financial stability, consistent returns, and shareholder-friendly policies. Dividend Kings offer a realistic and relatively conservative set of stocks for applying portfolio optimization techniques.
This choice ensures that the portfolio is built on reliable, historically strong performers while leaving room to explore the benefits of optimization. Of course, the code is flexible—you can specify any set of tickers if you prefer growth stocks, ETFs, or other instruments.
For more on Dividend Kings, check out the full list here: Dividend Kings List.
Introduction to Portfolio Optimization
At the heart of portfolio management lies the concept of the Efficient Frontier. This theoretical boundary identifies the optimal trade-off between portfolio risk (volatility) and return. Harry Markowitz's Mean-Variance Optimization (MVO) introduced a systematic approach to achieving this balance, and it remains one of the most influential financial models.
However, traditional methods rely heavily on historical data and fixed assumptions. Markets, on the other hand, are dynamic and complex. This is where Machine Learning enters the equation—by forecasting future returns and adjusting to changing conditions, ML models can augment MVO for better decision-making.
Blending Machine Learning with MVO
Our project combines the power of predictive modeling with the rigor of statistical optimization. By using ML models like Linear Regression, we estimate asset returns based on historical data and trends. These predicted returns are then fed into the MVO algorithm to calculate the optimal allocation of assets.
Key Features:
- Black-Litterman Framework: Adjusts market returns based on investor views and confidence levels.
- Efficient Frontier Analysis: Visualizes the best possible portfolios for various risk levels.
- Performance Metrics: Includes Sharpe Ratio, Sortino Ratio, and Information Ratio to measure portfolio efficiency.
Portfolio Details
For this project, we used the following Dividend Kings as our investment universe:
Symbol | Company Name | Weight | Sector |
---|---|---|---|
MO | Altria Group Inc. | 4% | Consumer Staples |
NWN | Northwest Natural Gas | 14% | Utilities |
BKH | Black Hills Corp. | 1% | Utilities |
ED | Con Edison | 1% | Utilities |
PEP | PepsiCo Inc. | 9% | Consumer Staples |
NFG | National Fuel Gas | 16% | Utilities |
KO | Coca-Cola Company | 6% | Consumer Staples |
FRT | Federal Realty Inv. Trust | 28% | Real Estate |
GPC | Genuine Parts Co. | 16% | Consumer Discretionary |
MSEX | Middlesex Water Co. | 5% | Utilities |
The total portfolio value is $100,000, with weights translating into dollar amounts. For instance, a 4% weight in MO means $4,000 invested in Altria Group.
How It Works
- Input Portfolio: Define the initial portfolio with weights and market caps.
- Predict Returns: Use Machine Learning models to predict future returns for each asset.
- Optimize Allocation: Use MVO to find the optimal weights for the portfolio based on predicted returns, minimizing risk while maximizing returns.
- Backtest: Simulate the optimized portfolio’s performance against historical data.
- Visualize Results: Generate the Efficient Frontier, plot portfolio performance, and compare with the benchmark (S&P 500).
Results
Our project provides several outputs to help investors make informed decisions:
- Efficient Frontier: A curve showing the best portfolios for different risk levels.
- Capital Market Line (CML): A line representing portfolios that combine the risk-free asset with the market portfolio.
- Performance Metrics:
- Sharpe Ratio: How much return you earn for every unit of risk.
- Sortino Ratio: Similar to Sharpe but focuses only on downside risk.
- Information Ratio: Compares portfolio performance against a benchmark.
Below is a sample visualization generated by our project:
Why This Matters
- Customizable: Investors can adjust parameters like risk tolerance, minimum/maximum asset weights, and the choice of ML models.
- Adaptability: The use of ML ensures that the portfolio adapts to changing market conditions.
- Transparency: By visualizing the Efficient Frontier and other metrics, investors gain clarity on how decisions impact performance.
How to Get Started
Want to try it yourself? Here’s how:
- Clone the GitHub repository:
- Install dependencies:
- Define your portfolio in the
fetch_portfolio_data()
method. - Run the
main()
function:
The outputs will include:
- Optimized portfolio weights.
- Performance metrics and tables.
- Visualization of the Efficient Frontier and portfolio performance.
Conclusion
Combining Machine Learning with Mean-Variance Optimization bridges the gap between modern predictive analytics and traditional portfolio theory. By applying this to Dividend Kings, we focus on reliable, stable companies while exploring innovative techniques to maximize returns and minimize risks.
References
- Markowitz, H. (1952). Portfolio Selection. The Journal of Finance.
- Dividend Kings List
Disclaimer: This project is for educational purposes only and does not constitute financial advice. Always consult a financial advisor before making investment decisions.
Comments
Post a Comment