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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 15 13:29:00 CEST 2013


Author: bodanker
Date: 2013-04-15 13:29:00 +0200 (Mon, 15 Apr 2013)
New Revision: 1433

Modified:
   pkg/quantstrat/R/rules.R
Log:
- another fix to chain rule execution logic


Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2013-04-14 21:53:14 UTC (rev 1432)
+++ pkg/quantstrat/R/rules.R	2013-04-15 11:29:00 UTC (rev 1433)
@@ -633,12 +633,11 @@
                             # determine which closed orders are chained to an entry
                             chain.rules <- strategy$rules[[type]]
                             chain.rule.names <- sapply(chain.rules, '[[', 'parent')
-                            closed.with.chain <- which(closed.orders$Rule %in% chain.rule.names)
                             # put rules/prices in same order
-                            rules <- chain.rules[closed.with.chain]
-                            chain.price <- closed.orders$Order.Price[closed.with.chain]
+                            rules <- chain.rules[match(closed.orders$Rule, chain.rule.names, nomatch=0L)]
+                            chain.price <- closed.orders$Order.Price[closed.orders$Rule %in% chain.rule.names]
                             # loop over each rule and call ruleProc()
-                            for(i in seq_along(closed.with.chain)) {
+                            for(i in seq_along(rules)) {
                                 # call ruleProc in a loop, since it doesn't look like chain.price would be subset correctly
                                 ruleProc(rules[i], timestamp=timestamp, path.dep=path.dep, mktdata=mktdata, portfolio=portfolio, symbol=symbol, ruletype=type, mktinstr=mktinstr, parameters=list(chain.price=as.numeric(chain.price[i]), ...))
                             }



More information about the Blotter-commits mailing list