First we calculate the final wealth of the universal portfolio for all possible pairs of stocks, and show the corresponding cumulative probability function, and which pair is the best. This shows how concise R code can be.
library(logopt)
x <- coredata(nyse.cover.1962.1984)
w <- logopt:::x2w(x)
nDays <- dim(x)[1]
nStocks <- dim(x)[2]
Days <- 1:nDays
FinalWealth <- function(cols) {
xij <- x[,cols]
uc <- universal.cover(xij, 20)
return(uc[length(uc)])
}
ws <- combn(1:nStocks, 2, FinalWealth)
plot(ecdf(ws),col="blue",pch=19,cex=0.5)
grid()
# show the best pair
BestIdx <- combn(1:nStocks,2)[,which.max(ws)]
cat(sprintf("Max final wealth: %.4f for pair (%s,%s)\n", max(ws), colnames(x)[BestIdx[1]], colnames(x)[BestIdx[2]]))
The result is the figure below, plus this line
Max final wealth: 78.4742 for pair (comme,kinar)
There are two interesting observations to make:
- There is a long, thin tail. In other words, there are some pairs giving good results, but they are relatively rare.
- The best pair happens to be one of the examples in Cover's article, probably not a coincidence.
WealthRatio <- function(cols) {
xij <- x[,cols]
uc <- universal.cover(xij, 20)
return(uc[length(uc)]/max(w[length(uc),cols]))
}
wrs <- combn(1:nStocks, 2, WealthRatio)
plot(ecdf(wrs),col="blue",pch=19,cex=0.5)
grid()
# show the best and worst pairs
BestIdx <- combn(1:nStocks,2)[,which.max(wrs)]
cat(sprintf("Max increase from best stock: %.4f for pair (%s,%s)\n", max(wrs), colnames(x)[BestIdx[1]], colnames(x)[BestIdx[2]]))
WorstIdx <- combn(1:nStocks,2)[,which.min(wrs)]
cat(sprintf("Min ratio from best stock: %.4f for pair (%s,%s)\n", min(wrs), colnames(x)[WorstIdx[1]], colnames(x)[WorstIdx[2]]))
The result is the figure below, plus these lines
Max increase from best stock: 4.3379 for pair (iroqu,kinar)
Min ratio from best stock: 0.3773 for pair (dupont,morris)
And we can do similar observations:
- There is a long, thin tail, even thinner than for the wealth itself. In other words, there are some pairs giving good results, but they are relatively rare.
- In the majority of the case (about 60%), the wealth of universal portfolio is below the wealth of the best stock in the pair, sometimes significantly so.
- The best pair happens to be another one of the examples in Cover's article, probably not a coincidence either.
The general feeling is that universal portfolio is a valid approach, but maybe not as performing as could be deduced from the original article that cherry picked the examples.
No comments:
Post a Comment