[R] Downloading quote data from yahoo finance
Joshua Ulrich
josh.m.ulrich at gmail.com
Sat Dec 4 21:47:45 CET 2010
On Wed, Dec 1, 2010 at 11:15 PM, Deb Midya <debmidya at yahoo.com> wrote:
> Hi R users,
>
> Thanks in advance.
>
> I am using R 2.12.0 on Windows XP.
>
> May I request you to assist me in the following please.
>
> 1. I am getting error while downloading quote data from yahoo finance.
>
> The example code is below (taken from tseries help):
>
> library(tseries)
>
> con <- url("http://quote.yahoo.com")
> if(!inherits(try(open(con), silent = TRUE), "try-error")) {
> close(con)
> x <- get.hist.quote(instrument = "^gspc", start = "1998-01-01",
> quote = "Close")
> plot(x)
> x <- get.hist.quote(instrument = "ibm", quote = c("Cl", "Vol"))
> plot(x, main = "International Business Machines Corp")
> spc <- get.hist.quote(instrument = "^gspc", start = "1998-01-01",
> quote = "Close")
> ibm <- get.hist.quote(instrument = "ibm", start = "1998-01-01",
> quote = "AdjClose")
> x <- merge(spc, ibm)
> plot(x, main = "IBM vs S&P 500")
> x <- get.hist.quote(instrument = "EUR/USD", provider = "oanda",
> start = Sys.Date() - 500)
> plot(x, main = "EUR/USD")
> }
>
> Error message:
>
> Warning message:
> In open.connection(con) :
> unable to connect to 'quote.yahoo.com' on port 80.
>
The example works for me. Are you behind a firewall or proxy?
> 2. How can I download Key Statistics Data from Yahoo Finance
>
> A. http://finance.yahoo.com/
>
> B. ASH.AX (Using GET QUOTES)
>
> C. Key Statistics
>
> How can I download Key Statistics dynamically (Using R code)
>
library(quantmod)
getFinancials("IBM")
viewFinancials(IBM.f)
>
> Thank you very much for the time you have given.
>
> Regards,
>
> Deb
>
>
>
Hope that helps,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
More information about the R-help
mailing list