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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 25 15:50:15 CEST 2013


Author: opentrades
Date: 2013-04-25 15:50:15 +0200 (Thu, 25 Apr 2013)
New Revision: 1450

Modified:
   pkg/quantstrat/R/rules.R
Log:
- chain orders now use transaction price instead of order price as price reference



Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2013-04-25 10:43:22 UTC (rev 1449)
+++ pkg/quantstrat/R/rules.R	2013-04-25 13:50:15 UTC (rev 1450)
@@ -598,7 +598,12 @@
                                 rules <- chain.rules[chain.rule.names %in% closed.chain$Rule[i]]
                                 for(j in seq_along(rules)) {
                                     # call ruleProc in a loop, since it doesn't look like chain.price would be subset correctly
-                                    ruleProc(rules[j], timestamp=timestamp, path.dep=path.dep, mktdata=mktdata, portfolio=portfolio, symbol=symbol, ruletype=type, mktinstr=mktinstr, parameters=list(chain.price=as.numeric(closed.chain$Order.Price[i]), ...))
+                                    
+                                    txns <- getTxns(Portfolio=portfolio, Symbol=symbol, Dates=timestamp)
+                                    txn.price <- last(txns$Txn.Price)	# last() because there may be more than one txn at this timestamp
+
+                                    #ruleProc(rules[j], timestamp=timestamp, path.dep=path.dep, mktdata=mktdata, portfolio=portfolio, symbol=symbol, ruletype=type, mktinstr=mktinstr, parameters=list(chain.price=as.numeric(closed.chain$Order.Price[i]), ...))
+                                    ruleProc(rules[j], timestamp=timestamp, path.dep=path.dep, mktdata=mktdata, portfolio=portfolio, symbol=symbol, ruletype=type, mktinstr=mktinstr, parameters=list(chain.price=txn.price))
                                 }
                             }
                         }



More information about the Blotter-commits mailing list