Ajay Shah
2004-Mar-03 09:55 UTC
[R] get.hist.quote - is great, but am I missing something?
I find it's just great to be able to say: library(tseries) x <- get.hist.quote(instrument="ongc.ns") and it gets a full time-series of the stock price of the symbol ongc.ns from Yahoo quote. However, once my hopes have been raised by such beauty :-) I get disappointed when I do> plot(x)and the annotation is horrible! The x axis is not labelled as dates. The default plot method for get.hist.quote should be better, no? I was not able to understand the object returned by get.hist.quote. If I say:> summary(x)Open High Low Close Min. : 397.0 Min. : 407.3 Min. :395.1 Min. :398.4 1st Qu.: 494.2 1st Qu.: 501.4 1st Qu.:482.7 1st Qu.:490.4 Median : 614.9 Median : 622.7 Median :600.7 Median :610.0 Mean : 615.6 Mean : 627.1 Mean :599.7 Mean :611.9 3rd Qu.: 690.5 3rd Qu.: 707.4 3rd Qu.:676.2 3rd Qu.:691.5 Max. :1000.0 Max. :1000.0 Max. :930.0 Max. :944.9 NA's : 88.0 NA's : 88.0 NA's : 88.0 NA's : 88.0 there is no mention of a 'time' variable. And, I'm unable to extract (say) a vector of closing prices - e.g. if I say:> closingprices <- x$Close > print(closingprices)NULL I guess I'm not understanding the object that get.hist.quote makes. In general, what are R facilities for discovering what a given object is? -- Ajay Shah Consultant ajayshah at mayin.org Department of Economic Affairs http://www.mayin.org/ajayshah Ministry of Finance, New Delhi
Heywood, Giles
2004-Mar-03 10:37 UTC
[R] get.hist.quote - is great, but am I missing something?
If you use priceIts() in package 'its' (Irregular Time Series), you get similar functionality, and the labelling etc in plot() recognizes the calendar. You can also do further calendar-based extractions, etc. - Giles> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Ajay Shah > Sent: 03 March 2004 09:55 > To: r-help > Subject: [R] get.hist.quote - is great, but am I missing something? > > > I find it's just great to be able to say: > > library(tseries) > x <- get.hist.quote(instrument="ongc.ns") > > and it gets a full time-series of the stock price of the symbol > ongc.ns from Yahoo quote. > > However, once my hopes have been raised by such beauty :-) I get > disappointed when I do > > > plot(x) > > and the annotation is horrible! The x axis is not labelled as > dates. The default plot method for get.hist.quote should be better, > no? > > I was not able to understand the object returned by get.hist.quote. If > I say: > > > summary(x) > Open High Low Close > Min. : 397.0 Min. : 407.3 Min. :395.1 Min. :398.4 > 1st Qu.: 494.2 1st Qu.: 501.4 1st Qu.:482.7 1st Qu.:490.4 > Median : 614.9 Median : 622.7 Median :600.7 Median :610.0 > Mean : 615.6 Mean : 627.1 Mean :599.7 Mean :611.9 > 3rd Qu.: 690.5 3rd Qu.: 707.4 3rd Qu.:676.2 3rd Qu.:691.5 > Max. :1000.0 Max. :1000.0 Max. :930.0 Max. :944.9 > NA's : 88.0 NA's : 88.0 NA's : 88.0 NA's : 88.0 > > there is no mention of a 'time' variable. And, I'm unable to extract > (say) a vector of closing prices - e.g. if I say: > > > closingprices <- x$Close > > print(closingprices) > NULL > > I guess I'm not understanding the object that get.hist.quote makes. In > general, what are R facilities for discovering what a given object is? > > -- > Ajay Shah Consultant > ajayshah at mayin.org Department of Economic Affairs > http://www.mayin.org/ajayshah Ministry of Finance, New Delhi > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >********************************************************************** This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}
Gabor Grothendieck
2004-Mar-03 12:45 UTC
[R] get.hist.quote - is great, but am I missing something?
Here are a number of options: plotOHLC(x) # in tseries package or require(chron) x <- get.hist.quote( your.symbol, origin = chron(0) ) tt <- chron( time( x ) ) plot(tt, x[,"Close"]) or # using tt and x just calculated require(zoo) plot(zoo(x,tt)) or see Giles' post on his its package --- Date: Wed, 3 Mar 2004 15:25:14 +0530 From: Ajay Shah <ajayshah at mayin.org> To: r-help <r-help at stat.math.ethz.ch> Subject: [R] get.hist.quote - is great, but am I missing something? I find it's just great to be able to say: library(tseries) x <- get.hist.quote(instrument="ongc.ns") and it gets a full time-series of the stock price of the symbol ongc.ns from Yahoo quote. However, once my hopes have been raised by such beauty :-) I get disappointed when I do> plot(x)and the annotation is horrible! The x axis is not labelled as dates. The default plot method for get.hist.quote should be better, no? I was not able to understand the object returned by get.hist.quote. If I say:> summary(x)Open High Low Close Min. : 397.0 Min. : 407.3 Min. :395.1 Min. :398.4 1st Qu.: 494.2 1st Qu.: 501.4 1st Qu.:482.7 1st Qu.:490.4 Median : 614.9 Median : 622.7 Median :600.7 Median :610.0 Mean : 615.6 Mean : 627.1 Mean :599.7 Mean :611.9 3rd Qu.: 690.5 3rd Qu.: 707.4 3rd Qu.:676.2 3rd Qu.:691.5 Max. :1000.0 Max. :1000.0 Max. :930.0 Max. :944.9 NA's : 88.0 NA's : 88.0 NA's : 88.0 NA's : 88.0 there is no mention of a 'time' variable. And, I'm unable to extract (say) a vector of closing prices - e.g. if I say:> closingprices <- x$Close > print(closingprices)NULL I guess I'm not understanding the object that get.hist.quote makes. In general, what are R facilities for discovering what a given object is? -- Ajay Shah Consultant ajayshah at mayin.org Department of Economic Affairs http://www.mayin.org/ajayshah Ministry of Finance, New Delhi
Dirk Eddelbuettel
2004-Mar-03 16:02 UTC
[R] get.hist.quote - is great, but am I missing something?
On Wed, Mar 03, 2004 at 03:25:14PM +0530, Ajay Shah wrote:> I find it's just great to be able to say: > > library(tseries) > x <- get.hist.quote(instrument="ongc.ns") > > and it gets a full time-series of the stock price of the symbol > ongc.ns from Yahoo quote. > > However, once my hopes have been raised by such beauty :-) I get > disappointed when I do > > > plot(x)a) use plotOHLC(x), not plot(), PlotOHLC is also in tseries. b) install the its package which has a variant of get.hist.quote and plots that too (though it doesn;t skip weekends)> and the annotation is horrible! The x axis is not labelled as > dates. The default plot method for get.hist.quote should be better, > no?So are you intending to contribute one?> I was not able to understand the object returned by get.hist.quote. If > I say: > > > summary(x) > Open High Low Close > Min. : 397.0 Min. : 407.3 Min. :395.1 Min. :398.4 > 1st Qu.: 494.2 1st Qu.: 501.4 1st Qu.:482.7 1st Qu.:490.4 > Median : 614.9 Median : 622.7 Median :600.7 Median :610.0 > Mean : 615.6 Mean : 627.1 Mean :599.7 Mean :611.9 > 3rd Qu.: 690.5 3rd Qu.: 707.4 3rd Qu.:676.2 3rd Qu.:691.5 > Max. :1000.0 Max. :1000.0 Max. :930.0 Max. :944.9 > NA's : 88.0 NA's : 88.0 NA's : 88.0 NA's : 88.0 > > there is no mention of a 'time' variable. And, I'm unable to extract > (say) a vector of closing prices - e.g. if I say: > > > closingprices <- x$Close > > print(closingprices) > NULL > > I guess I'm not understanding the object that get.hist.quote makes. In > general, what are R facilities for discovering what a given object is?class(x) str(x) ... Hth, Dirk -- The relationship between the computed price and reality is as yet unknown. -- From the pac(8) manual page
Heywood, Giles
2004-Mar-03 17:27 UTC
[R] get.hist.quote - is great, but am I missing something?
If you wish to 'skip' (i.e. not interpolate) weekends in its, you could use the following: prices <- priceIts(instrument="ongc.ns") plot(union(prices,newIts(start=start(prices),end=end(prices))),interp="none" ) - Giles> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Dirk > Eddelbuettel > Sent: 03 March 2004 16:02 > To: Ajay Shah > Cc: r-help > Subject: Re: [R] get.hist.quote - is great, but am I missing > something? > > > On Wed, Mar 03, 2004 at 03:25:14PM +0530, Ajay Shah wrote: > > I find it's just great to be able to say: > > > > library(tseries) > > x <- get.hist.quote(instrument="ongc.ns") > > > > and it gets a full time-series of the stock price of the symbol > > ongc.ns from Yahoo quote. > > > > However, once my hopes have been raised by such beauty :-) I get > > disappointed when I do > > > > > plot(x) > > a) use plotOHLC(x), not plot(), PlotOHLC is also in tseries. > > b) install the its package which has a variant of get.hist.quote > and plots that too (though it doesn;t skip weekends) > > > and the annotation is horrible! The x axis is not labelled as > > dates. The default plot method for get.hist.quote should be better, > > no? > > So are you intending to contribute one? > > > I was not able to understand the object returned by > get.hist.quote. If > > I say: > > > > > summary(x) > > Open High Low Close > > Min. : 397.0 Min. : 407.3 Min. :395.1 Min. :398.4 > > 1st Qu.: 494.2 1st Qu.: 501.4 1st Qu.:482.7 1st Qu.:490.4 > > Median : 614.9 Median : 622.7 Median :600.7 Median :610.0 > > Mean : 615.6 Mean : 627.1 Mean :599.7 Mean :611.9 > > 3rd Qu.: 690.5 3rd Qu.: 707.4 3rd Qu.:676.2 3rd Qu.:691.5 > > Max. :1000.0 Max. :1000.0 Max. :930.0 Max. :944.9 > > NA's : 88.0 NA's : 88.0 NA's : 88.0 NA's : 88.0 > > > > there is no mention of a 'time' variable. And, I'm unable to extract > > (say) a vector of closing prices - e.g. if I say: > > > > > closingprices <- x$Close > > > print(closingprices) > > NULL > > > > I guess I'm not understanding the object that > get.hist.quote makes. In > > general, what are R facilities for discovering what a given > object is? > > class(x) > str(x) > ... > > Hth, Dirk > > -- > The relationship between the computed price and reality is as > yet unknown. > -- From the > pac(8) manual page > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html ********************************************************************** This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}
Adrian Trapletti
2004-Mar-03 18:49 UTC
[R] get.hist.quote - is great, but am I missing something?
> > I find it's just great to be able to say: > > library(tseries) > x <- get.hist.quote(instrument="ongc.ns") > > and it gets a full time-series of the stock price of the symbol > ongc.ns from Yahoo quote. > > However, once my hopes have been raised by such beauty I get > disappointed when I do > >>> plot(x) > > > and the annotation is horrible! The x axis is not labelled as > dates. The default plot method for get.hist.quote should be better, > no?It depends what you want to do. But it all behaves as it is documented. Since the object returned by get.hist.quote is a multivariate time series (class "mts") plot.mts is called. As documented, the times are given in Julian dates since 1899-12-30. Therefore the "horrible" annotation. If you would like a more user-friendly plot, try plotOHLC(x).> > I was not able to understand the object returned by get.hist.quote. If > I say: > >>> summary(x) > > Open High Low Close > Min. : 397.0 Min. : 407.3 Min. :395.1 Min. :398.4 > 1st Qu.: 494.2 1st Qu.: 501.4 1st Qu.:482.7 1st Qu.:490.4 > Median : 614.9 Median : 622.7 Median :600.7 Median :610.0 > Mean : 615.6 Mean : 627.1 Mean :599.7 Mean :611.9 > 3rd Qu.: 690.5 3rd Qu.: 707.4 3rd Qu.:676.2 3rd Qu.:691.5 > Max. :1000.0 Max. :1000.0 Max. :930.0 Max. :944.9 > NA's : 88.0 NA's : 88.0 NA's : 88.0 NA's : 88.0 > > there is no mention of a 'time' variable. And, I'm unable to extract > (say) a vector of closing prices - e.g. if I say: > >>> closingprices <- x$Close >>> print(closingprices) > > NULL > > I guess I'm not understanding the object that get.hist.quote makes. In > general, what are R facilities for discovering what a given object is?I suggest, you study first one of the beginners manuals of the R environment: http://cran.r-project.org/manuals.html Then you would easily see that, e.g., x[,"Close"] gives you the series of closing prices, time(x) gives you the series of times and so on...> > -- > Ajay Shah Consultant > ajayshah at mayin.org Department of Economic Affairs > http://www.mayin.org/ajayshah Ministry of Finance, New Delhi > >best Adrian -- Dr. Adrian Trapletti Trapletti Statistical Computing Wildsbergstrasse 31, 8610 Uster Switzerland Phone & Fax : +41 (0) 1 994 5631 Mobile : +41 (0) 76 370 5631 Email : mailto:a.trapletti at bluewin.ch WWW : http://trapletti.homelinux.com