Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(data.table)
- library(fasttime)
- library(ggplot2)
- library(PerformanceAnalytics)
- library(xts)
- spy = fread("/path/to/unzipped/tsv")
- spy = spy[,date := as.POSIXct(strptime(date, format="%Y-%m-%d %H:%M:%S"), tz="UTC")]
- spy_xts = as.xts.data.table(spy)
- indexTZ(spy_xts) <- "America/New_York"
- spy_xts =rbind(spy_xts['T09:30/T09:31'], spy_xts['T10:09/T10:11'], spy_xts['T10:20/T10:21'])
- spy_xts$Returns = Return.calculate(spy_xts$close, method="discrete")
- spy_xts$Log_Returns = Return.calculate(spy_xts$close, method="log")
- rets = cbind(as.vector(spy_xts['T10:09/T10:11']$Log_Returns), as.vector(spy_xts['T10:20/T10:21']$Log_Returns))
- plot(rets)
- cor(rets)
- cor(rets, method="spearman")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement