[Blotter-commits] r993 - pkg/quantstrat/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Mar 31 19:29:03 CEST 2012
Author: braverock
Date: 2012-03-31 19:29:03 +0200 (Sat, 31 Mar 2012)
New Revision: 993
Modified:
pkg/quantstrat/R/rules.R
Log:
- don't evaluate exit orders if you are flat and they are of type 'market'
Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R 2012-03-28 14:51:38 UTC (rev 992)
+++ pkg/quantstrat/R/rules.R 2012-03-31 17:29:03 UTC (rev 993)
@@ -640,8 +640,11 @@
rebalance =, exit = , enter = , entry = {
if(isTRUE(hold)) next()
if(type=='exit'){
- # must have a position for an exit rules to fire
- if (getPosQty(Portfolio=portfolio,Symbol=symbol,Date=timestamp)==0) next()
+ if(length(strategy$rules$exit)==length(grep('market',strategy$rules$exit))){
+ # all exit orders are of type 'market'
+ # so we must have a position for exit rules to fire / be evaluated
+ if (getPosQty(Portfolio=portfolio,Symbol=symbol,Date=timestamp)==0) next()
+ }
}
if(length(strategy$rules[[type]])>=1) {
ruleProc(strategy$rules[[type]],timestamp=timestamp, path.dep=path.dep, mktdata=mktdata,portfolio=portfolio, symbol=symbol, ruletype=type, mktinstr=mktinstr, ...)
More information about the Blotter-commits
mailing list