[Blotter-commits] r1227 - pkg/FinancialInstrument/inst/parser

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Oct 21 02:33:38 CEST 2012


Author: peter_carl
Date: 2012-10-21 02:33:38 +0200 (Sun, 21 Oct 2012)
New Revision: 1227

Modified:
   pkg/FinancialInstrument/inst/parser/download.NAREIT.R
Log:
- fixed parsing issue with stringsAsFactors
- renamed symbol to indicate monthly data


Modified: pkg/FinancialInstrument/inst/parser/download.NAREIT.R
===================================================================
--- pkg/FinancialInstrument/inst/parser/download.NAREIT.R	2012-10-21 00:31:49 UTC (rev 1226)
+++ pkg/FinancialInstrument/inst/parser/download.NAREIT.R	2012-10-21 00:33:38 UTC (rev 1227)
@@ -19,11 +19,11 @@
 if (!file.exists(filesroot))
   dir.create(filesroot, mode="0777")
   
-if (!file.exists(paste(filesroot, "/NAREIT.IDX", sep="")))
-  dir.create(paste(filesroot, "/NAREIT.IDX", sep=""), mode="0777")
+if (!file.exists(paste(filesroot, "/NAREIT.M.IDX", sep="")))
+  dir.create(paste(filesroot, "/NAREIT.M.IDX", sep=""), mode="0777")
   
 # Download the first sheet in the xls workbook directly from the web site:
-x = read.xls("http://returns.reit.com/returns/MonthlyHistoricalReturns.xls", pattern="Date", sheet="Data")
+x = read.xls("http://returns.reit.com/returns/MonthlyHistoricalReturns.xls", pattern="Date", sheet="Index Data", stringsAsFactors=FALSE)
 
 # We'll focus on the first three columns, the date, the total return, and the total return index.  The next columns divide it into price, income and dividend yield components, and after that are the individual sectors.
 # @TODO: create symbols for the rest of the columns in the spreadsheet
@@ -33,17 +33,17 @@
 x.price = xts(x.price, order.by = x.dates)
 
 x.xts = cbind(x.price, x.returns)
-colnames(x.xts) = c("Close", "Returns")
+colnames(x.xts) = c("NAREIT.M.IDX.Close", "NAREIT.M.IDX.Returns")
 
 # Save it into an rda file on the filesystem
-save(x.xts, file=paste(filesroot,"NAREIT.IDX/NAREIT.IDX.rda", sep="/"))
+save(x.xts, file=paste(filesroot,"NAREIT.M.IDX/NAREIT.M.IDX.rda", sep="/"))
 
 # Create currencies first:
 require(FinancialInstrument)
 currency("USD")
 
 # Describe the metadata for the index
-instrument("NAREIT.IDX", currency="USD", multiplier=1, tick_size=.01, start_date="1971-12-31", description="FTSE NAREIT U.S. Real Estate Index", data="CR", source="reit.com", assign_i=TRUE)
+instrument("NAREIT.M.IDX", currency="USD", multiplier=1, tick_size=.01, start_date="1971-12-31", description="FTSE NAREIT U.S. Real Estate Index", data="CR", source="reit.com", assign_i=TRUE)
 
 # Now, whenever you log in you need to register the instruments.  This
 # might be a line you put into .Rprofile so that it happens automatically:
@@ -51,6 +51,6 @@
 setSymbolLookup.FI(base_dir=filesroot, split_method='common')
 
 # Now you should be able to:
-getSymbols("NAREIT.IDX")
-chartSeries(Cl(NAREIT.IDX), theme="white")
-head(NAREIT.IDX)
+getSymbols("NAREIT.M.IDX")
+chartSeries(Cl(NAREIT.M.IDX), theme="white")
+head(NAREIT.M.IDX)



More information about the Blotter-commits mailing list