[Blotter-commits] r1232 - in pkg/FinancialInstrument: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Oct 28 23:07:43 CET 2012
Author: gsee
Date: 2012-10-28 23:07:42 +0100 (Sun, 28 Oct 2012)
New Revision: 1232
Modified:
pkg/FinancialInstrument/NEWS
pkg/FinancialInstrument/R/update_instruments.morningstar.R
Log:
the location of the relevant table on morningstar's webpage changed. update_instruments.ms has been updated to use the table with the most rows.
Modified: pkg/FinancialInstrument/NEWS
===================================================================
--- pkg/FinancialInstrument/NEWS 2012-10-26 21:07:53 UTC (rev 1231)
+++ pkg/FinancialInstrument/NEWS 2012-10-28 22:07:42 UTC (rev 1232)
@@ -13,6 +13,9 @@
o option_series.yahoo() checks the results of the call to
quantmod::getOptionChain() and only uses rows that contain the ticker Symbol
(sometimes in the off-hours, yahoo includes a bad row)
+ o update_instruments.morningstar is slightly more robust. It no longer
+ depends on the relevant table being the 4th on the page; instead it uses
+ the table with the most rows.
USER VISIBLE CHANGES
o minor updates to docs: typo fixes, updated seealso sections
Modified: pkg/FinancialInstrument/R/update_instruments.morningstar.R
===================================================================
--- pkg/FinancialInstrument/R/update_instruments.morningstar.R 2012-10-26 21:07:53 UTC (rev 1231)
+++ pkg/FinancialInstrument/R/update_instruments.morningstar.R 2012-10-28 22:07:42 UTC (rev 1232)
@@ -27,12 +27,15 @@
require(XML)
x <- readHTMLTable(paste("http://news.morningstar.com/etf/Lists/ETFReturn",
"s.html?topNum=All&lastRecNum=1000&curField=8&ca",
- "tegory=0", sep=""), stringsAsFactors=FALSE)[[4L]]
+ "tegory=0", sep=""), stringsAsFactors=FALSE)
+ x <- x[[which.max(sapply(x, nrow))]]
colnames(x) <- x[2, ]
x <- x[-c(1:3), -1]
x <- x[!is.na(x[, 1]), ]
x <- x[!duplicated(x[, 1]), ]
tickers <- gsub(".*\\(|*\\)", "", x[,1])
+ x <- x[tickers != "", ]
+ tickers <- tickers[tickers != ""]
rownames(x) <- tickers
if (missing(Symbols)) {
Symbols <- unique(c(ls_funds(), ls_stocks()))
More information about the Blotter-commits
mailing list