I installed R package quantstrat and its depencies as in the following code, as answered in this link:
install.packages("devtools")
require(devtools)
install_github("braverock/FinancialInstrument")
install_github("joshuaulrich/xts")
install_github("braverock/blotter")
install_github("braverock/quantstrat")
install_github("braverock/PerformanceAnalytics")
When installing quantstrat package, I got the following output:
Note: no visible binding for '<<-' assignment to '.strategy'
Note: no visible binding for '<<-' assignment to 'hold'
I do not know actually what it means. However, it seems I am not being able to make any transactions.
if I run demo('bbands', ask=FALSE)
I get the following output:
Error in chart.Posn(Portfolio = "bbands", Symbol = stock.str) :
no transactions/positions to chart
Session info:
version R version 3.4.4 (2018-03-15)
system x86_64, linux-gnu
ui RStudio (1.1.453)
language (EN)
collate en_US.UTF-8
tz America/Cuiaba
date 2018-06-27
As well answered by @FXQuantTrader, I could ignore the notes. It was a problem with version 0.14.5 where the notes are not relevant. It is fixed in version 0.14.6 and works perfectly now.
source: https://github.com/braverock/quantstrat/issues/88
You can safely ignore the Notes on compiling (I get them too). They won't affect the code adversely in any meaningful way.
Your error:
Comes about because you have no transactions done in your backtest. So there are no positions to plot. If you had transactions, you wouldn't get this error.
Make sure that
startDate
is a value that is before the start of your market data. OtherwiseaddPosLimit
may not work as intended and trades don't get generated. (Also, maybe also set your timezone to "UTC" if working with data withDate
time indexes). The demo works for me and generates trades.