MFH: r377828

- Upstream rerolled tarball
  * Updated DESCRIPTION file
- Update the patch to make fetchable more than 50 records because
  web page layout was changed in January 2015
This commit is contained in:
Antoine Brodin 2015-03-05 22:45:16 +00:00
parent 3ac0e319d7
commit 1fe71c1f46
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/branches/2015Q1/; revision=380563
3 changed files with 68 additions and 13 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= RFinanceYJ
PORTVERSION= 0.3.1
PORTREVISION= 5
PORTREVISION= 6
CATEGORIES= finance
DISTNAME= ${PORTNAME}_${PORTVERSION}

View File

@ -1,2 +1,2 @@
SHA256 (RFinanceYJ_0.3.1.tar.gz) = b8fc8b7e6dcf0683b84df985749f6ebe2674f2761f3c64c9532a387965c7c0a9
SIZE (RFinanceYJ_0.3.1.tar.gz) = 3719
SHA256 (RFinanceYJ_0.3.1.tar.gz) = a33eeb02a919490bdaa3b2c7721c03a122f8a5d2574f39d90757b00399fe1562
SIZE (RFinanceYJ_0.3.1.tar.gz) = 3635

View File

@ -1,15 +1,70 @@
--- R/quoteStockTsData.R.orig 2013-08-13 00:05:58.000000000 +0900
+++ R/quoteStockTsData.R 2014-05-25 10:58:31.000000000 +0900
@@ -57,10 +57,10 @@
extractQuoteTable <- function(r,type){
if(type %in% c("fund","fx")){
+++ R/quoteStockTsData.R 2015-01-24 20:34:35.000000000 +0900
@@ -46,42 +46,33 @@
#get time series data from Yahoo! Finance.
quoteTsData <- function(x,function.financialproduct,since,start.num,date.end,time.interval,type="stock"){
r <- NULL
- result.num <- 51
financial.data <- data.frame(NULL)
- #start <- (gsub("([0-9]{4,4})-([0-9]{2,2})-([0-9]{2,2})","&c=\\1&a=\\2&b=\\3",since))
- #end <- (gsub("([0-9]{4,4})-([0-9]{2,2})-([0-9]{2,2})","&f=\\1&d=\\2&e=\\3",date.end))
start <- (gsub("([0-9]{4,4})-([0-9]{2,2})-([0-9]{2,2})","&sy=\\1&sm=\\2&sd=\\3",since))
end <- (gsub("([0-9]{4,4})-([0-9]{2,2})-([0-9]{2,2})","&ey=\\1&em=\\2&ed=\\3",date.end))
if(!any(time.interval==c('d','w','m'))) stop("Invalid time.interval value")
-
- extractQuoteTable <- function(r,type){
- if(type %in% c("fund","fx")){
- tbl <- r[[2]][[2]][[7]][[3]][[3]][[9]][[2]]
+ tbl <- r[[2]][[2]][[7]][[3]][[3]][[8]][[2]]
}
else{
- }
- else{
- tbl <- r[[2]][[2]][[7]][[3]][[3]][[10]][[2]]
+ tbl <- r[[2]][[2]][[7]][[3]][[3]][[11]][[2]]
- }
- return(tbl)
- }
-
- while( result.num >= 51 ){
+ while( 1 ){
start.num <- start.num + 1
quote.table <- NULL
quote.url <- paste('http://info.finance.yahoo.co.jp/history/?code=',x,start,end,'&p=',start.num,'&tm=',substr(time.interval,1,1),sep="")
- try( r <- xmlRoot(htmlTreeParse(quote.url,error=xmlErrorCumulator(immediate=F))), TRUE)
+ try( r <- htmlParse(quote.url) )
if( is.null(r) ) stop(paste("Can not access :", quote.url))
- #try( quote.table <- r[[2]][[1]][[1]][[16]][[1]][[1]][[1]][[4]][[1]][[1]][[1]], TRUE )
- try( quote.table <- extractQuoteTable(r,type), TRUE )
+ try( quote.table <- xpathApply(r,"//table")[[2]], TRUE )
+
+ quote.size <- xmlSize(quote.table)
+
+ if( xmlSize(quote.table) <= 1 ){
+ return(financial.data)
+ }
if( is.null(quote.table) ){
if( is.null(financial.data) ){
stop(paste("Can not quote :", x))
}else{
- financial.data <- financial.data[order(financial.data$date),]
- return(financial.data)
+ financial.data <- financial.data[order(financial.data$date),]
+ return(financial.data)
}
}
return(tbl)
@@ -90,7 +81,6 @@
financial.data <- rbind(financial.data,function.financialproduct(quote.table[[i]]))
}
- result.num <- xmlSize(quote.table)
Sys.sleep(1)
}
financial.data <- financial.data[order(financial.data$date),]
@@ -120,5 +110,3 @@
return(startOfNextMonth-1)
}
-
-