Created
May 28, 2011 20:32
-
-
Save 1beb/997216 to your computer and use it in GitHub Desktop.
Milktrader Double Y VIX v. GSPC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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