If you have read my last blog post you will know that I have now ditched Yahoo Finance as my information source for UK shares because of the data quality problems. Instead I’m using Quandl. The Quandl website has a nice plotting facility but unfortunately only for a single share, making comparisons more difficult. This short R script allows you to obtain data from quandl (for as many securities as you want) and then do a quick comparison plot. You can change the frequency of plotting and the start date. Because it is specifically for comparison, the script discards rows of data where information is missing. Here is the script for ISF (ISH CORE FTSE100 ETF) and CUKX (ISH FTSE100 ACC ETF). If you ever needed an example of the power of reinvesting dividends, this has to be a good one!
library(Quandl) library(PerformanceAnalytics) tickers <- c("ISF", "CUKX") ## put as many securities as you want here mydata <- Quandl(paste0("LSE/", tickers, ".1"), type = "xts", api_key = "XXXXXX") mydata <- na.omit(mydata) colnames(mydata) <- tickers startdate <- "2010-01-01/" mydataused <- mydata[startdate] indx <- xts(apply(mydataused, 2, function(x) x/x), order.by = index(mydataused) ) indx2plt <- indx[endpoints(indx, on="months"),] # "days", “weeks”, “months”, “quarters” or “years” chart.TimeSeries(indx2plt, main = "Cumulative Returns", legend.loc = "topleft", minor.ticks = F, lwd = 2 )