Skip to content

Instantly share code, notes, and snippets.

@null712
Last active August 29, 2015 14:04
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 null712/2e585239d02083441221 to your computer and use it in GitHub Desktop.
Save null712/2e585239d02083441221 to your computer and use it in GitHub Desktop.
dayi.trade = data[grep(data$date[i], data$date),]
dayi.buy = dayi.trade[grep(“BUY”, dayi.trade$action),]
dayi.sell = dayi.trade[grep(“SELL”, dayi.trade$action),]
trade.buy[i] = sum(dayi.buy$quant * dayi.buy$price)/sum(dayi.buy$quant)
trade.sell[i] = sum(dayi.sell$quant * dayi.sell$price)/sum(dayi.sell$quant)
trade.spread[i] = trade.buy[i] - trade.sell[i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment