Sparks, John James
2011-Mar-18 03:48 UTC
[R] quantmod Some Single Letter Tickers Not getFin
Hi,
I have been learning the quantmod package over the last several days. I
went to check some of my data pulls against other sources and was
surprised to find that a few tickers that have single characters do not
successfully scrape from Google Finance using getFin(). Particularly
require(quantmod)
getFin("A")
getFin("E")
getFin("F")
getFin("G")
getFin("M")
all result in a file not found error. I show the last one below.
> getFin("M")
Error in download.file(paste(google.fin, Symbol, sep = ""), quiet =
TRUE, :
cannot open URL 'http://finance.google.com/finance?fstype=ii&q=M'
In addition: Warning message:
In download.file(paste(google.fin, Symbol, sep = ""), quiet = TRUE, :
cannot open: HTTP status was '400 Bad Request'
I checked out the financial statement pages for all of these and they
exist and are as expected: 5 quarters worth of quarterly figures (except
for cash-flow which has 4 quarters) and 4 years of annual figures. All
the rows are also present by comparing a scrape to excel with the figures
for "Y", which does getFin("Y") without a problem.
I was hoping that someone who knows a lot more about scraping then I do
could look into this.
Best wishes to all,
--John Sparks
Hi John,
The financial statement pages exist, but they require the exchange to
be specified. For example:
http://www.google.com/finance?fstype=ii&q=NYSE:GE
and
http://www.google.com/finance?fstype=ii&q=GE
take you to the same page, but
http://www.google.com/finance?fstype=ii&q=NYSE:F
works, while
http://www.google.com/finance?fstype=ii&q=F
results in a 400 'Bad request' error.
This seems to work for this one symbol, maybe it will work for others as well.
getFin("NYSE:F")
Best,
--
Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com
On Thu, Mar 17, 2011 at 10:48 PM, Sparks, John James <jspark4 at uic.edu>
wrote:> Hi,
>
> I have been learning the quantmod package over the last several days. ?I
> went to check some of my data pulls against other sources and was
> surprised to find that a few tickers that have single characters do not
> successfully scrape from Google Finance using getFin(). ?Particularly
>
> require(quantmod)
> getFin("A")
> getFin("E")
> getFin("F")
> getFin("G")
> getFin("M")
>
> all result in a file not found error. ?I show the last one below.
>
>> getFin("M")
> Error in download.file(paste(google.fin, Symbol, sep = ""), quiet
= TRUE, ?:
> ?cannot open URL
'http://finance.google.com/finance?fstype=ii&q=M'
> In addition: Warning message:
> In download.file(paste(google.fin, Symbol, sep = ""), quiet =
TRUE, ?:
> ?cannot open: HTTP status was '400 Bad Request'
>
>
> I checked out the financial statement pages for all of these and they
> exist and are as expected: ?5 quarters worth of quarterly figures (except
> for cash-flow which has 4 quarters) and 4 years of annual figures. ?All
> the rows are also present by comparing a scrape to excel with the figures
> for "Y", which does getFin("Y") without a problem.
>
> I was hoping that someone who knows a lot more about scraping then I do
> could look into this.
>
> Best wishes to all,
> --John Sparks
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>