I've just started using get.hist.quote to download
returns on non-US stocks, and noticed that the period
downloaded is typically shorter than that shown as
available in the yahoo finance website.
e.g.
get.hist.quote("vow.f")
says
"time series starts 2005-08-17"
yet on the yahoo.finance website I can manually click
on historical prices back to 2000. I get similar
truncated results on other international markets.
I've tried setting the start farther back, that
doesn't help. Any tips on how to get more history?
I'm using windows, R2.21 and 2.30
Regards,
Andrew West
get.hist.quote question
4 messages · Andrew West, Michael Stegh, Martin Becker +1 more
Dear Andrew, after I read your mail, I tried downloading the quotes manually from the German Yahoo Finance webpage into the .csv format. The resulting file is truncated, too. I have tried this for several major German stocks and the files only inlcude the prices back to August 2005 (although the historical prices back to 2000 are available). In contrast the historical prices of the German Stock Market Index DAX are available till 1990 and the downloaded .csv file contains all of them. So it rather seems to be a problem of Yahoo and not of R. Regards, Michael Stegh
Hi,
I noticed this behavior of get.hist.quote (or rather finance.yahoo.com)
a while ago and wrote some "wrapper" for get.hist.quote (which also
makes get.hist.quote more quiet, which may be implemented in
get.hist.quote itself meanwhile).
Yahoo seems to return only a small amount of data for foreign time
series, so the wrapper shifts the time window and merges the parts of
the time series. The implementation is quick and dirty, but maybe it is
useful anyhow. I think it will only work for retclass="zoo", but
modification for other return classes should be possible.
Regards,
Martin Becker
--- Start Code ---
GetQuote <- function(instrument="vow.f",start,end,quiet=TRUE,...) {
HV<-NULL;
if (require(tseries)) {
if (missing(start))
start <- "1991-01-02"
if (missing(end))
end <- format(Sys.Date() - 1, "%Y-%m-%d")
if (quiet) {
zz <- file(".GetQuoteLog", open="wt")
sink(zz,type="message");
sink(zz);
}
numtries=0;notworked=TRUE;
while((numtries<5)&&(notworked)) {
tmpdata<-try(get.hist.quote(instrument=instrument,start=start,end=end,...));
notworked<-inherits(tmpdata,"try-error");
numtries<-numtries+1;
}
if (!notworked) {
HV<-tmpdata;
oldstart<-end;
while (start(HV)>as.Date(as.Date(start)+5)) {
numtries=0;notworked=TRUE;
while((numtries<5)&&(notworked)) {
tmpdata<-try(get.hist.quote(instrument=instrument,start=start,end=start(HV)-1),...);
notworked<-inherits(tmpdata,"try-error");
numtries<-numtries+1;
}
if (!notworked) HV<-c(HV,tmpdata);
newstart<-start(HV);
if (newstart<oldstart) oldstart<-newstart else break;
}
}
if (quiet) {
sink(type="message");
sink();
close(zz);
}
return(HV);
} else stop("Package tseries not installed!");
}
--- End Code ---
Andrew West wrote:
I've just started using get.hist.quote to download
returns on non-US stocks, and noticed that the period
downloaded is typically shorter than that shown as
available in the yahoo finance website.
e.g.
get.hist.quote("vow.f")
says
"time series starts 2005-08-17"
yet on the yahoo.finance website I can manually click
on historical prices back to 2000. I get similar
truncated results on other international markets.
I've tried setting the start farther back, that
doesn't help. Any tips on how to get more history?
I'm using windows, R2.21 and 2.30
Regards,
Andrew West
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance
On Wed, 07 Jun 2006 10:45:29 +0200 Martin Becker wrote:
Hi, I noticed this behavior of get.hist.quote (or rather finance.yahoo.com) a while ago and wrote some "wrapper" for get.hist.quote (which also makes get.hist.quote more quiet, which may be implemented in get.hist.quote itself meanwhile).
yes, it is. Z
Yahoo seems to return only a small amount of data for foreign time
series, so the wrapper shifts the time window and merges the parts of
the time series. The implementation is quick and dirty, but maybe it
is useful anyhow. I think it will only work for retclass="zoo", but
modification for other return classes should be possible.
Regards,
Martin Becker
--- Start Code ---
GetQuote <- function(instrument="vow.f",start,end,quiet=TRUE,...) {
HV<-NULL;
if (require(tseries)) {
if (missing(start))
start <- "1991-01-02"
if (missing(end))
end <- format(Sys.Date() - 1, "%Y-%m-%d")
if (quiet) {
zz <- file(".GetQuoteLog", open="wt")
sink(zz,type="message");
sink(zz);
}
numtries=0;notworked=TRUE;
while((numtries<5)&&(notworked)) {
tmpdata<-try(get.hist.quote
(instrument=instrument,start=start,end=end,...)); notworked<-inherits
(tmpdata,"try-error"); numtries<-numtries+1;
}
if (!notworked) {
HV<-tmpdata;
oldstart<-end;
while (start(HV)>as.Date(as.Date(start)+5)) {
numtries=0;notworked=TRUE;
while((numtries<5)&&(notworked)) {
tmpdata<-try(get.hist.quote
(instrument=instrument,start=start,end=start(HV)-1),...);
notworked<-inherits(tmpdata,"try-error"); numtries<-numtries+1;
}
if (!notworked) HV<-c(HV,tmpdata);
newstart<-start(HV);
if (newstart<oldstart) oldstart<-newstart else break;
}
}
if (quiet) {
sink(type="message");
sink();
close(zz);
}
return(HV);
} else stop("Package tseries not installed!");
}
--- End Code ---
Andrew West wrote:
I've just started using get.hist.quote to download
returns on non-US stocks, and noticed that the period
downloaded is typically shorter than that shown as
available in the yahoo finance website.
e.g.
get.hist.quote("vow.f")
says
"time series starts 2005-08-17"
yet on the yahoo.finance website I can manually click
on historical prices back to 2000. I get similar
truncated results on other international markets.
I've tried setting the start farther back, that
doesn't help. Any tips on how to get more history?
I'm using windows, R2.21 and 2.30
Regards,
Andrew West
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance