I'm trying to use Brian Peterson's code to learn applications of MACD for our investment management situation, but have run into this error:
"Error in addTxn(Portfolio = portfolio, Symbol = symbol, TxnDate = txntime, : Transactions must be added in order. TxnDate (2007-01-03) is before last transaction in portfolio (2014-04-29) for AAPL"
I see here that this was a bug for which Josh Ulrich pushed a fix last May (2017), so why am I still getting it, especially when I am using posted code by a quantstrat
author?
I tried another fix Brian suggested here, but that didn't help.
The problem occurs with the applyStrategy
call (about line 109 in Brian's code):
out<-applyStrategy(strat.st , portfolios=portfolio.st,
parameters=list(nFast=fastMA, nSlow=slowMA,
nSig=signalMA,maType=maType),verbose=TRUE)
I realize quantstrat
is "still in heavy development", so maybe I've missed some recent development. Have I? I've searched for quite a while to no avail.
Also, as a side, but related question: why is it an error that 2007-01-03 "is before last transaction in portfolio (2014-04-29)" since the former actually is chronologically before the latter date? Am I right to assume that the error is prompted by quantstrat
's (actually, I guess it is blotter's) mistaken view that the former is LISTED after the latter in the object?