I get the error message:
Error in do.call(paste("getSymbols.", symbol.source, sep = ""), list(Symbols = current.symbols, : object 'from' not found
when I run the following code from Quantitative Trading with R from Georgakopoulos:
library(quantstrat)
library(xts)
library(TTR)
library(FinancialInstrument)
library(quantmod)
library(blotter)
library(PerformanceAnalytics)
library(foreach)
# CHAPTER 7
# Backtesting with Quantstrat
#################
# Initial setup #
#################
# Suppresses warnings
options("getSymbols.warning4.0" = FALSE)
# Do some house cleaning
rm(list = ls(.blotter), envir = .blotter)
# Set the currency and the timezone
currency('USD')
Sys.setenv(TZ = "UTC")
# Define symbols of interest
symbols <- c("XLB", #SPDR Materials sector
"XLE", #SPDR Energy sector
"XLF", #SPDR Financial sector
"XLP", #SPDR Consumer staples sector
"XLI", #SPDR Industrial sector
"XLU", #SPDR Utilities sector
"XLV", #SPDR Healthcare sector
"XLK", #SPDR Tech sector
"XLY", #SPDR Consumer discretionary sector
"RWR", #SPDR Dow Jones REIT ETF
"EWJ", #iShares Japan
"EWG", #iShares Germany
"EWU", #iShares UK
"EWC", #iShares Canada
"EWY", #iShares South Korea
"EWA", #iShares Australia
"EWH", #iShares Hong Kong
"EWS", #iShares Singapore
"IYZ", #iShares U.S. Telecom
"EZU", #iShares MSCI EMU ETF
"IYR", #iShares U.S. Real Estate
"EWT", #iShares Taiwan
"EWZ", #iShares Brazil
"EFA", #iShares EAFE
"IGE", #iShares North American Natural Resources
"EPP", #iShares Pacific Ex Japan
"LQD", #iShares Investment Grade Corporate Bonds
"SHY", #iShares 1-3 year TBonds
"IEF", #iShares 3-7 year TBonds
"TLT" #iShares 20+ year Bonds)
# SPDR ETFs first, iShares ETFs afterwards
if(!"XLB" %in% ls()) {
# If data is not present, get it from yahoo
suppressMessages(getSymbols(symbols, from = from, to = to, src = "yahoo", adjust = TRUE))}
I have run this on two different machines. This exact code used to work on one. Now neither of them can run without producing this error. Thank you.
fromis a variable that's not defined in this example. Where is this value supposed to be coming from? - MrFlick