# Strategic Portfolio Optimization Using Simulated, Digital, and Quantum Annealing
## 6 Portfolio Optimization Implementation
### Pairs-Trading Strategy  
The pairs-trading strategy was implemented similarly to [PERSON] et al. [24] (p. 56) to show how an investment strategy can be used in combination with annealing algorithms. Because most of the price series of assets are not stationary, cointegrated pairs of price series were used. If a linear combination of non-stationary price series can be found, then they are cointegrated. To find the stationary combinations, the ADF test was used. First, for every possible combination of distinct price series a linear regression was created. The regression coefficient tells how the pairs are combined. The idea is that if for example, one asset is 25% long, then the other one is 75% short. The regressions coefficient is the so-called hedge ratio. Next, the ADF test was executed on the combined price series to test whether the combined series is stationary. If that was the case, then the Hurst exponent was calculated to determine how strong the series' stationarity is. Only strongly stationary series were used for further executions of the pairs trading strategy. Afterward, the remaining price series were tested in an out-of-sample data set. As parameters for the strategy the rolling mean and the rolling standard deviation of the series are needed. To calculate the rolling mean and rolling standard deviation, 1/4 of the half-life was used for the rolling window size. For each data point of the price series, the Z-score in its distribution of returns was calculated. For simplification, we assumed that the returns follow a Gaussian distribution. The formula for calculating the z-score is:  
\[\text{z-score}=\frac{\text{return Of PriceSeries $-$ rolling Mean}}{\text{rolling Standard Deviation}} \tag{19}\]  
If the z-score is in one of the two 25% confidence intervals, then a trade will be executed. The first price series of the pair will be invested long and the second short. The hedge ratio tells how much the second will be invested in short per unit of the first asset. At that moment the return of the cointegrated price series is on the edge of its return distribution. Because of the stationarity, the return will revert to its mean. As soon as the return comes back close to its mean, the trade will be finalized and both positions will be closed. For every transaction, transaction costs of 1% have been assumed. This includes commissions and fees for the US-American market of a broker (interactive brokers commissions, [[https://www.interactivebrokers.com/en/index.php?f=1590&p=stocks1](https://www.interactivebrokers.com/en/index.php?f=1590&p=stocks1)]([https://www.interactivebrokers.com/en/index.php?f=1590&p=stocks1](https://www.interactivebrokers.com/en/index.php?f=1590&p=stocks1)), 29 August 2021). Slippage and market impact are not included because we only used percentages of the overall capital for the calculation of the positions. To model slippage and market impact, exact transaction amounts must be known. Out of the result of the backtest, the Sharpe ratio for every pair was calculated and it is used later on for the annealing. For the Sharpe ratio, a risk-free rate of 1.54% was used (YCharts, US 1 Year Treasury Rate, [[https://www.ycharts.com/indicators/1_year_treasury_rate](https://www.ycharts.com/indicators/1_year_treasury_rate)]([https://www.ycharts.com/indicators/1_year_treasury_rate](https://www.ycharts.com/indicators/1_year_treasury_rate)), 29 August 2021). The risk-free rate is the return of the 1-year treasury bill of the US.