Abstract
In this paper we propose a hybrid quantum-classical algorithm for dynamic portfolio optimization with minimal holding period. Our algorithm is based on sampling the near-optimal portfolios at each trading step using a quantum processor, and efficiently post-selecting to meet the minimal holding constraint. We found the optimal investment trajectory in a dataset of 50 assets spanning a 1 year trading period using the D-Wave 2000Q processor. Our method is remarkably efficient, and produces results much closer to the efficient frontier than typical portfolios. Moreover, we also show how our approach can easily produce trajectories adapted to different risk profiles, as typically offered in financial products. Our results are a clear example of how the combination of quantum and classical techniques can offer novel valuable tools to deal with real-life problems, beyond simple toy models, in current NISQ quantum processors.
Subject terms: Quantum information, Qubits, Computational science
Introduction
The field of quantum computing is living an unprecedented expansion due to recent experimental advances. Quantum technologies as a whole1–8 are being benefited from recent results both on quantum computer implementations9–15 as well as on quantum communications16–22. Due to this, people have started to think seriously about industrial applications of quantum computers4. Among the different verticals, finance is among the most promising ones, given the ubiquitousness of intractable mathematical problems. For a detailed description of applications of quantum computing in finance, see Ref.23. Among these applications, one of the most prominent is quantum optimization. There are many important optimization problems in finance which can be solved more efficiently using quantum computing. See Refs.24–28 for some examples. In this setting, the most paradigmatic optimization problem in finance is that of portfolio optimization, both in its static and dynamic versions.
Our aim in this work is to solve the dynamic portfolio optimization problem. An issue that investors often face is that short term investments tend to be taxed much higher than long term investments. It is common for investors to impose a minimal holding period, preventing any purchased asset from being sold before a predetermined period of time. We build upon the work from Ref.29, and demonstrate an efficient post-selection protocol to impose the minimal holding constraint. Similarly to Ref.29, we further impose that investors must invest in integer bundles, as is typically the case for exchange-traded funds (ETF) shares.
Financial model
Our aim is to find the best investment trajectory for an investor, given a level of risk that they want to take. According to Modern Portfolio Theory, the optimal investment at a defined level of risk is the one which maximizes profit30. The portfolio’s risk—or volatility—is computed from the assets’ covariance matrix. The ratio of returns to risk is the Sharpe ratio, which is our metric for comparing investments. These are defined mathematically in what follows.
Let us define , the fraction of the total budget invested in asset n at time t. The optimal holding trajectory minimizes the Modern Portfolio Theory cost function:
1 |
Here, is the vector of the logarithmic returns at time t and is the covariance matrix. The risk aversion controls the portfolios penalty for risk. This determines the amount of risk an investor is willing to take. The forecasted returns and covariance matrices can be deduced from the stocks’ prices. This is detailed, for instance, in Ref.29. Following this notation, the Sharpe ratio is given by
2 |
which, as we said, is nothing but the ration between the total return (numerator) and volatility (denominator).
At any point in time, we would like the entire available budget to be invested. This constrains the holdings to be normalized at any time t. We enforced this by penalizing portfolios which did not respect this constraint. The cost function we optimized is therefore
3 |
where the Lagrange multiplier is an hyperparameter of the model. Note also that Eq. (3) can be written as:
4 |
for some . This means that the optimal investment at time t is independent of our investment history, as long as no more constraints are included that correlate trading times among each other. In such a situation it is therefore sufficient to minimize at every time t to compute the optimal holdings . This is a good approximation, for instance, for the trading investment funds of an everyday investor, for which transaction costs and market impact may be negligible.
We assume shares can only be sold in large bundles. These constraints imply that our objective variables—the instantaneous asset holdings —are integer variables. At any trading time, we can encode the qubit values to our qubits using a binary encoding:
5 |
where is the readout value of the qubit assigned to institution n, and K is the total investment.
This encoding has several consequences. First, the holdings are always bound by: . Since , investors are not given the option to sell short securities. Allowing short-selling could be an interesting extension for this problem. Second, this encoding allows investors to split their total investment in a maximum of K bundles. This discretization is part of the reason why this problem is so hard to solve on classical computers29. From a practical perspective, using the bit variables the cost function can then be written as
6 |
with x a vector of bit variables, and Q a matrix of real numbers. In the language of combinatorial optimization, this is a quadratic unconstrained binary optimization (QUBO) problem, and is the natural input for the D-Wave quantum annealer.
In Eq. (5), we have introduced the bit depth , the number of qubits which encode the asset holdings. Typically, we would choose such that . This choice allows the investor to invest their entire budget into a single asset. We may, however, want to impose a diversification constraint. Typically, large financial institutions are not allowed to invest more than of their total budget in any single asset. Choosing such that naturally implements this diversification constraint.
Minimum holding period
The holding period is the amount of time which elapses between an investment’s purchase and its sale (or sale of a security). Because long-term gains are taxed more favourably than short-term gains, it is common to demand that investments meet a minimum holding period. In this study, we imposed a minimal holding period of 7 days, which is a natural timeframe for some realistic banking products.
Here we imposed this constraint by post-selecting investment trajectories which respected this condition. The number of possible trajectories grows exponentially . It is therefore computationally prohibitive to successively consider each trajectory and verify if they meet the minimal 7 day holding period.
Instead, we build the investment trajectory iteratively, following the flow chart presented Fig. 1. At every time t, we choose holdings for that instant. We compute them by sampling at each time t the low-energy subspace of in Eq. (4) using, in our case, the D-Wave machine. the fact that the problem can be decoupled into separate times t allows us to tackle more assets at every given time with the quantum annealer. The sampled instantaneous portfolios are considered in order of decreasing Sharpe ratio. As customary in finance, a large Sharpe ratio is an indicator of a good-quality portfolio, since it implies that the return is large for the risk being assumed. We note, however, that other figures of merit could be used, such as the returns (the larger the better), or the volatility (the lower the better). In our case, though we choose to work with the Sharpe ratio because of the afore-mentioned reasons. We only retain candidates which fulfil the minimum holding constraint.
Figure 1.
Flow chart detailing the post-selection algorithm used to efficiently eliminate trajectories which do not meet the minimum 7 day holding period.
By following iteratively, the algorithm implements a tree-like selection and efficiently rules out trajectories which do not meet the minimal 7-day holding period, as is illustrated in Fig. 2. Note that at any time t, there always exists at least one solution which meets the minimal 7-day holding period: the solution .
Figure 2.
Candidate investment trajectories are efficiently ruled out by the post-selection algorithm. Node represents the candidate holdings at time t. Green nodes meet the minimum holding period, while grey nodes do not. When the constraint is not met at time t, the node is crossed out and all resulting investment trajectories are eliminated.
Alternatively, we could include this constraint by penalizing in Eq. (3) trajectories which do not meet the minimum holding period. The corresponding penalty term would then correlate different time steps between each other, such that the cost function would not have the separable form of Eq. (4). In such a case, the problem would become even more computationally intractable, and a global optimization strategy over all possible trading times would be necessary from the very beginning. It is therefore remarkable that our simple approach, based on quantum sampling and post-selection, produces such high-quality portfolios in an extremely efficient manner.
Dimensional reduction
The number of objective variables in this problem is proportional to the number of assets, multiplied by the bit depth. For problems of commercial value, this can be very large. Because current quantum resources in Noisy Intermediate Scale Quantum (NISQ) devices are limited, a good option is to apply dimensional reduction techniques. Reducing the space of solutions searched also makes it easier for the optimization routine to converge to the global minimum.
In Ref.29, authors described a method to cluster assets based on their time series’ similarity. In the following, we apply this method, and discard all except for the best asset in each cluster (based on its historical Sharp ratio). The dimensional reduction strategy follows from applying first a Hodrick-Prescott smoothing, to extract data trends, and then computing the euclidean distance between different pairs of trends of assets. Thanks to this, we can perform a clustering of the assets into clusters of assets of similar behavior. This dimensional reduction strategy also allows us to significantly lower the portfolio’s risk, by diversifying our investment among maximally uncorrelated assets. Moreover, our target investors typically select their investment risk category. To meet this risk requirement, we performed a pre-selection among available assets. We computed each assets’ historical volatility, and discarded any asset which significantly exceeded the agreed risk level. This allows us to construct portfolios for investors with different risk profiles: high-risk, medium-risk, low-risk, and so forth.
In practice, we determined the optimal number of clusters by studying each clusters’ variance. In the studied data, we found that the mean clusters’ variance decreased exponentially with the number of clusters. For , the clusters’ variance did not significantly decrease, indicating that 7 clusters capture almost all of the system’s variations. We therefore set in our calculations.
Results
Following the protocol detailed in previous sections, based on looking at optimal Sharpe ratios of portfolios computed with the D-Wave quantum annealer, we found the optimal investment trajectory between May the 31st 2019 and May the 31st 2020 among a total of 50 international assets and indices. Daily transactions were allowed, but investments had to meet a minimum 7 day holding period. We allowed investments to be split into a maximum of bundles, and set the bit depth to .
We found the optimal portfolios by minimizing Eq. (3) on the D-Wave 2000Q processor. Computed investment trajectories for five risk packages (minimum risk, , , , and annual risk) are plotted in Fig. 3. Also plotted are 1000 random investment trajectories which meet the minimum 7 day holding period. These give us some intuition about the space of allowed portfolios. We see that allowed portfolios tend to exist between and annualized profit, and between and risk (as measured by the annualized volatility). It is clearly visible that the investment trajectories obtained using our method based on quantum optimization, dimensional reduction and post-selection, tend to gather much closer to the efficient frontier in portfolio space than those obtained by investing at random.
Figure 3.
Investment trajectories, chosen among 50 assets spanning May the 31st 2019 to May the 31st 2020. The blue dots represent randomly selected trajectories. The coloured dots are investment trajectories with different levels of risk obtained using our quantum optimization toolbox.
In Fig. 4, we show an example investment trajectory. This corresponds to the risk package (purple dot in Fig. 3), which yields return on investment. We can see from this figure that the most profitable assets which meet the risk limit are Bankia Fonduxo Universal FI, Bankia Futuro Sostenible Universal FI, Bankia Indice Eurostoxx Universal FI, Amundi Fds Pioneer US Bd A2 EUR C, Fidelity Global Technology A-Acc-EUR, Nordea 1 − Chinese Equity Y EUR, and Franklin India A(acc)EUR. As can be read off from Fig. 4, the optimal investment on May the 31st 2019 meeting these constraints is: in Fidelity Global Technology A-Acc-EUR, in Amundi Fds Pioneer US Bd A2 EUR C, in Franklin India A(acc)EUR, and in Nordea 1 − Chinese Equity Y EUR. The everyday composition of the trading trajectory can be read form the chart, and it always fulfils by construction the minimum holding period.
Figure 4.
The optimal investment trajectory between May the 31st 2019 and May the 31st 2020 among considered assets for an investor wanting to take risk. As can be seen from Fig. 3, this portfolio provided annualized return on investment (purple dot in the Fig. 3). Data for this calculation was obtained from daily prices of international assets and indices as explained in the text, which are public and can be obtained from e.g. Bloomberg, Yahoo Finance, and/or Morningstar databases.
Finally, we would like to discuss about the computational running time and quality of the computed portfolios, in comparison with other classical and quantum optimization strategies. The running time to compute the optimal portfolios in Fig. 3 using our strategy of combining D-Wave and post-selection was of just a few minutes, for daily portfolios of 50 assets. For comparison, other quantum optimization strategies, such as Variational Quantum Eigensolvers (VQE) on universal quantum processors are highly limited at the moment and can only handle very small portfolios with typically 2–3 assets at most29. Compared to classical solvers, our method is way faster than brute-force classical search, which scales exponentially fast in the number of qubits and quickly hits astronomical numbers (the problem is clearly intractable in this sense for 50 assets). Compared to other solvers, D-Wave quantum annealing is known to be faster and allow larger portfolios than solvers such as Gekko, see Table IV in Ref.29, which equally applies in our case.
Conclusion
Here we have proposed a hybrid quantum-classical algorithm for dynamic portfolio optimization with minimal holding period. Our algorithm is based on quantum sampling of near-optimal portfolios at each trading step, combined with dimensional reduction and post-selection. We tested our idea using quantum optimization with the D-Wave 2000Q processor, and real data from 50 assets during 1 year. Our study shows that the method is remarkably efficient and produces in few minutes results close to the optimal efficient frontier in portfolio space, much better than typical random portfolios. We also showed how our approach can be used to produce trajectories corresponding to different risk profiles, in accordance with typical products offered by financial institutions to investors. Our results are a clear example of how the combination of quantum and classical techniques can provide novel and valuable methods to deal with real-life financial data in today’s NISQ quantum processors. Moreover, we believe that the use of distributed quantum computer architectures, such as those discussed in Ref.3, could accelerate even more the implementation of this type of quantum computing algorithms to solve real-life financial mathematical problems.
Acknowledgements
We wish to thank Ignacio Cea from Bankia, as well as Carlos Ceruelo and Ángel Sánchez from Everis, for enabling this fascinating project. We thank Christophe Jurczak, Pedro Luis Uriarte, Pedro Muñoz-Baroja, Joseba Sagastigordia, Creative Destruction Lab, BIC-Gipuzkoa, DIPC, Ikerbasque, and Basque Government for constant support. We also acknowledge the hard work and constant feedback from Multiverse’s fantastic technical team, Francesco Benfenati, Gianni Del Bimbo, Rodrigo Hernandez, Beinat Mencia, Samuel Palmer, and Serkan Sahin.
Author contributions
All authors contributed to the settling of the problem, development of the algorithmic solution, numerical simulations and cross-checks, and writing the paper.
Competing interests
The authors declare no competing interests.
Footnotes
Publisher's note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
References
- 1.Gyongyosi L, Imre S. A survey on quantum computing technology. Comput. Sci. Rev. 2019;31:51. doi: 10.1016/j.cosrev.2018.11.002. [DOI] [Google Scholar]
- 2.Gyongyosi L, Imre S, Nguyen HV. A survey on quantum channel capacities. IEEE Commun. Surv. Tutor. 2018;20:1149. doi: 10.1109/COMST.2017.2786748. [DOI] [Google Scholar]
- 3.Gyongyosi L, Imre S. Scalable distributed gate-model quantum computers. Sci. Rep. 2021;11:5172. doi: 10.1038/s41598-020-76728-5. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4.MacQuarrie ER, Simon C, Simmons S, Maine E. The emerging commercial landscape of quantum computing. Nat. Rev. Phys. 2020;2:596. doi: 10.1038/s42254-020-00247-5. [DOI] [Google Scholar]
- 5.Gyongyosi L, Imre S. Circuit depth reduction for gate-model quantum computers. Sci. Rep. 2020;10:11229. doi: 10.1038/s41598-020-67014-5. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6.Gyongyosi L, Imre S. Optimizing high-efficiency quantum memory with quantum machine learning for near-term quantum devices. Sci. Rep. 2020;10:135. doi: 10.1038/s41598-019-56689-0. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 7.Gyongyosi L. Quantum state optimization and computational pathway evaluation for gate-model quantum computers. Sci. Rep. 2020;10:4543. doi: 10.1038/s41598-020-61316-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Gyongyosi L, Imre S. Dense quantum measurement theory. Sci. Rep. 2019;9:6755. doi: 10.1038/s41598-019-43250-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9.Arute F, Arya K, Babbush R, Bacon D, Bardin JC, Barends R, Biswas R, Boixo S, Brandao FGSL, Buell DA, Burkett B, Chen Y, Chen Z, Chiaro B, Collins R, Courtney W, Dunsworth A, Farhi E, Foxen B, Fowler A, Gidney C, Giustina M, Graff R, Guerin K, Habegger S, Harrigan MP, Hartmann MJ, Ho A, Hoffmann M, Huang T, Humble TS, Isakov SV, Jeffrey E, Jiang Z, Kafri D, Kechedzhi K, Kelly J, Klimov PV, Knysh S, Korotkov A, Kostritsa F, Landhuis D, Lindmark M, Lucero E, Lyakh D, Mandrà S, McClean JR, McEwen M, Megrant A, Mi X, Michielsen K, Mohseni M, Mutus J, Naaman O, Neeley M, Neill C, Niu MY, Ostby E, Petukhov A, Platt JC, Quintana C, Rieffel EG, Roushan P, Rubin NC, Sank D, Satzinger KJ, Smelyanskiy V, Sung KJ, Trevithick MD, Vainsencher A, Villalonga B, White T, Yao ZJ, Yeh P, Zalcman A, Neven H, Martinis JM. Quantum supremacy using a programmable superconducting processor. Nature. 2019;574:505. doi: 10.1038/s41586-019-1666-5. [DOI] [PubMed] [Google Scholar]
- 10.Preskill J. Quantum computing in the NISQ era and beyond. Quantum. 2018;2:79. doi: 10.22331/q-2018-08-06-79. [DOI] [Google Scholar]
- 11.Harrow AW, Montanaro A. Quantum computational supremacy. Nature. 2017;549:203. doi: 10.1038/nature23458. [DOI] [PubMed] [Google Scholar]
- 12.Aaronson, S. & Chen, L. Complexity-theoretic foundations of quantum supremacy experiments. In Proceedings of the 32nd Computational Complexity Conference, 22:1–22:67 (2017)
- 13.Alexeev Y, et al. Quantum computer systems for scientific discovery. PRX Quantum. 2021;2:017001. doi: 10.1103/PRXQuantum.2.017001. [DOI] [Google Scholar]
- 14.Awschalom D, Berggren KK, Bernien H, Bhave S, Carr LD, Davids P, Economou SE, Englund D, Faraon A, Fejer M, Guha S, Gustafsson MV, Hu E, Jiang L, Kim J, Korzh B, Kumar P, Kwiat PG, Lončar M, Lukin MD, Miller DA, Monroe C, Nam SW, Narang P, Orcutt JS, Raymer MG, Safavi-Naeini AH, Spiropulu M, Srinivasan K, Sun S, Vučković J, Waks E, Walsworth R, Weiner AM, Zhang Z. Development of quantum interconnects (QuICs) for next-generation information technologies. PRX Quantum. 2021;2:017002. doi: 10.1103/PRXQuantum.2.017002. [DOI] [Google Scholar]
- 15.Foxen B, Neill C, Dunsworth A, Roushan P, Chiaro B, Megrant A, Kelly J, Chen Z, Satzinger K, Barends R, Arute F, Arya K, Babbush R, Bacon D, Bardin JC, Boixo S, Buell D, Burkett B, Chen Y, Collins R, Farhi E, Fowler A, Gidney C, Giustina M, Graff R, Harrigan M, Huang T, Isakov SV, Jeffrey E, Jiang Z, Kafri D, Kechedzhi K, Klimov P, Korotkov A, Kostritsa F, Landhuis D, Lucero E, McClean J, McEwen M, Mi X, Mohseni M, Mutus JY, Naaman O, Neeley M, Niu M, Petukhov A, Quintana C, Rubin N, Sank D, Smelyanskiy V, Vainsencher A, White TC, Yao Z, Yeh P, Zalcman A, Neven H, Martinis JM. Demonstrating a continuous set of two-qubit gates for near-term quantum algorithms. Phys. Rev. Lett. 2020;125:120504. doi: 10.1103/PhysRevLett.125.120504. [DOI] [PubMed] [Google Scholar]
- 16.Pirandola S, Braunstein SL. Physics: Unite to build a quantum Internet. Nature. 2016;532:169. doi: 10.1038/532169a. [DOI] [PubMed] [Google Scholar]
- 17.Wehner S, Elkouss D, Hanson R. Quantum internet: A vision for the road ahead. Science. 2018 doi: 10.1126/science.aam9288. [DOI] [PubMed] [Google Scholar]
- 18.Pirandola S, Andersen UL, Banchi L, Berta M, Bunandar D, Colbeck R, Englund D, Gehring T, Lupo C, Ottaviani C, Pereira JL, Razavi M, Shaari JS, Tomamichel M, Usenko VC, Vallone G, Villoresi P, Wallden P. Advances in quantum cryptography Adv. Opt. Photon. 2020;12:1012. doi: 10.1364/AOP.361502. [DOI] [Google Scholar]
- 19.Pirandola S. End-to-end capacities of a quantum communication network communications. Physics. 2019;2:51. doi: 10.1038/s42005-019-0147-3. [DOI] [Google Scholar]
- 20.Pirandola S, Laurenza R, Ottaviani C, Banchi L. Fundamental limits of repeaterless quantum communications. Nat. Commun. 2017;8:15043. doi: 10.1038/ncomms15043. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 21.Pirandola S, et al. Theory of channel simulation and bounds for private communication. Quantum Sci. Technol. 2018;3:035009. doi: 10.1088/2058-9565/aac394. [DOI] [Google Scholar]
- 22.Pirandola S. Bounds for multi-end communication over quantum networks. Quantum Sci. Technol. 2019;4:045006. doi: 10.1088/2058-9565/ab3f66. [DOI] [Google Scholar]
- 23.Orús R, Mugel S, Lizaso E. Quantum computing for finance: Overview and prospects. Rev. Phys. 2019;4:100028. doi: 10.1016/j.revip.2019.100028. [DOI] [Google Scholar]
- 24.Mugel, S., Lizaso, E., & Orus, R. Use Cases of Quantum Optimization for Finance, 1–10 arXiv: 2010.01312 (2020).
- 25.Rosenberg G, Haghnegahdar P, Goddard P, Carr P, Wu K, López De Prado M. Solving the optimal trading trajectory problem using a quantum annealer. IEEE J. Select. Top. Signal Process. 2016;10:1053. doi: 10.1109/JSTSP.2016.2574703. [DOI] [Google Scholar]
- 26.Elsokkary, N., Khan, F. S., Torre, D. L., Humble, T. S., & Gottlieb, J. Financial Portfolio Management using D-Wave’s Quantum Optimizer: The Case of Abu Dhabi Securities Exchange, 1−4 (IEEE, 2017).
- 27.Grant, E., Humble, T. & Stump, B. Benchmarking Quantum Annealing Controls with Portfolio Optimization arXiv: 2007.03005 (2020).
- 28.Cohen, J., Khan, A. & Alexander, C. Portfolio Optimization of 40 Stocks Using the DWave Quantum Annealer 1–16 arXiv: 2007.01430 (2020).
- 29.Mugel, S. et al. Dynamic Portfolio Optimization with Real Datasets Using Quantum Processors and Quantum-Inspired Tensor Networks, 1–11 arXiv: 2007.00017 ( 2020),
- 30.Markowitz H. Portfolio selection. J. Financ. 1952;7:77. doi: 10.2307/2975974. [DOI] [Google Scholar]