Skip to content

Instantly share code, notes, and snippets.

@null712
Created July 16, 2014 19:00
Show Gist options
  • Save null712/eb1f4feafde202075ec0 to your computer and use it in GitHub Desktop.
Save null712/eb1f4feafde202075ec0 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