From a2b528c41ece76874e464fdabe6f678e70699048 Mon Sep 17 00:00:00 2001 From: Jasen Mackie Date: Mon, 15 Apr 2019 15:05:05 +0000 Subject: [PATCH] curIndex should be set to first.index and not 1 In the applyRules function, when evaluating rules we should reference first.index as opposed to the 1st timestamp. This fix is required for any strategy in which rule.subset is used, such as walk.forward. This is a material change in the behavior, so bumping version and updating 'Date'. See #90 --- DESCRIPTION | 4 ++-- R/rules.R | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5c3e457..b767458 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: quantstrat Type: Package Title: Quantitative Strategy Model Framework -Version: 0.15.4 -Date: 2019-04-12 $Date$ +Version: 0.15.5 +Date: 2019-04-15 $Date$ Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jasen Mackie, Jan Humme Depends: R(>= 3.2), diff --git a/R/rules.R b/R/rules.R index ed1e512..178d034 100644 --- a/R/rules.R +++ b/R/rules.R @@ -538,7 +538,7 @@ applyRules <- function(portfolio, hold=FALSE holdtill=first(time(Dates))-1 # TODO FIXME make holdtill default more robust? mktinstr<-getInstrument(symbol) - curIndex<-1 + curIndex<-first.index if(nrow(mktdata)>1) freq <- periodicity(mktdata) # run once and pass to ruleOrderProc else {