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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Apr 20 14:10:27 CEST 2013


Author: bodanker
Date: 2013-04-20 14:10:27 +0200 (Sat, 20 Apr 2013)
New Revision: 1443

Modified:
   pkg/quantstrat/R/rules.R
Log:
- clean up stoptrailing code (s/stoplimit/stoptrailing in last commit)


Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2013-04-20 11:45:09 UTC (rev 1442)
+++ pkg/quantstrat/R/rules.R	2013-04-20 12:10:27 UTC (rev 1443)
@@ -460,8 +460,6 @@
                 trailorders <- which('stoptrailing'==ordersubset.oo.idx[,'Order.Type'])
                 for(torder in trailorders)
                 {
-                    firsttime<-NULL
-                    neworders<-NULL
                     onum<-oo.idx[torder]
                     orderThreshold <- as.numeric(ordersubset[onum,'Order.Threshold'])
                     tmpqty<-ordersubset[onum,'Order.Qty']
@@ -474,8 +472,7 @@
                     }
                     tmpqty<-as.numeric(tmpqty)
                     tmpprice<-as.numeric(ordersubset[onum,'Order.Price'])
-                    tmpidx <- format(index(ordersubset[onum,]), "%Y-%m-%d %H:%M:%OS6") #this is the time the order was entered
-                    #print(tmpidx)
+
                     if(isBBOmktdata) {
                         if(tmpqty > 0){ # positive quantity 'buy'
                             prefer='offer'
@@ -485,16 +482,15 @@
                     } else if (isOHLCmktdata) {
                         prefer='close'
                     } 
-                    dindex<-get.dindex()
-                    if(is.null(firsttime)) firsttime<-timestamp
 
+                    dindex<-get.dindex()
                     ddindex <- dindex[dindex>curIndex]
                     if(length(ddindex) == 0)
                         return(FALSE)
 
                     nextidx <- min(ddindex)
                     nextstamp <- format(index(mktdata[nextidx,]), "%Y-%m-%d %H:%M:%OS6")
-                    timespan <- paste(format(firsttime, "%Y-%m-%d %H:%M:%OS6"),"::",nextstamp,sep='')
+                    timespan <- paste(format(timestamp, "%Y-%m-%d %H:%M:%OS6"),"::",nextstamp,sep='')
 
                     #get the subset of prices
                     mkt_price_series <-getPrice(mktdata[timespan],prefer=prefer)[-1]  # don't look for crosses on curIndex
@@ -510,7 +506,7 @@
                     }
                     # check if order will be filled
                     cross <- sigThreshold(data=mkt_price_series, label='tmptrail',column=col,threshold=tmpprice,relationship=relationship)
-                    tmpidx<-NULL
+
                     # update dindex if order is moved or filled
                     if(any(move_order) || any(cross)){
                         moveidx <- curIndex + min(which(move_order)[1], which(cross)[1], na.rm=TRUE)



More information about the Blotter-commits mailing list