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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 10 15:51:22 CEST 2013


Author: opentrades
Date: 2013-05-10 15:51:22 +0200 (Fri, 10 May 2013)
New Revision: 1465

Modified:
   pkg/quantstrat/R/ruleOrderProc.R
Log:
- ohlc stoplimit orders can no longer transact on price out of bar; now limited to Hi() or Lo() of bar



Modified: pkg/quantstrat/R/ruleOrderProc.R
===================================================================
--- pkg/quantstrat/R/ruleOrderProc.R	2013-05-08 20:43:14 UTC (rev 1464)
+++ pkg/quantstrat/R/ruleOrderProc.R	2013-05-10 13:51:22 UTC (rev 1465)
@@ -165,7 +165,7 @@
                                 if( (has.Lo(mktdata) && orderPrice > as.numeric(Lo(mktdataTimestamp))) || 
                                     (!has.Lo(mktdata) && orderPrice > as.numeric(getPrice(mktdataTimestamp, prefer=prefer))))
                                 {
-                                    txnprice = orderPrice
+                                    txnprice = min(orderPrice, Hi(mktdataTimestamp))
                                     txntime = timestamp
                                 } else next() # price did not move through my order, should go to next order  
                             } else if((orderQty < 0 && orderType != 'stoplimit') || (orderQty > 0 && (orderType=='stoplimit'))) { 
@@ -173,7 +173,7 @@
                                 if ( (has.Hi(mktdata) && orderPrice < as.numeric(Hi(mktdataTimestamp))) ||
                                      (!has.Hi(mktdata) && orderPrice < as.numeric(getPrice(mktdataTimestamp,prefer=prefer))) )
                                 {
-                                    txnprice = orderPrice
+                                    txnprice = max(orderPrice, Lo(mktdataTimestamp))
                                     txntime = timestamp
                                 } else next() # price did not move through my order, should go to next order 
                             } else {



More information about the Blotter-commits mailing list