There is a central notion in Time Series Econometrics, cointegration. Loosely it refers to finding the long run equilibrium of two non-stationary series. As the most know non-stationary series examples comes from finance, cointegration is nowadays a tool for traders (not a common one though!). They use it as the theory behind pairs trading (aka Statistical Arbitrage).
In the following lines we use a simple pairs trading technique, studying the ratio of the two price evolution series. We use the New York versions of two of the greatest players in ATHEX, NBG and OTE.
stock <- "NBG"
stock1 <- "OTE"
start.date <- "2003-10-20"
end.date <- Sys.Date()
quote <- paste("http://ichart.finance.yahoo.com/table.csv?s=",
stock,
"&a=", substr(start.date,6,7),
"&b=", substr(start.date, 9, 10),
"&c=", substr(start.date, 1,4),
"&d=", substr(end.date,6,7),
"&e=", substr(end.date, 9, 10),
"&f=", substr(end.date, 1,4),
"&g=d&ignore=.csv", sep="")
quote1 <- paste("http://ichart.finance.yahoo.com/table.csv?s=",
stock1,
"&a=", substr(start.date,6,7),
"&b=", substr(start.date, 9, 10),
"&c=", substr(start.date, 1,4),
"&d=", substr(end.date,6,7),
"&e=", substr(end.date, 9, 10),
"&f=", substr(end.date, 1,4),
"&g=d&ignore=.csv", sep="")
dataNBG.l <- read.csv(quote, as.is=TRUE)
dataOTE.l <- read.csv(quote1, as.is=TRUE)
X2=dataOTE.l[order(dataOTE.l$Date),];Y2=dataNBG.l[order(dataNBG.l$Date),]
LinkedIn
Facebook
Youtube
Twitter