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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 8 20:15:55 CET 2011


Author: braverock
Date: 2011-03-08 20:15:54 +0100 (Tue, 08 Mar 2011)
New Revision: 568

Modified:
   pkg/quantstrat/R/orders.R
Log:
- normalize pricing behavior of 'limit' txnPrice calc to match stoplimit/stoptrailing and execute at prevailing price.

Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2011-03-08 18:57:47 UTC (rev 567)
+++ pkg/quantstrat/R/orders.R	2011-03-08 19:15:54 UTC (rev 568)
@@ -467,14 +467,17 @@
                             # check side/qty
                             if(orderQty > 0){ # positive quantity 'buy'
                                 if(orderPrice >= as.numeric(getPrice(mktdataTimestamp,prefer='offer'))){
-                                    # price we're willing to pay is higher than the offer price, so execute at the limit
+                                    # price we're willing to pay is higher than the offer price, so execute at the prevailing price
+                                    #txnprice = orderPrice
+                                    txnprice = as.numeric(getPrice(mktdataTimestamp,prefer=prefer)) #presumes unique timestamps
                                     txnprice = orderPrice
                                     txntime = timestamp
                                 } else next()
                             } else { # negative quantity 'sell'
                                 if(orderPrice <= as.numeric(getPrice(mktdataTimestamp,prefer='bid'))){
-                                    # we're willing to sell at a better price than the bid, so execute at the limit
-                                    txnprice = orderPrice
+                                    # we're willing to sell at a better price than the bid, so execute at the prevailing price
+                                    # txnprice = orderPrice
+                                    txnprice = as.numeric(getPrice(mktdataTimestamp,prefer=prefer)) #presumes unique timestamp
                                     txntime = timestamp
                                 } else next()
                             }



More information about the Blotter-commits mailing list