I've been going through Guy's quantstrat lecture (link below) and after repeatedly attempting to re-execute the code, I'm getting a few initial errors that are preventing most of the subsequent code in the lecture from functioning.
Here is the code (copied from the lecture with very minor re-arrangements):
rm(list=ls(all=TRUE)) #added this to delete memory
library(quantstrat)
library(blotter) #added this hoping it would rectify the errors
library(FinancialInstrument) #added this hoping it would rectify the errors
# initialize portfolio, accounts and orders
qs.strategy <- "qsFaber"
initPortf(qs.strategy, 'SPY', initDate = '1997-12-31')
initAcct(qs.strategy, portfolios = qs.strategy, initDate = '1997-12-31', initEq= 1e6)
Here are the errors I am getting:
1)
> initPortf(qs.strategy, 'SPY', initDate = '1997-12-31')
Error in exists(paste("portfolio", name, sep = "."), envir = .blotter, :
object '.blotter' not found
2)
> initAcct(qs.strategy, portfolios = qs.strategy, initDate = '1997-12-31', initEq= 1e6)
Error in exists(paste("account", name, sep = "."), envir = .blotter, inherits = TRUE) :
object '.blotter' not found
I had to directly download blotter as I am using Windows 64 bit, but despite copying the code from the lecture, I am unsure why I am getting those errors. My search efforts have indicated that a portion of blotter evolved into the FinancialInstrument package, but even after clearing memory and loading FinancialInstruments I am still getting the same error.
Any help would be highly appreciated.
LINK to lecture: http://www.r-programming.org/files/quantstrat-I.pdf
The sheets by Guy Yollin are excellent learning material, but unfortunately they are somewhat outdated (2011). Many changes have been made to blotter, quantstrat and other packages over the last 2 years, and much of the code in Guy's sheets will no longer run as such.
As far as the quantstrat package is concerned, you may want to take a look at the sheets from the R/Finance 2013 conference in Chicago; you can get a copy at http://www.rinfinance.com/agenda/2013/workshop/Humme+Peterson.pdf.
UPDATE: Guy Yollin has updated his slides to the latest quantstrat as of August 2013, they are available here http://www.r-programming.org/papers