Recently during a webinar we had to face two very interesting but unrelated topics about finance. The first one was about how to consider certificates as an asset class in a diversified portfolio, whereas the second topic revolved around current stock valuation on international markets and the role of emerging markets in portfoglio diversification.
On a second thought I can see there’s infact a relationship about these two topics (portfolio diversification) though they were treated as two different subjects during a two-session webinar. As my favorite analytics companion R supported me in plotting two awesome charts we used to highlight some useful insights in portfolio optimization.
The first topic was certificates and their role in portfolio diversification. As an example I chose to simulate the return distributions of two publicly listed X-Markets certificates (a Bonus certificate on ENEL – ISIN DE000DX5LAZ0 – and an Express certificate on BMW – ISIN DE000DE3WDD6 – hence the title of this article).
I wanted to show a comparison between a certificate and its underlying risk-return profile and after having collected all the necessary data (here) I imported them in R:
dat.z <- read.table(file = "zert.csv", header = TRUE, sep = ";", dec = ",")
head(dat.z)
## Val.Fin Bonus ENEL Express BMW
## 1 25 0.0001 0.0001 0.0003 0.0003
## 2 50 0.0331 0.0331 0.0620 0.0681
## 3 75 0.1964 0.1964 0.1208 0.2097
## 4 100 0.1153 0.2926 0.0000 0.2523
## 5 125 0.6551 0.2297 0.8169 0.1930
## 6 150 0.0000 0.1322 0.0000 0.1221
Some necessary packages are needed to accomodate the data.
library(ggplot2)
library(reshape2)
Now I had to melt the data in the columns with reshape2 package and reorder them using factor:
dat.z.m <- melt(dat.z, id = "Val.Fin")
dat.z.m$variable <- factor(dat.z.m$variable, levels = c("Bonus", "Express",
"ENEL", "BMW"))
head(dat.z.m)
## Val.Fin variable value
## 1 25 Bonus 0.0001
## 2 50 Bonus 0.0331
## 3 75 Bonus 0.1964
## 4 100 Bonus 0.1153
## 5 125 Bonus 0.6551
## 6 150 Bonus 0.0000
At last, charting with the awesome ggplot2 package (loaded before) the simulated distributions of returns making sure to trellis (or facet) for individual security/certificate:
pl.z <- ggplot(data = dat.z.m, aes(x = Val.Fin, y = value))
pl.z + geom_bar(stat = "identity") + facet_wrap(~variable)
and save my plot:
ggsave(file = "excert.png", width = 6, height = 6, dpi = 96)
My second, and unrelated, task was to show current valuations on stock markets. The procedure looks like the one I followed before, import and reorder (the data).
dat.st <- read.table(file = "stock_pe.csv", header = TRUE, sep = ";", dec = ",")
dat.st$EXCH <- factor(dat.st$EXCH, levels = c("NYSE", "LONDON", "FRANKFURT",
"MOSCOW", "HGKG", "SHANGHAI"))
head(dat.st)
## SECURITY Price PE DY CAP EXCH DATE
## 1 Rwe 28.26 469.2 0.21 17201 FRANKFURT 30/11/2013
## 2 Kabel 96.00 425.3 0.24 8494 FRANKFURT 30/11/2013
## 3 Kabel 96.00 425.3 0.24 8494 FRANKFURT 30/11/2013
## 4 WackerChemie 78.49 405.5 0.25 4018 FRANKFURT 30/11/2013
## 5 Healthcare 55.99 271.0 0.37 12040 NYSE 30/11/2013
## 6 AvalonbayComm 118.56 252.9 0.40 11383 NYSE 30/11/2013
tail(dat.st)
## SECURITY Price PE DY CAP EXCH DATE
## 1363 SwEnergyCo 38.86 NA NA 10426 NYSE 20/03/2013
## 1364 TheAesCorp 12.68 NA NA 7173 NYSE 20/03/2013
## 1365 WpxEnergy 16.46 NA NA 2552 NYSE 20/03/2013
## 1366 BatouSteel 4.89 NA NA 4763 SHANGHAI 20/03/2013
## 1367 CnCommuCons 4.76 NA NA 9750 SHANGHAI 20/03/2013
## 1368 Minimetals 15.02 NA NA 1929 SHANGHAI 20/03/2013
Again, ggplot2 with its ggplot command does all the heavy lifting.
box_plpe <- ggplot(data = dat.st, aes(DATE, PE))
box_plpe + geom_boxplot(outlier.colour = "green", outlier.size = 3) + scale_y_log10() +
facet_wrap(~EXCH) + geom_jitter(aes(size = CAP, color = DY)) + labs(title = "PE valuations | Cap weighted & DY | Data source: Sole 24 Ore")
Eventually, as always, saving my work with ggsave in three different file formats for different publications is as easy as can be in ggplot2.
ggsave(file = "pe_dy_eng_box_whisker.png", dpi = 96, height = 6, width = 12)
ggsave(file = "pe_dy_eng_box_whisker.pdf", dpi = 300, height = 6, width = 12)
ggsave(file = "pe_dy_eng_box_whisker.eps", dpi = 300, height = 6, width = 12)
Though market valuations haven’t changed much since March 20, 2013 (20/03/2013, on chart above), New York (NYSE), London and Frankfurt share the highest number (probably because of market depth and width in terms of listed stocks) of outliers in terms of PE ratio (in green on chart above) and have the lowest dividend yield (DY) among the six stock markets; whereas Moscow, Hong Kong and Shanghai stock markets trade at a somewhat lower valuation in terms of PE. Recent corrections in overall emerging stock markets surely account for a significant part of this lower valuation compared to developed markets. It seems to notice that emerging markets have offer lower diversification opportunities than developed ones.
Leave a Reply