[Blotter-commits] r1635 - pkg/blotter/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 7 17:45:59 CEST 2014


Author: braverock
Date: 2014-10-07 17:45:59 +0200 (Tue, 07 Oct 2014)
New Revision: 1635

Modified:
   pkg/blotter/R/tradeStats.R
Log:
- check for div by zero error, patch suggested by Daniel Cegielka

Modified: pkg/blotter/R/tradeStats.R
===================================================================
--- pkg/blotter/R/tradeStats.R	2014-09-19 19:14:12 UTC (rev 1634)
+++ pkg/blotter/R/tradeStats.R	2014-10-07 15:45:59 UTC (rev 1635)
@@ -147,7 +147,7 @@
             
             GrossProfits <- sum(PL.gt0)
             GrossLosses  <- sum(PL.lt0)
-            ProfitFactor <- abs(GrossProfits/GrossLosses)
+            ProfitFactor <- ifelse(GrossLosses == 0, NA, abs(GrossProfits/GrossLosses))
             
             AvgTradePL <- mean(PL.ne0)
             MedTradePL <- median(PL.ne0)



More information about the Blotter-commits mailing list