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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 3 20:35:56 CET 2012


Author: gsee
Date: 2012-02-03 20:35:56 +0100 (Fri, 03 Feb 2012)
New Revision: 920

Modified:
   pkg/FinancialInstrument/inst/parser/DJIA.index.R
Log:
yahoo webpage format chaged for DJIA components

Modified: pkg/FinancialInstrument/inst/parser/DJIA.index.R
===================================================================
--- pkg/FinancialInstrument/inst/parser/DJIA.index.R	2012-02-02 15:43:53 UTC (rev 919)
+++ pkg/FinancialInstrument/inst/parser/DJIA.index.R	2012-02-03 19:35:56 UTC (rev 920)
@@ -8,7 +8,7 @@
         stop("Please install the XML package before using this function.")
     }
     djicomp <- readHTMLTable('http://finance.yahoo.com/q/cp?s=^DJI+Components')
-    data.frame(djicomp[[10]])
+    data.frame(djicomp[[grep("Symbol", djicomp)]])
 }
 
 #' fetch the current divisor for the Dow Jones Industrial Average from Barrons
@@ -22,13 +22,13 @@
 }
 
 currency('USD')
-DJIA.members <- sapply(DJIcomponents()$Symbol, stock, currency="USD", member.of='DJIA')
+DJIA.members <- stock(DJIcomponents()$Symbol, currency="USD", member.of='DJIA')
 getSymbols(DJIA.members) # <-- getting data first is not required, but may be preferable
 synthetic.instrument("DJIA","USD", members=DJIA.members, memberratio=rep(1,length(DJIA.members)), 
                      multiplier=1/dow.divisor(), tick_size=0.01, description='Dow Jones Industrial Average')
 buildBasket('DJIA') #theoretical index
 tail(DJIA)
 
-getSymbols("^DJI") #acual index
+getSymbols("^DJI") #actual index
 tail(DJI)
 



More information about the Blotter-commits mailing list