February 12, 2026
Optimization of stock portfolios with modern portfolio theory
Victor Vinci Fantucci; Miguel Ângelo Lellis Moreira
Summary prepared by the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege focused on synthesis and writing.
This study develops and validates an optimization model to build an efficient stock portfolio that achieves a predefined minimum annual return, minimizing associated risk, based on Modern Portfolio Theory (MPT). The research applies quantitative techniques for strategic asset allocation in the Brazilian capital market, aiming to offer a methodological alternative for investors seeking to supplement their retirement strategies. The central proposal is to demonstrate, through a practical case, how diversification and mathematical optimization can generate portfolios with a superior risk-return relationship compared to simplistic approaches, such as equal allocation, and conservative benchmarks.
The relevance of the research is anchored in the Brazilian social security scenario. Projections indicate a growing imbalance in the public system. In 2022, the ratio was 1.97 contributors per beneficiary, a number expected to fall to 0.86 in 2060 (Costanzi; Ansiliero, 2024). This inversion signals the urgency for citizens to develop private investment strategies to ensure financial security in retirement. In this context, exclusive reliance on the public system becomes risky, driving the need for active wealth management; allocation in variable income assumes a central role.
The transition to the capital market, however, introduces the relationship between risk and return. Risk management is fundamental to mitigate the impacts of volatility (Silva et al., 2018). The rational investor seeks to maximize return, conditioned on an acceptable risk limit (Neto, 2025). The premise that higher returns are associated with greater risks is an axiom of finance. The challenge is not to eliminate risk, but to manage it. An efficient portfolio is one that offers the highest profitability for a given level of risk, or the lowest risk for a desired return (Elton et al., 2014).
To this end, Harry Markowitz’s Modern Portfolio Theory (1952) formalized the concept of diversification. Markowitz demonstrated that the risk of a portfolio depends on the correlation between its assets, not just on the weighted average of individual risks. By combining assets that do not move in sync, it is possible to reduce unsystematic risk. This work is based on this principle. Although other models such as CAPM (Sharpe, 1964) and multifactor models (Fama; French, 1993) offer complementary perspectives, Markowitz’s approach (1959) remains the primary tool for optimizing and constructing the efficient frontier, the focus of this analysis.
The proposal is to apply Markowitz’s theory to a practical problem: the construction of a portfolio of Brazilian stocks for the long term. The work develops a replicable optimization process with real data and accessible tools. It seeks to validate the model’s effectiveness in achieving its goals and provide a methodological roadmap that can be adapted by individual investors, contributing to more informed decision-making in an increasingly complex environment.
This work is an applied research, which employs tools from Data Science and financial theory (Elton et al., 2014; Neto, 2025). With exploratory and descriptive objectives, it investigates the effects of diversification and optimization in portfolio construction, describing the risk-return relationship under different scenarios. The approach is quantitative, based on the statistical analysis of historical data with computational support. Mathematical modeling and simulations are prioritized to ensure the rigor and replicability of the results (Morettin; Bussab, 2017).
The selection of assets was a crucial step. Eight assets from four perennial sectors were chosen: banks (BBAS3, ITUB4), insurance companies (BBSE3, PSSA3), electric energy (EGIE3, ELET6), and sanitation (CSMG3, SAPR4). The choice is justified by their defensive characteristics, such as consistent cash generation, lower volatility, and dividend history, attributes sought by investors with a moderate profile (Damodaran, 2012). The criteria for the specific stocks included consolidated market presence, sector relevance, revenue predictability, high liquidity, and availability of a long historical data series.
The daily adjusted closing prices of the eight assets were extracted via the yfinance Python library (Aroussi, 2017). The analysis period was from January 2019 to March 2025, a window of over six years encompassing multiple economic cycles and market events, such as the COVID-19 crisis. Data treatment involved calculating daily percentage changes, which were aggregated to obtain average annual and monthly returns. The final step was the construction of the covariance matrix, which measures how the returns of each pair of assets vary jointly and is the central element of the Markowitz model, as it quantifies the benefit of diversification (Morettin; Bussab, 2017).
Portfolio optimization was implemented in MS Excel with the Solver add-in. The objective function was the minimization of the total portfolio variance, the TMP risk measure. The decision variables were the allocation weights of each of the eight assets. The process was subjected to constraints: the sum of all weights should be 100%; a minimum expected annual return of 14% was imposed; and individual allocation limits per asset, between 7.5% and 20%, were defined to ensure diversification and avoid excessive concentration.
To evaluate the model, six distinct scenarios were structured. Scenario 1 (C1) is the main optimized portfolio. Scenario 2 (C2) is an equal allocation portfolio (12.5% per asset), serving as a passive strategy benchmark. Scenario 3 (C3) uses the average annual CDI for the period as a conservative benchmark (Investidor10, 2025). Additionally, three sensitivity scenarios were created: Scenario 4 (C4), more restrictive (target of 15%, weights between 5% and 25%); Scenario 5 (C5), less restrictive (target of 13%, weights between 5% and 30%); and Scenario 6 (C6), an aggressive profile (target of 16%, weights between 5% and 35%).
The results for the base scenario (C1) reached the expected annual return of 14.00%. The optimal composition assigned the maximum weights (20%) to BBSE3 and PSSA3, and a high weight (19.09%) to SAPR4. The other assets received lower weights, with BBAS3, CSMG3, ELET6, and ITUB4 receiving the minimum of 7.5%. The risk of this portfolio, measured by the monthly standard deviation, was 1.62%, with a variance of 2.62 × 10⁻⁴. The structure demonstrates the algorithm’s ability to distribute capital in a non-intuitive way to minimize volatility, a benefit of the quantitative approach (Lehmkuhl; Schnorrenberger; Flach, 2021).
The comparison with the egalitarian allocation (C2) validates the superiority of the optimized model. The C2 portfolio generated a lower annual return of 13.16% and presented higher risk, with a monthly standard deviation of 1.73% and a variance of 2.98 × 10⁻⁴. Optimization increased profitability by 0.84 percentage points and reduced volatility. This efficiency gain materializes the benefit of intelligent diversification proposed by Markowitz (Elton et al., 2014). In relation to the conservative benchmark (C3), the average CDI of 9.89% per year, the optimized portfolio demonstrated superior performance, justifying the exposure to equity risk.
Sensitivity analysis reinforced the model’s consistency. In the most restrictive scenario (C4), requiring a 15% return, the portfolio risk increased, with the monthly standard deviation rising to 1.81%. In the aggressive scenario (C6), the pursuit of a 16% return raised the risk to a standard deviation of 2.05%. Conversely, in the least restrictive scenario (C5), with a 13% target, the model built a more conservative portfolio, with the lowest risk among the optimized scenarios (standard deviation of 1.48%). These results outline the efficient frontier, demonstrating the trade-off between risk and return: to achieve higher gains, the investor must accept greater volatility (Lima, 2022).
The discussion of the results highlights the contribution of sectoral diversification, imposed by allocation limits. By forcing the presence of all sectors, the model avoided excessive concentration, which contributed to the reduction of volatility and increased portfolio resilience. This finding reinforces the importance of combining quantitative optimization with qualitative management principles, such as strategic sectoral diversification (Bodie; Kane; Marcus, 2014). The model’s applicability for individual investors is notable, as the use of tools like MS Excel demystifies portfolio optimization, making it accessible.
It is necessary to recognize the limitations of the model. The analysis was based on historical data, and past performance does not guarantee future results. Transaction costs, taxes, and liquidity were not incorporated. Furthermore, the study focused on price appreciation, disregarding distributions (dividends and interest on own capital). The inclusion of dividends, which are relevant for the selected sectors, could increase portfolio performance and accentuate the advantage of the optimized portfolio over the CDI.
The study’s main practical contribution is the demonstration of an accessible and effective methodology for structuring more efficient investment portfolios. The combination of TMP with simple computational tools allows investors to structure their portfolios more scientifically and aligned with long-term objectives, such as retirement (Mira, 2024). The results confirm that the model was successful in achieving the desired return, keeping risk controlled and outperforming passive strategies. The flexibility shown in the sensitivity analysis validates the proposal as a tool adaptable to different investor profiles.
The study departed from the problematic of the Brazilian social security system, which makes the search for investment alternatives imperative. A quantitative methodology based on Modern Portfolio Theory was proposed and applied to construct and evaluate stock portfolios. The analysis, conducted with Brazilian market data and MS Excel’s Solver, demonstrated that mathematical optimization provides significant efficiency gains when compared to a passive allocation, achieving superior returns with controlled risk. The findings reinforce the importance of sectoral diversification and validate the model as a useful tool for investors with a moderate profile and long-term horizon.
The research contributes to the literature by applying a consolidated model to a current context, using an accessible approach. As suggestions for future work, it is recommended to expand the analysis to include other asset classes, such as real estate funds and international assets, incorporate dividends in the total return calculation, and use more advanced optimization methods. It is concluded that the central objective of the work was fully achieved: the effectiveness of Modern Portfolio Theory in constructing an optimized stock portfolio was demonstrated, capable of achieving a target return of 14% per year with minimized risk and superior performance to passive strategies and conservative benchmarks.
References:
Bodie, Z.; Kane, A.; Marcus, A. J. Investments. 10th ed. New York: McGraw-Hill, 2014.
Costanzi, R. N.; Ansiliero, G. Evolução e projeção de longo prazo de contribuintes e beneficiários e implicações para o financiamento da previdência social. Rio de Janeiro: Ipea, 2024. 59 p.: il. (Texto para Discussão, n. 2988).
Damodaran, A. Investment philosophies: successful strategies and the investors who made them work. 2nd ed. New York: Wiley, 2012.
Elton, E. J.; Gruber, M. J.; Brown, S. J.; Goetzmann, W. N. Modern portfolio theory and investment analysis. 9th ed. Hoboken: Wiley, 2014.
Fama, E. F.; French, K. R. Common risk factors in the returns on stocks and bonds. Journal of Financial Economics, v. 33, n. 1, p. 3–56, 1993.
Investidor10. 2025. TAXA CDI hoje, histórico mensal e anual do CDI. Disponível em: https://investidor10. com. br/indices/cdi/. Acesso em: 19/07/2025.
Lehmkuhl, R.; Schnorrenberger, D.; Flach, L. Teoria Moderna do Portfólio: a busca por uma carteira de investimentos adequada. Revista Controladoria e Gestão, v. 3, n. 1, p. 578–594, 2021.
Executive summary from the Final Course Work of the Specialization in Data Science and Analytics of the MBA USP/Esalq
Learn more about the course; click here: