Case Study: Portfolio Optimization on Dirac-3
1 Introduction
Investors aim to maximize their portfolio’s expected return while minimizing risk, typically measured by the variance of returns. This trade-off between risk and return lies at the heart of modern portfolio theory. Risk, quantified as the variance of portfolio returns, represents the uncertainty associated with the future performance of investments, while the expected return reflects the anticipated profit from a portfolio. Striking the right balance between these two competing objectives is crucial for successful investment strategies.
One of the foundational concepts in portfolio optimization was introduced by Harry Markowitz in 1952 [9], marking a significant breakthrough in financial theory. Markowitz introduced the notion that diversification—spreading investments across a range of assets—can reduce the overall risk of a portfolio without sacrificing returns. This idea revolutionized the way investors construct portfolios, emphasizing that an optimal portfolio should focus not only on maximizing returns but also on minimizing risk. Markowitz’s work laid the foundation for Modern Portfolio Theory (MPT), which remains a cornerstone of financial economics.
A widely adopted metric for evaluating the performance of a portfolio relative to its risk is the Sharpe ratio, denoted by . The Sharpe ratio, introduced by William F. Sharpe, measures the excess return per unit of risk, defined as the portfolio’s standard deviation of returns:
where
is the expected return of the portfolio,
is the risk free interest rate, and
is the standard deviation of the portfolio’s returns, which reflects risk.
The Sharpe ratio provides a standardized way to compare different portfolios or investments by adjusting the expected return above the risk-free rate for the risk taken. A higher Sharpe ratio indicates that an investment offers better returns per unit of risk, making it a key measure for performance evaluation.
While the Sharpe ratio is valuable, investors may also prioritize different metrics depending on their risk tolerance. For risk-averse investors, minimizing risk might take precedence, leading to portfolios that emphasize low variance even at the cost of lower expected returns. On the other hand, more risk-tolerant investors may accept higher volatility in exchange for the potential of higher returns. Thus, portfolio optimization becomes a dynamic process, tailored to an investor’s risk preferences and financial objectives.
Portfolio Optimization with Quantum Computing
Quantum computing promises significant improvements in solution quality and computing speed when solving large-scale optimization problems due to quantum parallelism. Studies using Variational Quantum Eigensolver (VQE) or Quantum Approximate Optimization Algorithms (QAOA) on gate-based machines as well as quantum annealers [12, 4, 10, 3] have shown encouraging results for portfolio optimization. However, these studies rely on binary encoding, limiting decision variables to "yes/no" choices for asset inclusion. For finer control over portfolio allocation (how much to invest in each asset), binary encoding becomes unsuitable. This necessitates a mapping step to translate continuous variables into a format compatible with quantum hardware, leading to the increase in problem size and dynamic range. This limitation can be bypassed using Dirac-3 QCi’s quantum sum-constrained continuous solver which allows easy direct mapping of the natural objective function for portfolio optimization which will be outlined in 3.2.
2 Method
2.1 Management Factors
The portfolio management method proposed seeks to build an optimal portfolio by minimizing the risk and maximizing the return based on previous performance in a recent time period (the "look-back window"). This method assumes that the performance of this portfolio will be close to previous performance in the near future (the "look-forward window"). The look-forward time period is usually much shorter than the look-back period.
To prevent investors from losing all risking large losses in a specific asset, constraints are used to ensure diversification. These could be minimum or maximum weightings for specific asset classes or limitations on individual asset correlations within the portfolio.
2.2 Model
Let be the total number of available stocks to choose from, that is the size of the stock pool. For example, we can use the collection of all stocks in an index such as the Nasdaq-100 index as our stock pool. We want to choose the weights of stocks such that the portfolio risk is minimized, while the portfolio expected return is maximized:
where is the daily returns of the portfolio over some period of time, VAR(R) and are the variance and expectation of daily returns, and are hyper-parameters, and ${w_i}$ is the weight of stock i in the portfolio; . We call the base interest rate; it is introduced so that the two added terms in the objective function are on an equal footing. Obviously, can be absorbed into . A large value of means the focus of optimization is to increase return, whereas a small value indicates the reduction of risk is more important. We obviously want to the weights to sum to 1. So the optimization is subject to
We also want to make the portfolio diverse. So we can apply an upper limit on all weights ,
The portfolio daily return over a time period can be written as a linear combination of daily returns of its constituent stocks over the same time period. We have,
where is the daily return of stock at time during time period .
The expectation of portfolio daily return over time period can thus be expanded as,
and the variance of portfolio daily returns over time period is expanded as,
where is the covariant function.
To impose the inequality constraints in Equation 4, we can introduce auxiliary variables , and impose equality constraints as,
where
Substituting Equations 6 and 7 into Equation 2, the objective function becomes ,
where
To avoid overfitting on the portfolio data, we can minimize the average of the cost function over overlapping time periods, that is . The problem becomes,
Adding the constraints in Equations 3 and 8 to the objective function in Equation 13, the optimization problem reduces to,
where the two body coupling coefficients are defined as,
and the linear coefficients are defined as,
2.3 Advantages of using Dirac-3
No need for an additional embedding step: The construction of the portfolio optimization model in Equation 14 requires continuous variables . This requires an additional embedding step to convert the problem into a Quadratic Unconstrained Binary Optimization (QUBO) format [5, 1]. Dirac-3 quantum optimization machine offers a significant advantage. Due to its ability to perform optimization with discrete variables encoded in a high-dimensional time-energy mode [13], Dirac-3 can handle the input from Equation 14 directly. This eliminates the conversion step and reduces the overall complexity of the problem represented.
Increased problem size and accuracy-complexity trade-off: Replacing continuous variables with binary ones inflates the problem size. This creates a trade-off: higher accuracy demands a larger number of variables, which can surpass the hardware’s limitations in terms of both problem complexity and dynamic range. Here, the dynamic range is defined as the ratio of largest to smallest element of the Hamiltonian in decibels. QCi’s Dirac-3 is designed to have an optimal performance for problems with a dynamic range of less than 23 decibels.
Limited connectivity impacts: On many other quantum devices, the device topology directly affects the optimization performance. Forcing a problem to conform to a device-specific configuration can lead to scenarios where there are increases in error rates, execution times, and in some cases an inability to run the problem entirely [7, 2, 11, 8].
3 Results
look-back window | 60 days |
look-forward window | 30 days |
window-size | 30 days |
window-overlap | 15 days |
(annual) | 5% |
8% | |
5 | |
1 | |
1 |
Table 1: Parameters used for portfolio optimization algorithm run on Dirac-3.
Our algorithm was implemented and executed on QCi’s Dirac-3 quantum optimization machine. We tested its performance on a 21-year period, from January 1st, 2003, to March 31st, 2024. The model parameters used are detailed in Table 1. While these choices of hyper-parameters are believed to be reasonable, a thorough study is needed to understand the impact of each parameter and to choose an optimal value. Note that the values used for and ensure that the equality constraint 3 and inequality constraint 4 are satisfied. The only hyperparameter which we have studied in this work is . With the assumption of monthly portfolio rebalancing, each test over the 21 year period involved solving 255 optimization problems on Dirac-3.
3.1 Availability of historical data
At each point of time during the 21-year period, the constituents of Nasdaq-100 at that time are used. Some of these stocks were delisted a long time ago and, as such, their historical prices may not be available or easily accessible. We have used multiple sources to get the stock prices. However, the historical prices of some constituents of Nasdaq-100 for older dates are not available.
Figure 1 shows the count of constituent stocks with historical data available in each month since 2003. As can be seen, only since 2016 the historical prices of about 100 of the Nasdaq-100 constituents are available; only the stocks with available historical prices during all periods were used for testing.
3.2 Comparison of the optimized portfolio to Nasdaq-100 index
Figure 2 compares the values of the optimal portfolio constructed by our algorithm with the Nasdaq-100 index over the 21-year period, assuming an initial investment of $1 million in each on January 1st, 2003. As the figure shows, the optimal portfolio delivers a higher overall return than the Nasdaq-100 index.
Figure 3 shows the monthly returns of the optimal portfolio, adjusted with the Nasdaq-100 (Symbol NDX) returns. Thus, the positive values (green bars) correspond to the months in which the optimal portfolio outperforms Nasdaq-100 index, and the negative values (red bars) are related to the months of inferior performance; the optimal portfolio has outperformed the index in 138 out of 255 months, that is a rate of 54.1%. On average, the optimal portfolio outperforms the index by a monthly return of 1.15% +/- 5.41%, compared to Nasdaq-100 that delivered a monthly return of 1.10% +/- 6.80% over the 21 year period; the optimal portfolio delivered a slightly higher return with a significantly lower risk.
3.3 Hyperparameter study
Some parameter tuning was done to better understand the effect of parameters on the corresponding optimal portfolio. However, a more comprehensive study is needed to get a complete picture of how these parameters affect the portfolio performance and what the optimal choices are.
Table 2 shows the average and standard deviation of monthly returns for optimal portfolios with different values of ξ from 0.01 to 5, compared to those of Nasdaq-100. As can be seen, all of the optimal portfolios yield superior monthly returns over the index, while keeping the return volatility, presented by the standard deviation of monthly returns, well below that of the index. As can be seen, a choice of ξ = 1 seems to perform better than all other choices of ξ, although the statistical significance of this result cannot be judged based on the present limited study.
Table 3 shows the count and percentage of calendar months in which the optimal portfolio outperformed the index for different values of ξ. As can be seen, the statistics are more or less the same fort all choices of ξ.
Portfolio | Average Monthly Return | Monthly Return Standard Deviation |
1.1375% | 5.4024% | |
1.1231% | 5.3993% | |
1.1510% | 5.4115% | |
1.1280% | 5.3994% | |
Nasdaq-100 | 1.1095% | 6.7804% |
Table 2: Average monthly returns and monthly return standard deviations for optimal portfolios with different values of , compared to Nasdaq-100; .
Portfolio | Number of Outperformed Months | Rate |
137 | 53.7 | |
137 | 53.7 | |
138 | 54.1 | |
137 | 53.7 |
Table 3: The count and fraction of months (over a 252 months period) that optimal portfolios corresponding to different s outperform Nasdaq-100 index; .
3.4 The impact of relaxation schedule
Dirac-3 offers four relaxation schedules, each determining the time allocated for the system to evolve and converge towards the ground state. Schedules 1, 2, 3, and 4 correspond to different time settings, with higher schedule numbers indicating slower system evolution and, consequently, a higher probability of obtaining favorable results.
Table 4 shows the average and standard deviation of monthly returns for different relaxation schedules. As expected, the highest relaxation schedule of 4 yields superior results; however, using a relaxation schedule of 3 yields similar results with a significantly improved runtime. Table 5 shows the runtimes (in seconds) of each optimization solved on Dirac3 for different relaxation schedules. Note that each test over the 21 year period consists of 255 optimization problems. As can be seen, the runtime improves significantly as we change the relaxation schedule from 4 to 3. However, further decreasing the relaxation schedule does not seem to improve the runtime.
Relaxation Schedule | Average Monthly Return | Monthly Return Standard Deviation |
4 | 1.1510% | 5.4115% |
3 | 1.1438% | 5.4191% |
2 | 1.1265% | 5.4077% |
1 | 1.1357% | 5.4220% |
Table 4: Average monthly returns and monthly return standard deviations for optimal portfolios with different values of , compared to Nasdaq-100; .
Relaxation Schedule | Optimization Runtime (seconds) |
4 | 209 +/- 28 |
3 | 60 +/- 16 |
2 | 62 +/- 17 |
1 | 72 +/- 13 |
Table 5: Average optimization runtimes; .
3.5 Comparison to a classical solver
We ran the portfolio optimization test over the 21 year period using LocalSolver (Hexaly) Optimizer, a leading classical optimization technology.
Figure 4 shows the solution energies of LocalSolver and Dirac-3. As can be seen, the energies are similar, although LocalSolver yields a slightly lower energy for some of the solutions.
4 Conclusion
We demonstrated a method for portfolio allocation that leverages investment fundamentals to maximize returns while minimizing risk. The method is implemented on a commercially available Dirac-3 quantum optimization machine. The results demonstrate the machine’s effectiveness in solving continuous quadratic optimization problems with multi-level variables. This achievement paves the way for tackling complex combinatorial optimization problems directly on quantum hardware, eliminating the need for binary conversion or graph mapping, which can cause significant problem size and dynamic range issues. Consequently, portfolios optimized using Dirac-3 achieve superior performance compared to the Nasdaq-100 index, delivering higher returns with lower monthly volatility.
5 Future Work
Our future research will explore the following avenues:
Device Tuning and Relaxation Schedules: We will investigate whether device tuning and exploring different relaxation schedules can further improve the results.
Benchmarking: We will conduct a benchmark comparison against classical methods like Monte Carlo simulation to assess the solution quality obtained by Dirac-3.
Time-to-Solution Analysis: A comparative analysis of the time-to-solution between Dirac-3, classical methods, and the QUBO format on other quantum hardware platforms would further solidify the efficiency and processing power of the Dirac-3 optimization machine.
References
[1] Akshay Ajagekar, Kumail Al Hamoud, and Fengqi You. “Hybrid Classical-Quantum Optimization Techniques for Solving Mixed-Integer Programming Problems in Production Scheduling”. In: IEEE Transactions on Quantum Engineering 3 (2022), pp. 1–16. DOI: 10.1109/TQE.2022.3187367.
[2] Adam Holmes et al. “Impact of qubit connectivity on quantum algorithm performance”. In: Quantum Sci. Technol (2020).
[3] S. Brandhofer, D. Braun, and V. Dehn. “Benchmarking the performance of portfolio optimization with QAOA”. In: Quantum Inf Process (2023).
[4] Jeffrey Cohen, Alex Khan, and Clark Alexander. Portfolio Optimization of 60 Stocks Using Classical and Quantum Algorithms. 2020. arXiv: 2008.08669 [q-fin.GN].
[5] R. Dridi and H. Alghassi. “Prime factorization using quantum annealing and computational algebraic geometry”. In: Sci Rep 7 (2017). DOI: https://doi.org/10.1038/srep43048.
[6] Hexaly Optimizer. https://www.hexaly.com/.
[7] Yanjun Ji et al. Algorithm-oriented qubit mapping for variational quantum algorithms. 2024. arXiv:
2310.09826 [quant-ph].
[8] Gushu Li, Yufei Ding, and Yuan Xie. “Tackling the Qubit Mapping Problem for NISQ-Era
Quantum Devices”. In: Proceedings of the Twenty-Fourth International Conference on Architectural Support for Programming Languages and Operating Systems. ASPLOS ’19. Providence, RI, USA: Association for Computing Machinery, 2019, pp. 1001–1014. ISBN: 9781450362405. DOI: 10.1145/3297858.3304023. URL: https://doi.org/10.1145/3297858.3304023.
[9] Harry Markowitz. “Portfolio Selection”. In: The Journal of Finance 7.1 (1952), pp. 77–91. ISSN: 00221082, 15406261. URL: http://www.jstor.org/stable/2975974 (visited on 02/28/2024).
[10] Frank Phillipson and Harshil Singh Bhatia. “Portfolio Optimisation Using the D-Wave Quantum Annealer”. In: Computational Science – ICCS 2021. Ed. by Maciej Paszynski et al. Cham: Springer International Publishing, 2021, pp. 45–59. ISBN: 978-3-030-77980-1.
[11] Adrian Prodan, Vasile-Ion Manta, and Alexandru-Gabriel Tudorache. “The performance impact of the graph topology in Ibm’s Quantum devices on Grover’s search algorithm”. In: 2021 25th International Conference on System Theory, Control and Computing (ICSTCC). 2021, pp. 327–333. DOI: 10.1109/ICSTCC52150.2021.9607230.
[12] Wolfgang Sakuler et al. A real world test of Portfolio Optimization with Quantum Annealing. 2023. arXiv: 2303.12601 [quant-ph].