[Blotter-commits] r840 - pkg/quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 6 15:40:26 CET 2011
Author: gsee
Date: 2011-11-06 15:40:25 +0100 (Sun, 06 Nov 2011)
New Revision: 840
Modified:
pkg/quantstrat/R/orders.R
Log:
differentiate between limit and stoplimit
Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R 2011-11-06 13:36:50 UTC (rev 839)
+++ pkg/quantstrat/R/orders.R 2011-11-06 14:40:25 UTC (rev 840)
@@ -478,15 +478,17 @@
if( orderType == 'iceberg'){
stop("iceberg orders only supported for BBO data")
}
- # check to see if price moved through the limit
- if(orderQty < 0) { # negative quantity 'sell'
+ # check to see if price moved through the limit
+ if(orderQty > 0 || (orderQty < 0 && orderType == 'stoplimit') ) {
+ # buy limit, or sell stoplimit
if( (has.Lo(mktdata) && orderPrice > as.numeric(Lo(mktdataTimestamp))) ||
(!has.Lo(mktdata) && orderPrice >= as.numeric(getPrice(mktdataTimestamp, prefer=prefer))))
{
txnprice = orderPrice
txntime = timestamp
} else next() # price did not move through my order, should go to next order
- } else if(orderQty > 0) { # positive quantity 'buy'
+ } else if(orderQty < 0 || (orderQty > 0 && orderType == 'stoplimit')) {
+ # sell limit or buy stoplimit
if ( (has.Hi(mktdata) && orderPrice < as.numeric(Hi(mktdataTimestamp))) ||
(!has.Hi(mktdata) && orderPrice <= as.numeric(getPrice(mktdataTimestamp,prefer=prefer))) )
{
More information about the Blotter-commits
mailing list