Skip to content

Instantly share code, notes, and snippets.

@1beb
Created May 28, 2011 20:32
Show Gist options
  • Save 1beb/997216 to your computer and use it in GitHub Desktop.
Save 1beb/997216 to your computer and use it in GitHub Desktop.
Milktrader Double Y VIX v. GSPC
require("quantmod")
getSymbols("^GSPC;^VIX")
VIX <- as.data.frame(unlist(VIX))
GSPC <- as.data.frame(unlist(GSPC))
y1 <- data.frame(Date=as.Date(row.names(VIX),"%Y-%m-%d"),"VIX"=VIX$VIX.Close)
row.names(y1) <- NULL
y2 <- data.frame(Date=as.Date(row.names(GSPC),"%Y-%m-%d"),"GSPC"=GSPC$GSPC.Close)
row.names(y2) <- NULL
plot(y1$Date, y1$VIX, type="l", col="blue", xlab="Time", ylab="Closing Price")
par(new=TRUE)
plot(y2$Date, y2$GSPC, type="l", ann=FALSE, yaxt="n")
axis(4)
legend(x="topleft", bty="n", lty=c(1,1), col=c("blue","black"), legend=c("VIX", "GSPC"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment