PW
May 24, 2015
Historical stock index data can provide useful context for both personal and public policy questions. For example:
Through the European Index Portfolio app created using Shiny, you can perform your own customized analysis of four European markets: Germany (DAX), Switzerland (SMI), France (CAC) and the UK (FTSE).
The app allows a user to:
Since the market data set is represented in business days, the app must implement an approximated weekend adjustment to enable usage of the calendar inputs to subset the time series.
getPerfWindow <- function(beginDate, endDate) {
yrB <- year(beginDate)
numWeeksB <- trunc(yday(beginDate)/7)
bizDaysB <- yday(beginDate)-numWeeksB*2
yrE <- year(endDate)
numWeeksE <- trunc(yday(endDate)/7)
bizDaysE <- yday(endDate)-numWeeksE*2
outTS <- window(EuStockMarkets, start = c(yrB,bizDaysB), end = c(yrE,bizDaysE))
return(outTS)
}
Based on user input, the application will produce summary statistics on the returns and volatility of the selected indices, as well as the combined portfolio. For example, take a portfolio including all 4 indices from June 17, 1994 to April 5, 1996:
kable(getPerfStats(getPerfWindow('1994-06-17','1996-04-05')))
| DAX | SMI | CAC | FTSE | Total Portfolio | |
|---|---|---|---|---|---|
| Cumulative Returns (%) | 19.97 | 33.16 | 3.94 | 23.28 | 20.09 |
| Average Daily Returns (%) | 0.04 | 0.06 | 0.01 | 0.04 | 0.04 |
| Standard Deviation of Daily Returns (%) | 0.89 | 0.80 | 1.05 | 0.68 | 0.72 |
| Avg. Daily Returns / Std. Dev | 0.04 | 0.08 | 0.01 | 0.07 | 0.05 |
Plot of selected index performance over sample period
Plot of cumulative portfolio returns, given specified size (e.g. here 25,000)