**Recap**

After having introduced the theoretical framework in my previous post, I now want to present a practical guide for the portfolio optimisation. Our goal is to optimise a portfolio with respect to utility. As mentioned before, Full-Scale Optimisation (FSO) is free from any limitations on the form of the utility function that is to be optimised. This is in contrast to the Mean-Variance (MV) framework, which is limited to the first two moments. In the following simple example, we optimise a portfolio with regards to an exponential utility function

(1)

where is the degree of absolute risk aversion. denotes the portfolio returns.

**Data**

For the sake of simplicity, we collect daily price data for the top 3 constituents of the S&P500, namely Microsoft (MSFT), Apple (AAPL) and Amazon (AMZN) from January 1st 2015 to December 31st 2019, yielding 1258 observations in total. Keep in mind that our sample selection includes a survivorship bias, which we will only address at this point. Using the respective closing prices, we calculate daily log returns and store them in a matrix. Table 1 reports the summary statistics for the log returns. All stocks feature a leptocurtic behaviour and a slight skewness regarding the return distribution, indicating a higher possibility for larger fluctuations on the fat tails. The assumption of non-normality cannot be rejected across all return series.

Table 1: Summary statistics of daily log returns.

Mean (%) | Vola. (%) | Kurtosis | Skewness | JB-stat. | P-value | |
---|---|---|---|---|---|---|

MSFT | 0.097 | 1.467 | 9.780 | 0.098 | 2409.341 | 0.000 |

AAPL | 0.079 | 1.569 | 7.053 | -0.368 | 888.540 | 0.000 |

AMZN | 0.142 | 1.826 | 11.545 | 0.743 | 3940.029 | 0.000 |

In addition, the returns are positively correlated (Table 2), so price changes tend to move in the same direction. We find the highest correlation between MFST and AMZN (0.63) and the lowest correlation between AAPL and AMZN (0.50).

Table 2: Correlation matrix of the employed stocks.

MSFT | AAPL | AMZN | |
---|---|---|---|

MSFT | 1.00 | 0.57 | 0.63 |

AAPL | 1.00 | 0.50 | |

AMZN | 1.00 |

**Empirical Application**

We use the programming language R for the further analysis. After storing the daily log returns in a matrix, we import the necessary libraries for the calculations.

library(tseries) library(quadprog) library(PortfolioAnalytics) library(DEoptim) library(quantmod) library(IntroCompFinR)

Using the DEoptim package, which allows for the use of the Differential Evolution algorithm, we now calculate the FSO optimal portfolio allocation.

N <- nrow(ReturnMatrix) mintheta <- 0 maxtheta <- 1 lower <- rep(mintheta,N) upper <- rep(maxtheta,N) # Create a parameter matrix for the different parameters that are to be tested A <- c(0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6) Parameter_expo <- cbind.data.frame(A)} # Define the Exponential Utility Function # A: degree of absolute risk aversion # r: portfolio return Exponential_Utility <- function(A, r){ return(-exp(-A*(1+r)))} # Define the objective function for exponential utility optimisation obj_expo <- function(theta,A,ReturnMatrix){ rp = t(theta) %*% ReturnMatrix # portfolio return vector with length T opt_theta <- -((1/ncol(ReturnMatrix))*sum(Exponential_Utility(A,rp))) weight_penalty = 100*(1-sum(theta))^2 #such that weights add up to one return(opt_theta + weight_penalty)} # Calculate the FSO optimal portfolio allocations for each of the above parameter settings AllocationMatrix_expo_FSO <- data.frame(matrix(nrow=(nrow(Parameter_expo)), ncol=(nrow(ReturnMatrix)))) for (i in 1:(nrow(Parameter_expo))){ controlDE <- list(strategy=1, NP=50, F=0.5, CR=0.8, steptol=50, itermax=1000, trace=100) out <- DEoptim(fn=obj_expo, ReturnMatrix=ReturnMatrix, A=Parameter_expo$A[i], lower=lower, upper=upper, control=controlDE) AllocationMatrix_expo_FSO[i, 1:(nrow(ReturnMatrix))] <- out $optim$bestmem}}

To obtain the MV optimal allocation, we calculate the average FSO return for each parameter setting and set it as target return for the MV optimisation as follows:

# Calculate the MV optimal portfolio allocations for each of the above parameter settings AllocationMatrix_expo_MV <- data.frame(matrix(nrow=(nrow(Parameter_expo)), ncol=(nrow(ReturnMatrix)))) for (i in 1:(nrow(Parameter_expo))){ mu = matrix((rowMeans(ReturnMatrix)), nrow=1) sigma = cov(t(ReturnMatrix)) target.return = Avg_Rp_expo_FSO[i,] port.sol = portfolio.optim(x=mu, covmat=sigma, pm=target.return, shorts=F, reslow=rep(0,(nrow(ReturnMatrix))), reshigh=rep(1,(nrow(ReturnMatrix)))) AllocationMatrix_expo_MV[i, 1:nrow(ReturnMatrix)] <- port.sol$pw}

Using both portfolio allocation matrices, we calculate the respective return distribution as portfolio weight multiplied with the returns matrix. Besides analysing statistical properties of the resulting return distributions (which we consider known practice for the readers), we now want to benchmark the FSO framework to the MV framework. Therefore, we introduce the certainty equivalent as a measure for performance (Hagstroemer et al., 2008). Recall that the certainty equivalent is the certain return that would give an investor the same amount of utility as the uncertain return of a risky investment. The certainty equivalent for the exponential utility function is derived from the equation

(2)

which can be transformed and rearranged to

(3)

where denotes the average utility. In our example we define the certainty equivalent functions as

# Define the certainty equivalent function for exponential utility rCE_exponential <- function(A,avgutil){return((-1/A)*log(-avgutil)-1)}

and in the following, calculate the respective certainty equivalents for FSO & MV portfolio allocations.

# Calculate the FSO \& MV certainty equivalents rCE_exp_FSO <- data.frame(matrix(nrow=nrow(Parameter_expo),ncol=1)) rCE_exp_MV <- data.frame(matrix(nrow=nrow(Parameter_expo),ncol=1)) for (i in 1:nrow(Parameter_expo)){ rCE_exp_FSO[i,1] <- rCE_exponential(avgutil=(Avg_utility_exp_FSO[i,]),A=Parameter_expo$A[i]) rCE_exp_MV[i,1] <- rCE_exponential(avgutil=(Avg_utility_exp_MV[i,]),A=Parameter_expo$A[i])}

To be more precise, we are interested in the difference between the FSO and MV certainty equivalents, to assess the portfolio performance:

(4)

# Calculate differences of certainty equivalents Delta_exp_rCE <- data.frame(matrix(nrow=nrow(Parameter_expo),ncol=1)) for (i in 1:nrow(Parameter_expo)){ Delta_exp_rCE[i,1] <- (rCE_exp_FSO[i,]-rCE_exp_MV[i,])}

**Results**

Table 3 shows the in-sample results for the respective portfolio allocations. We report differences of the FSO & MV return distributions up to the fourth central moment, as well as the differences in the average utility and our main performance measure— the differences in certainty equivalents. The expected portfolio return equals the same for both approaches, as the expected return of FSO is the target return for the MV approach.

Observably, the FSO return distribution is more volatile for an absolute degree of risk aversion up to and offers higher skewness and kurtosis than the MV return distribution for all degrees of risk aversion, except for . This reflects that more extreme returns in the sample are considered in the FSO distributional properties. The differences in average utility are marginally positive for all parameter specifications. As a result, FSO outperforms the MV portfolio in this regard.

For the main performance measure (the differences in certainty equivalents), we again observe FSO outperforming the MV portfolio, although the reported differences are marginal as well. This is due to the fact that we are analysing daily returns, which generally do not take on large values, and due to the shape of the exponential utility, which can be well approximated by the MV framework. The full potential of the FSO framework is displayed when the function that is to be optimised features a threshold, e.g. for s-shaped utility.

The flexibility of modeling complex objective functions and optimising without simplifying assumptions on the underlying distribution make FSO a powerful tool for portfolio analysis.

Table 3: In-sample results for exponential utility.

A | Avg Return (%) | Δ Vola. (%) | Δ Sk. | Δ Ku. | Δ Avg Utility | Δ CE (%) |
---|---|---|---|---|---|---|

0.50 | 1.42E-01 | 3.03E-07 | 1.39E-05 | 1.88E-04 | 4.09E-07 | 1.35E-04 |

1.00 | 1.42E-01 | 2.90E-07 | 1.42E-05 | 1.92E-04 | 3.61E-07 | 9.82E-05 |

1.50 | 1.42E-01 | 2.86E-07 | 1.30E-05 | 1.78E-04 | 2.49E-07 | 7.45E-05 |

2.00 | 1.42E-01 | 2.93E-07 | 1.43E-05 | 1.93E-04 | 1.28E-07 | 4.75E-05 |

2.50 | 1.42E-01 | 2.83E-07 | 1.42E-05 | 1.92E-04 | 3.76E-08 | 1.84E-05 |

3.00 | 1.40E-01 | -7.96E-06 | -4.56E-04 | -5.52E-03 | 7.69E-09 | 5.16E-06 |

3.50 | 1.36E-01 | 6.44E-06 | 4.42E-04 | 4.02E-03 | 4.04E-09 | 3.84E-06 |

4.00 | 1.32E-01 | 2.79E-06 | 2.21E-04 | 1.53E-03 | 7.46E-10 | 1.02E-06 |

4.50 | 1.29E-01 | -3.12E-06 | 2.01E-04 | 2.77E-03 | 2.63E-08 | 5.28E-05 |

5.00 | 1.26E-01 | 2.21E-06 | 3.31E-03 | 3.00E-02 | 6.78E-08 | 2.02E-04 |

5.50 | 1.23E-01 | -2.16E-06 | 3.14E-03 | 3.17E-02 | 5.89E-08 | 2.63E-04 |

6.00 | 1.21E-01 | 1.38E-06 | 4.22E-03 | 3.98E-02 | 4.91E-08 | 3.31E-04 |

**References**

Adler, T. and Kritzman, M. (2007). Mean-variance versus full-scale optimisation: In and out of sample. *Journal of Asset Management* (7), pp. 302-311.

Hagströmer, B. and Binner, J.M. (2009). Stock portfolio selection with full-scale optimization and differential evolution. *Applied Financial Economics* (19), pp. 1559-1571.

Hagströmer, B. et al. (2008). Mean-variance vs full-scale optimization: Broad evidence for the UK. *Federal Reserve Bank of St. Louis*, Working Paper No. 2007-016D.

Maringer, D. (2008). Risk preferences and loss aversion in portfolio optimization. *Computational Methods in Financial Engineering* (Eds) E. Kontoghiorghes, B. Rustem and P. Winkler, Springer, Berlin, Heidelberg, pp. 27-45.

Storn, P. and Price, K. (1997). Differential evolution – a simple and efficient heuristic for global optimization over continuous spaces. *Journal of Global Optimization* (11), pp. 341-359.

Yollin, G. (2009). R Tools for Portfolio Optimization. Retrieved from http://past.rinfinance.com/agenda/2009/yollin_slides.pdf.