Skip to content

Instantly share code, notes, and snippets.

@milktrader
Created March 24, 2011 03:21
Show Gist options
  • Save milktrader/884497 to your computer and use it in GitHub Desktop.
Save milktrader/884497 to your computer and use it in GitHub Desktop.
compare close with close n days ago
delta_farce <- function(sym="SPY", expiry=22, pct=.03){
require("quantmod")
ticker <- getSymbols(sym, auto.assign=FALSE)
ticker <- ticker[,4]
win <- 0
for(i in expiry:NROW(ticker))
if(as.numeric(ticker[i]) > as.numeric(ticker[i-(expiry-1)]))
win <- win + 1
winners <- win/(NROW(ticker)-expiry)
return(winners)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment