Portfolio Selection by Full-Scale Optimization and Differential Evolution (II/II)

Reading Time: 4 minutes

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)   \begin{equation*}U=-exp(-A(1+r_p)\end{equation*}

where A is the degree of absolute risk aversion. r_p 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 (N \times S) 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. (%)KurtosisSkewnessJB-stat.P-value
MSFT0.0971.4679.7800.0982409.3410.000
AAPL0.0791.5697.053-0.368888.5400.000
AMZN0.1421.82611.5450.7433940.0290.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.

 MSFTAAPLAMZN
MSFT1.000.570.63
AAPL1.000.50
AMZN1.00
Empirical Application

We use the programming language R for the further analysis. After storing the daily log returns in a (N \times S) 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 A 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 \theta^{*} 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)   \begin{equation*}u\left(1+r_{C E}\right)=E u\left(1+r_{p}\right)\end{equation*}

which can be transformed and rearranged to

(3)   \begin{equation*}r_{C E}=-\frac{1}{A} \ln (-\bar{u})-1\end{equation*}

where \bar{u} 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)   \begin{equation*}\Delta r_{C E}=r_{C E}^{F S O}-r_{C E}^{M V}\end{equation*}

# 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 A=2.5 and offers higher skewness and kurtosis than the MV return distribution for all degrees of risk aversion, except for A=3. 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.

AAvg Return (%)Δ Vola. (%)Δ Sk.Δ Ku.Δ Avg UtilityΔ CE (%)
0.501.42E-013.03E-071.39E-051.88E-044.09E-071.35E-04
1.001.42E-012.90E-071.42E-051.92E-043.61E-079.82E-05
1.501.42E-012.86E-071.30E-051.78E-042.49E-077.45E-05
2.001.42E-012.93E-07 1.43E-051.93E-04 1.28E-074.75E-05
2.501.42E-012.83E-071.42E-05 1.92E-043.76E-081.84E-05
3.001.40E-01-7.96E-06-4.56E-04-5.52E-037.69E-095.16E-06
3.501.36E-016.44E-064.42E-044.02E-034.04E-093.84E-06
4.001.32E-012.79E-062.21E-041.53E-037.46E-101.02E-06
4.501.29E-01-3.12E-06 2.01E-042.77E-032.63E-085.28E-05
5.001.26E-012.21E-063.31E-033.00E-026.78E-082.02E-04
5.501.23E-01-2.16E-063.14E-033.17E-025.89E-082.63E-04
6.001.21E-011.38E-064.22E-033.98E-024.91E-083.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.

Print Friendly, PDF & Email
+ posts