Instantly share code, notes, and snippets.

@null712 /spread
Last active Aug 29, 2015

Embed
What would you like to do?
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