# Strategic Portfolio Optimization Using Simulated, Digital, and Quantum Annealing
## 6 Portfolio Optimization Implementation
### Theoretical Remarks
Depending on the number of bits, as described in Equation (20), each asset occupies a number of variables equal to the number of bits. Therefore, the two dimensions of the QUBO matrix have a complexity of \(O(sb)\), where \(s\) is the number of strategies and \(b\) is the number of bits. It is not possible to make the resulting dense matrix more sparse, as it would contradict the goal of risk minimization in the original portfolio optimization problem. In order to minimize risk in a portfolio, the covariance between assets must be as close as possible to 0. That means that all assets in a portfolio are diverse and mitigate risk. Therefore, even if the QUBO matrix contains many 0s, they can not be eliminated because they are highly wanted. This fact makes portfolio optimization a computationally heavy problem and it shows the importance of new technologies such as quantum annealing or digital annealing. ## 7 Evaluation

We evaluate our new QUBO formulation for portfolio optimization by assuming a hypothetical investor who splits their money according to the suggestion of the QUBO optimization process and observing the development of their portfolio. We show that it is possible to add additional risk minimization, if needed, by adjusting the parameters of our model. The same is true for the maximization of the expected return. ### Dataset

Our data set consists of stocks of the New York Stock Exchange (NYSE) as well as common exchange-traded funds (ETFs). The data set contains the daily adjusted closing prices of those stocks and respective ETFs over a period of 5 years, starting on 31 December 2014 and ending on 31 December 2019. The daily adjusted closing prices of each stock and respective ETF over the 5-year period form a price series. Since the data were not complete (e.g., daily closing prices were missing for several days for certain stocks or ETFs), we decided to only keep price series that contain more than 900 daily prices. All the data were acquired via Yahoo Finance. ### Evaluation Framework

The experiments are carried out on D-Wave System's Quantum Annealer (Advantage System 4.1), on Fujitsu's Digital Annealing Unit (DAU Version 2), and on a classical computer using simulated annealing. We use default parameters for all algorithms on their respective hardware systems. We use UQO [38] as a platform to handle the execution of our experiments. Since D-Wave's Advantage System 4.1 only provides about 5000 qubits, arranged in the Pegasus graph, we were only able to use 18 strategies. We chose 8 pairs-trading strategies on ETF pairs and 10 trend-following strategies on different NYSE stocks as our 18 strategies. Each of the 18 strategies were selected by the best Sharpe ratio of the backtest results. To compare the annealing results to a random process, we created randomized portfolios, each of them consisting of an arbitrary amount of strategies that were assigned an arbitrary fraction of the capital. ### Diversification Measure

In the following figures to be seen, the coloring indicates the diversification of the portfolios. We used the following equation to determine the diversification of a portfolio:

\[\frac{\sum_{s_{i}\in P}\sum_{ \begin{subarray}{c}s_{i}\in P\\ i\
eq j\end{subarray} }cov(s_{i},s_{j})w_{s_{i}}w_{s_{j}}+\sum_{s_{i}\in P}1w_ {s_{i}}w_{s_{i}}}{-\sum_{s_{i}\in P}(w_{s_{i}}ln(w_{s_{i}}))+10^{-10}}+\frac{ 1}{\sum_{ \begin{subarray}{c}s_{i}\in P\\ i\
eq 0\end{subarray} }1}\]

In this equation, \(P\) denotes a portfolio, the price series of the portfolio are denoted by \(s_{i}\), \(s_{j}\), \(1\leq i,j\leq 18\), and \(0\leq w_{s_{i}},w_{s_{j}}\leq 1\) are the fractions of the capital that were investedinto the strategies \(s_{i}\), \(s_{j}\) in this specific portfolio \(P\). In the denominator of the first part of the equation, we added the term \(10^{-10}\) to the entropy of the portfolio to prevent division by zero, as it might be possible that \(w_{s_{i}}=1\), which implies that all other weights \(w_{s_{j}}\
eq w_{s_{i}}\) must be zero, and thus the value of the denominator would be \(ln(1)=0\).