[R-sig-Finance] get.hist.quote question
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Wed Jun 7 11:06:06 CEST 2006
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
>
More information about the R-SIG-Finance
mailing list