Skip to content

Instantly share code, notes, and snippets.

@timelyportfolio
Created November 22, 2011 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timelyportfolio/1387105 to your computer and use it in GitHub Desktop.
Save timelyportfolio/1387105 to your computer and use it in GitHub Desktop.
#look at distance from the 3 month minimum
#to compare the magical US Russell 2000
#to the world
require(quantmod)
tkrs <- c("^W2DOW","^RUT")
getSymbols(tkrs,from="1896-01-01",to=Sys.Date())
#merge the closing values
markets <- na.omit(merge(W2DOW[,4],RUT[,4]))
#this is ugly but it works
altitude <- function(x) x/min(x)-1
mins <- as.xts(apply(markets[(NROW(markets)-250):NROW(markets),1:2],
MARGIN=2,FUN=
altitude))
plot.zoo(mins,screens=1,
col=c("cadetblue4","darkolivegreen3"),
lwd=2,ylab="% from 250 day minimum",xlab=NA,
main="Russell 2000 and DJ World ex US
Distance from 250 Day Minimum")
legend("bottom",c("DJ World ex US","Russell 2000"),lty=1,lwd=2,
col=c("cadetblue4","darkolivegreen3"),horiz=TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment