[Blotter-commits] r1633 - pkg/quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Sep 18 23:17:11 CEST 2014
Author: bodanker
Date: 2014-09-18 23:17:10 +0200 (Thu, 18 Sep 2014)
New Revision: 1633
Modified:
pkg/quantstrat/R/ruleOrderProc.R
Log:
- Fix bug #5895 (Stoplimit execution with OHLC price gaps)
Thanks to Claymore Marshall for the report and for testing.
Modified: pkg/quantstrat/R/ruleOrderProc.R
===================================================================
--- pkg/quantstrat/R/ruleOrderProc.R 2014-09-16 14:00:04 UTC (rev 1632)
+++ pkg/quantstrat/R/ruleOrderProc.R 2014-09-18 21:17:10 UTC (rev 1633)
@@ -196,7 +196,10 @@
if( (has.Lo(mktdata) && orderPrice > as.numeric(Lo(mktdataTimestamp)[,1])) ||
(!has.Lo(mktdata) && orderPrice > as.numeric(getPrice(mktdataTimestamp, prefer=prefer)[,1])))
{
- txnprice = min(orderPrice, Hi(mktdataTimestamp)[,1])
+ if(orderType == 'stoplimit')
+ txnprice <- min(orderPrice, Op(mktdataTimestamp)[,1])
+ else
+ txnprice <- orderPrice
txntime = timestamp
} else next() # price did not move through my order, should go to next order
} else if((orderQty < 0 && orderType != 'stoplimit') || (orderQty > 0 && (orderType=='stoplimit'))) {
@@ -204,7 +207,10 @@
if ( (has.Hi(mktdata) && orderPrice < as.numeric(Hi(mktdataTimestamp)[,1])) ||
(!has.Hi(mktdata) && orderPrice < as.numeric(getPrice(mktdataTimestamp,prefer=prefer)[,1])) )
{
- txnprice = max(orderPrice, Lo(mktdataTimestamp)[,1])
+ if(orderType == 'stoplimit')
+ txnprice <- max(orderPrice, Op(mktdataTimestamp)[,1])
+ else
+ txnprice <- orderPrice
txntime = timestamp
} else next() # price did not move through my order, should go to next order
} else {
More information about the Blotter-commits
mailing list