[Blotter-commits] r1276 - pkg/blotter/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Dec 10 01:50:30 CET 2012
Author: opentrades
Date: 2012-12-10 01:50:30 +0100 (Mon, 10 Dec 2012)
New Revision: 1276
Modified:
pkg/blotter/R/tradeStats.R
Log:
prevent apply.daily() from crashing on portfolio with no completed txns
Modified: pkg/blotter/R/tradeStats.R
===================================================================
--- pkg/blotter/R/tradeStats.R 2012-12-09 18:06:17 UTC (rev 1275)
+++ pkg/blotter/R/tradeStats.R 2012-12-10 00:50:30 UTC (rev 1276)
@@ -117,6 +117,12 @@
PL.lt0 <- txn$Net.Txn.Realized.PL[txn$Net.Txn.Realized.PL < 0]
PL.ne0 <- txn$Net.Txn.Realized.PL[txn$Net.Txn.Realized.PL != 0]
+ if(length(PL.ne0) == 0)
+ {
+ # apply.daily will crash
+ next
+ }
+
DailyPL <- apply.daily(PL.ne0,sum)
AvgDailyPL <- mean(DailyPL)
MedDailyPL <- median(DailyPL)
More information about the Blotter-commits
mailing list