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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 21 19:41:00 CET 2013


Author: opentrades
Date: 2013-02-21 19:40:59 +0100 (Thu, 21 Feb 2013)
New Revision: 1401

Modified:
   pkg/quantstrat/R/rules.R
Log:
- bug fix by Joseph Dunn to execute order at next bar if a new order was opened



Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2013-02-21 10:30:53 UTC (rev 1400)
+++ pkg/quantstrat/R/rules.R	2013-02-21 18:40:59 UTC (rev 1401)
@@ -647,15 +647,13 @@
                     exit = , enter = {
                         if(isTRUE(hold)) next()
 
+                        if(isTRUE(path.dep)) openOrdersLen <- length(getOrders(portfolio=portfolio, symbol=symbol, status="open", timespan=timestamp,which.i=TRUE))
+
                         if(length(strategy$rules[[type]])>=1) {
                             ruleProc(strategy$rules[[type]],timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol, ruletype=type, mktinstr=mktinstr, parameters=parameters, ...)
                         }
-                        if(isTRUE(path.dep) && length(getOrders(portfolio=portfolio, symbol=symbol, status="open", timespan=timestamp,which.i=TRUE))) {
-                            ## TODO FIXME this doesn't appear to work correctly
-                            # we opened orders in this timestamp, make sure to increment dindex w/ curIndex+1 so the order slot gets checked next index ?
-                            #browser()
-                            #assign.dindex(c(get.dindex(),curIndex+1))
-                            #
+                        if(isTRUE(path.dep) && length(getOrders(portfolio=portfolio, symbol=symbol, status="open", timespan=timestamp,which.i=TRUE)) != openOrdersLen) {
+                            assign.dindex(c(get.dindex(),curIndex+1))
                         }
                     },
                     post = {



More information about the Blotter-commits mailing list