Picking the most efficient portfolio out of 314 US stocks at one time
We enter 314 US liquid common stocks into our portfolio optimization application, which runs well with 64 stocks. After making adjustments to the code to allow for greater scale, and instrumenting our quantum methods to ignore runs > 64 stocks, we were successful. Here is what we find and learn.
Our portfolio optimization application runs a set of stocks through a series of processing steps, and produces a set of portfolios with the lowest Chicago Quantum Net Score (CQNS). This is a risk minus reward calculation based on 1 year of daily stock market data. We cannot predict the future, but we can make an educated guess on how stocks trade together.
Our model finds stocks that zig when others zag. It finds stocks that when held together should move with the stock market indices but deliver less risk and less price volatility. We do this by calculating the patterns behind the stock market trading results. We find a set of stocks that work well together.
This is not a trading model. It suggests a buy and hold strategy based on the previous year’s trading data. It will not make for exciting headlines, but should be less risky during time of market declines, and potentially outperform its benchmarks by avoiding some losses.
Why pick this problem to run on quantum and classical computers? We pick this problem because it has value to a typical investor and it requires too many portfolios to be reviewed then can be checked reasonably by brute force. In other words, we are past the point of certainty (we were certain at up to 40 stocks in a portfolio).
We used this problem to test whether a quantum annealing computer, running in under a minute, could find solutions that were equivalent to those found by classical methods. They do for 64 assets, which is the limit of the hardware we are allowed to run on: the D-Wave Systems 2000Q with 2,048 qubits and the Chimera architecture (introduced 2017).
We just ran 314 stocks at one time to find the one more efficient portfolio. This is a search space of 3.337480e+94 stock portfolios, or 2³¹⁴ stock portfolios, or 33,374,797,436,264,220,037,422,214,158,899,251,790,667,258,161,822,699,530,422,525,122,222,183,215,322,508,594,108,782,608,383 stock portfolios.
Challenges in the run include a few scale-up issues:
- We are using a cholesky decomposition to ensure we have positive eigenvalues which ensures we have a semi-definite positive matrix. This avoids having negative variances. We have issues of precision, where some of our eigenvalues are negative at the level of precision, or -1.215 e-18 to -9.30 e-21. As a result, we remove the Cholesky decomposition and just test for positive eigenvalues within a level of precision tolerance. We will evaluate giving a ‘nudge’ or slight positive adjustment to all linear terms (1 e-12).
- We tried to use an integer value of 314! (314 factoral), which exceeds Python’s largest integer value of 10³⁰⁸. When we asked Google for the value of 314!, it said infinity, so we are probably ok to remove that formatting logic.
- Our print-outs were failing in matplotlib because there were too many values to show. We set an rcParam chunksize parameter to 10k which allows us to continue producing graphics that look the same as before.
- We still have an issue in our print-outs of Monte Carlo where a few portfolios sizes show up as having no valid random samples found with a CQNS value < 1.0. This requires a formatting fix.
Here were the results of our first successful 314 asset run, before any optimization work to reduce times or improve scores, in order of the quality of the solution:
We are energized by our results. We can evaluate 314 stocks in one run classically. We believe we can tune our results to speed up some of our slower methods without losing quality, while slowing others down to help them find better solutions (deeper minimum solutions). We keep our tabu sampler in the race because we believe it can provide a good solution, but we cannot make it work well today.
Our upper limit scale plan is ~3,200 stocks, which is the full set of NYSE-listed, and NASDAQ Q-class common stocks with a clean status. We exclude preferred stocks (as they act more like bonds) and we exclude mutual funds because they only have 1 ‘trade’ or ‘market price’ per day. That is the Net Asset Value (NAV).
We are including two more classical methods in this challenge, Toshiba’s Simulated Bifurcation Machine (which runs on AWS) & Quantum Walks on Graphs. We are going to re-evaluate the D-Wave Systems Hybrid Solver.
While scaling up past 314 stocks, we will also work to tune our 314 asset performance.
Finally, we have 3,200 stocks in a list. How can we create a user experience to make it fun and easy to pick stocks to evaluate?
Thank you for reading. We welcome client inquiries.
Jeffrey Cohen, President, US Advanced Computing Infrastructure, Inc.
September 8, 2020