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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 26 15:55:02 CEST 2012


Author: braverock
Date: 2012-03-26 15:55:02 +0200 (Mon, 26 Mar 2012)
New Revision: 989

Modified:
   pkg/quantstrat/R/rules.R
Log:
- fix typos in setting of tmpqty if no trade will occur but we still need to check for later price crosses, thanks Jan

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2012-03-25 20:29:29 UTC (rev 988)
+++ pkg/quantstrat/R/rules.R	2012-03-26 13:55:02 UTC (rev 989)
@@ -399,10 +399,10 @@
                         tmpqty <- ordersubset[oo.idx[slorder],'Order.Qty']
                         if (tmpqty=='all') tmpqty<-osNoOp(timestamp=timestamp, orderqty=tmpqty, portfolio=portfolio, symbol=symbol,ruletype='exit' )
                         if (tmpqty==0) {
-                            #no position, so do some slight of hand to figure out when the index may be needed
+                            #no position, so do some sleight of hand to figure out when the index may be needed
                             side <- ordersubset[oo.idx[slorder],'Order.Side']
-                            if(side=='long') tmpqty==-1
-                            else tmpqty==1
+                            if(side=='long') tmpqty=-1
+                            else tmpqty=1
                         }
                         tmpqty<-as.numeric(tmpqty)
                         tmpprice <- as.numeric(ordersubset[oo.idx[slorder],'Order.Price'])
@@ -439,8 +439,19 @@
 
                     for (lorder in limitorders){
                         dindex<-get.dindex()
-                        tmpqty<-as.numeric(ordersubset[oo.idx[lorder],'Order.Qty'])
+                        tmpqty<-ordersubset[oo.idx[lorder],'Order.Qty']
+                        if (tmpqty=='all') tmpqty<-osNoOp(timestamp=timestamp, orderqty=tmpqty, portfolio=portfolio, symbol=symbol,ruletype='exit' )
+#                        #don't think this block is needed for resular limit orders: BGP
+#                        if (tmpqty==0) {
+#                            #no position, so do some sleight of hand to figure out when the index may be needed
+#                            side <- ordersubset[oo.idx[lorder],'Order.Side']
+#                            if(side=='long') tmpqty=-1
+#                            else tmpqty=1
+#                        }
+                        tmpqty<-as.numeric(tmpqty)
+                        
                         tmpprice<-as.numeric(ordersubset[oo.idx[lorder],'Order.Price'])
+                        
                         if(tmpqty>0){
                             #buying
                             relationship="lte" #look for places where Mkt Ask <= our Bid
@@ -497,10 +508,10 @@
                         tmpqty<-ordersubset[onum,'Order.Qty']
                         if (tmpqty=='all') tmpqty<-osNoOp(timestamp=timestamp, orderqty=tmpqty, portfolio=portfolio, symbol=symbol,ruletype='exit' )
                         if (tmpqty==0) {
-                            #no position, so do some slight of hand to figure out when the index may be needed
+                            #no position, so do some sleight of hand to figure out when the index may be needed
                             side <- ordersubset[onum,'Order.Side']
-                            if(side=='long') tmpqty==-1
-                            else tmpqty==1
+                            if(side=='long') tmpqty=-1
+                            else tmpqty=1
                         }
                         tmpqty<-as.numeric(tmpqty)
                         tmpprice<-as.numeric(ordersubset[onum,'Order.Price'])



More information about the Blotter-commits mailing list