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