[R-SIG-Finance] Indexing package: update existant database
varcovar
varcovar at live.com
Tue Mar 27 16:31:19 CEST 2012
Hello,
I am not able to update data that I created with the indexing package. Below
is the code I used to create the index. It works well when I try to retrieve
data, but then I have no idea how to update the index.
library(indexing)
library(quantmod)
# Get data and create index
getSymbols("AAPL", from = "2010-01-01", to = "2012-03-20")
Date <- as.numeric(format(index(AAPL), "%Y%m%d"))
Close <- as.numeric(Cl(AAPL))
create_index(Date)
create_index(Close)
# Get data update
getSymbols("AAPL", from = "2012-03-20", to = Sys.Date())
Date <- as.numeric(format(index(AAPL), "%Y%m%d"))
Close <- as.numeric(Cl(AAPL))
# Load index
db <- load_index("Date", double())
load_index("Close", double())
# Test
db[Date > 20120310, data.frame(Date, Close)]
# Try to get a subset of data and update the file on disk
temp <- db[Date > 20120310, data.frame(Date, Close)]
Date <- c(temp$Date, Date)
Close <- c(temp$Close, Close)
# Not working:
create_index(Date)
# Error in create_index(Date) :
# data already exists. Remove disk structure or use 'load_index'
Any idea? Many thanks!
Markus Douglas, Jr.
--
View this message in context: http://r.789695.n4.nabble.com/Indexing-package-update-existant-database-tp4508992p4508992.html
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list