[Blotter-commits] r1163 - pkg/quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Sep 6 21:51:23 CEST 2012
Author: opentrades
Date: 2012-09-06 21:51:23 +0200 (Thu, 06 Sep 2012)
New Revision: 1163
Modified:
pkg/quantstrat/R/ruleOrderProc.R
Log:
fixed bug where trailing stoplimit order could survive orderset cancelation;
neworders are now directly attached to ordersubset to prevent replaced trailing order
from hiding in neworders "out of scope"
Modified: pkg/quantstrat/R/ruleOrderProc.R
===================================================================
--- pkg/quantstrat/R/ruleOrderProc.R 2012-09-06 17:19:02 UTC (rev 1162)
+++ pkg/quantstrat/R/ruleOrderProc.R 2012-09-06 19:51:23 UTC (rev 1163)
@@ -69,7 +69,6 @@
timestamp <- time(last(mktdata[timespan]))
#switch on frequency
freq = periodicity(mktdata)
- neworders<-NULL
mktdataTimestamp <- mktdata[timestamp]
#str(mktdataTimestamp)
# Should we only keep the last observation per time stamp?
@@ -214,7 +213,9 @@
status="open",
replace=FALSE, return=TRUE,
,...=..., TxnFees=txnfees)
- if (is.null(neworders)) neworders=neworder else neworders = rbind(neworders,neworder)
+
+ ordersubset<-rbind(ordersubset, neworder)
+
ordersubset[ii,"Order.Status"]<-'replaced'
ordersubset[ii,"Order.StatusTime"]<-format(timestamp, "%Y-%m-%d %H:%M:%S")
next()
@@ -274,7 +275,9 @@
status="open",
replace=FALSE, return=TRUE,
,...=..., TxnFees=txnfees)
- if (is.null(neworders)) neworders=neworder else neworders = rbind(neworders,neworder)
+
+ ordersubset<-rbind(ordersubset, neworder)
+
ordersubset[ii,"Order.Status"]<-'replaced'
ordersubset[ii,"Order.StatusTime"]<-format(timestamp, "%Y-%m-%d %H:%M:%S")
next()
@@ -325,7 +328,7 @@
label=ordersubset[ii,"Rule"],
,...=..., TxnFees=txnfees)
- if (is.null(neworders)) neworders=neworder else neworders = rbind(neworders,neworder)
+ ordersubset<-rbind(ordersubset, neworder)
ordersubset[ii,"Order.Status"]<-'replaced'
ordersubset[ii,"Order.StatusTime"]<-format(timestamp, "%Y-%m-%d %H:%M:%S")
@@ -364,11 +367,11 @@
{
ordersubset[OpenInOrderset.i, "Order.Status"] = 'canceled'
ordersubset[OpenInOrderset.i, "Order.StatusTime"]<-format(timestamp, "%Y-%m-%d %H:%M:%S")
+
}
}
} #end loop over open orders
- if(!is.null(neworders)) ordersubset=rbind(ordersubset,neworders)
-
+
# now put the orders back in
# assign order book back into place (do we need a non-exported "put" function?)
orderbook[[portfolio]][[symbol]] <- ordersubset
More information about the Blotter-commits
mailing list