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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 21 21:45:21 CEST 2012


Author: bodanker
Date: 2012-06-21 21:45:21 +0200 (Thu, 21 Jun 2012)
New Revision: 1065

Modified:
   pkg/quantstrat/R/ruleOrderProc.R
Log:
- Only update ordersubset with cancelled orders if some are *actually* canceled


Modified: pkg/quantstrat/R/ruleOrderProc.R
===================================================================
--- pkg/quantstrat/R/ruleOrderProc.R	2012-06-21 15:42:25 UTC (rev 1064)
+++ pkg/quantstrat/R/ruleOrderProc.R	2012-06-21 19:45:21 UTC (rev 1065)
@@ -298,8 +298,11 @@
                     #close all other orders in the order set
                     OrdersetTag = toString(ordersubset[ii,"Order.Set"])
 		    OpenInOrderset.i = which(ordersubset[,"Order.Status"] == 'open' & ordersubset[,"Order.Set"] == OrdersetTag)
-                    ordersubset[OpenInOrderset.i, "Order.Status"] = 'canceled'
-                    ordersubset[OpenInOrderset.i, "Order.StatusTime"]<-as.character(timestamp)
+                    # skip this if there are no orders
+                    if(length(OpenInOrderset.i)>0) {
+                      ordersubset[OpenInOrderset.i, "Order.Status"] = 'canceled'
+                      ordersubset[OpenInOrderset.i, "Order.StatusTime"]<-as.character(timestamp)
+                    }
                 } 
             }
         } #end loop over open orders  



More information about the Blotter-commits mailing list