[Blotter-commits] r1535 - pkg/blotter/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Oct 17 19:35:54 CEST 2013
Author: bodanker
Date: 2013-10-17 19:35:53 +0200 (Thu, 17 Oct 2013)
New Revision: 1535
Modified:
pkg/blotter/R/perTradeStats.R
Log:
- Fix trade start/end identification (based on qty, not value)
Modified: pkg/blotter/R/perTradeStats.R
===================================================================
--- pkg/blotter/R/perTradeStats.R 2013-10-17 14:25:16 UTC (rev 1534)
+++ pkg/blotter/R/perTradeStats.R 2013-10-17 17:35:53 UTC (rev 1535)
@@ -56,8 +56,8 @@
trades <- list()
# identify start and end for each trade, where end means flat position
- trades$Start <- index(posPL[which(posPL$Pos.Value!=0 & lag(posPL$Pos.Value)==0),])
- trades$End <- index(posPL[which(posPL$Pos.Value==0 & lag(posPL$Pos.Value)!=0),])
+ trades$Start <- index(posPL[which(posPL$Pos.Qty!=0 & lag(posPL$Pos.Qty)==0),])
+ trades$End <- index(posPL[which(posPL$Pos.Qty==0 & lag(posPL$Pos.Qty)!=0),])
# if the last trade is still open, adjust depending on whether wants open trades or not
if(length(trades$Start)>length(trades$End))
More information about the Blotter-commits
mailing list