In stock investment, determining a portfolio that offers attractive returns while maintaining acceptable risk remains a major challenge. Portfolio optimization algorithms can assist in identifying suitable stock combinations; however, the optimization process becomes increasingly complex as the number of possible combinations grows. This study analyzes the trade-off between computational efficiency and portfolio solution quality using the Brute Force and Greedy algorithms. The dataset consists of historical daily adjusted closing prices from 472 S&P 500 companies during the 2025–2026 period. The methodology includes data preprocessing, annualized return and volatility calculation, covariance matrix construction, and portfolio evaluation using the Sharpe ratio. The results show that the Brute Force algorithm consistently achieves higher Sharpe ratios, reaching 4.3619 compared to 3.6470 obtained by the Greedy algorithm for four stock portfolios. However, its runtime increases substantially from 0.0425 seconds for two-stock combinations to 670.7102 seconds for four stock combinations. In contrast, the Greedy algorithm maintains a stable runtime of approximately 0.0015 seconds while producing solutions that remain relatively close to the optimal results. These findings demonstrate a clear trade-off between computational efficiency and solution quality in portfolio optimization.
Copyrights © 2026