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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jun 12 00:17:21 CEST 2011


Author: braverock
Date: 2011-06-12 00:17:21 +0200 (Sun, 12 Jun 2011)
New Revision: 626

Modified:
   pkg/quantstrat/R/traderules.R
Log:
- fix bid/ask confusion, thanks to Garrett for spotting
- fix confusion between mktdata/data, likely not an issue, but clearer now

Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R	2011-06-11 17:42:13 UTC (rev 625)
+++ pkg/quantstrat/R/traderules.R	2011-06-11 22:17:21 UTC (rev 626)
@@ -62,18 +62,18 @@
                 market = ,
 				opside = ,
 				active = {
-                    if(is.BBO(mktdata)){
+                    if(is.BBO(data)){
                         if (orderqty>0) 
-                            prefer='bid'  # we're buying, so work the bid price
+                            prefer='ask'  # we're buying, so pay what they're asking
                         else
-                            prefer='ask'  # we're selling, so work the ask price  
+                            prefer='bid'  # we're selling, so give it to them for what they're bidding  
                     } 
 					orderprice <- try(getPrice(x=data, prefer=prefer))[timestamp] 
 				},
 				passive =,
 				work =,
 				join = {
-					if(is.BBO(mktdata)){
+					if(is.BBO(data)){
 						if (orderqty>0) 
 							prefer='bid'  # we're buying, so work the bid price
 						else
@@ -139,7 +139,7 @@
         
         ## now size the order
         #TODO add fancy formals matching for osFUN
-        orderqty <- osFUN(strategy=strategy, data=mktdata, timestamp=timestamp, orderqty=orderqty, ordertype=ordertype, orderside=orderside, portfolio=portfolio, symbol=symbol,...=...,ruletype=ruletype, orderprice=as.numeric(orderprice))
+        orderqty <- osFUN(strategy=strategy, data=data, timestamp=timestamp, orderqty=orderqty, ordertype=ordertype, orderside=orderside, portfolio=portfolio, symbol=symbol,...=...,ruletype=ruletype, orderprice=as.numeric(orderprice))
         
         
         if(!is.null(orderqty) && !orderqty == 0 && !is.null(orderprice)){ #orderqty could have length > 1



More information about the Blotter-commits mailing list