[Blotter-commits] r1170 - pkg/blotter/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Sep 9 18:19:27 CEST 2012
Author: braverock
Date: 2012-09-09 18:19:26 +0200 (Sun, 09 Sep 2012)
New Revision: 1170
Modified:
pkg/blotter/R/chart.ME.R
Log:
- fix PctPL calcs to do each trade individually instead of the aggregate
Modified: pkg/blotter/R/chart.ME.R
===================================================================
--- pkg/blotter/R/chart.ME.R 2012-09-08 20:24:16 UTC (rev 1169)
+++ pkg/blotter/R/chart.ME.R 2012-09-09 16:19:26 UTC (rev 1170)
@@ -144,20 +144,19 @@
# investment
trades$Max.Notional.Cost[i] <- first(trade[which(abs(trade$Pos.Qty)==max(abs(trade$Pos.Qty))),]$Pos.Cost.Basis)
+ # percentage-wise
trade$PctPL <- trade$PosPL/trade$Pos.Value #broken for last trade
trade$PctPL[length(trade$Pct.PL)]<-last(trade$PosPL)/trades$Max.Notional.Cost
+ trades$Pct.Net.Trading.PL[i] <- last(trade$PctPL)
+ trades$Pct.MAE[i] <- min(0,trade$PctPL)
+ trades$Pct.MFE[i] <- max(0,trade$PctPL)
# cash-wise
trades$Net.Trading.PL[i] <- last(trade$PosPL)
trades$MAE[i] <- min(0,trade$PosPL)
trades$MFE[i] <- max(0,trade$PosPL)
}
-
- # percentage-wise
- trades$Pct.Net.Trading.PL <- last(trade$PctPL)
- trades$Pct.MAE <- min(0,trade$PctPL)
- trades$Pct.MFE <- max(0,trade$PctPL)
#TODO add tick stats
More information about the Blotter-commits
mailing list