[Blotter-commits] r1414 - pkg/quantstrat/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 26 20:22:56 CET 2013


Author: opentrades
Date: 2013-03-26 20:22:56 +0100 (Tue, 26 Mar 2013)
New Revision: 1414

Modified:
   pkg/quantstrat/R/ruleSignal.R
Log:
- patch to suppress addOrder() call for exit/all rules in case there is no current pos anyway


Modified: pkg/quantstrat/R/ruleSignal.R
===================================================================
--- pkg/quantstrat/R/ruleSignal.R	2013-03-26 15:29:13 UTC (rev 1413)
+++ pkg/quantstrat/R/ruleSignal.R	2013-03-26 19:22:56 UTC (rev 1414)
@@ -205,23 +205,26 @@
 
         if(!is.null(orderqty) && orderqty!=0 && !is.null(orderprice)) #orderprice could have length > 1
         {
-            addOrder(portfolio=portfolio, 
-                     symbol=symbol, 
-                     timestamp=timestamp, 
-                     qty=orderqty, 
-                     price=as.numeric(orderprice), 
-                     ordertype=ordertype, 
-                     side=orderside, 
-                     orderset=orderset, 
-                     threshold=threshold, 
-                     status="open", 
-                     replace=replace , 
-                     delay=delay, 
-                     tmult=tmult, 
-                     ...=..., 
-                     prefer=prefer, 
-                     TxnFees=TxnFees,
-                     label=label)
+            if(orderqty != 'all' || getPosQty(portfolio, symbol, timestamp) != 0)
+            {
+                addOrder(portfolio=portfolio, 
+                         symbol=symbol, 
+                         timestamp=timestamp, 
+                         qty=orderqty, 
+                         price=as.numeric(orderprice), 
+                         ordertype=ordertype, 
+                         side=orderside, 
+                         orderset=orderset, 
+                         threshold=threshold, 
+                         status="open", 
+                         replace=replace , 
+                         delay=delay, 
+                         tmult=tmult, 
+                         ...=..., 
+                         prefer=prefer, 
+                         TxnFees=TxnFees,
+                         label=label)
+            }
         }
     }
     if(sethold) hold <<- TRUE



More information about the Blotter-commits mailing list