[Blotter-commits] r1393 - pkg/quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Feb 12 17:37:51 CET 2013
Author: braverock
Date: 2013-02-12 17:37:51 +0100 (Tue, 12 Feb 2013)
New Revision: 1393
Modified:
pkg/quantstrat/R/rules.R
Log:
- fix stoptrailing where order just needs to be moved, but does not cross
- minor cleanup where lookups not needed
- patch kudos to Joseph Dunn
Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R 2013-02-10 22:22:31 UTC (rev 1392)
+++ pkg/quantstrat/R/rules.R 2013-02-12 16:37:51 UTC (rev 1393)
@@ -470,7 +470,6 @@
trailorders<-grep('^stoptrailing$', ordersubset[oo.idx,'Order.Type'])
for(torder in trailorders)
{
- dindex<-get.dindex()
firsttime<-NULL
neworders<-NULL
onum<-oo.idx[torder]
@@ -532,12 +531,10 @@
}
tmpidx<-NULL
if(any(move_order)){
- dindex<-get.dindex()
#print(firsttime)
# find first index where we would move an order
orderidx<-first(which(move_order))
- if(is.null(tmpidx))
- tmpidx <- format(index(move_order[orderidx,]), "%Y-%m-%d %H:%M:%OS6")
+ tmpidx <- format(index(move_order[orderidx,]), "%Y-%m-%d %H:%M:%OS6")
trailspan <- paste(format(firsttime, "%Y-%m-%d %H:%M:%OS6"),"::",tmpidx,sep='')
#make sure we don't cross before then
# use sigThreshold
@@ -550,7 +547,7 @@
assign.dindex(c(get.dindex(),newidx))
} else {
#if we don't cross, do this
- moveidx<-index(mktdata[index(move_order[orderidx,]),which.i=TRUE])
+ moveidx <- curIndex + orderidx - 1
assign.dindex(c(get.dindex(),moveidx))
}
} # end any(move_order) check
@@ -561,7 +558,6 @@
if(curIndex){
if(hasmktord) {
curIndex <- curIndex+1
- dindex<-get.dindex()
} else {
dindex<-get.dindex()
if (any(dindex > curIndex)) {
More information about the Blotter-commits
mailing list