0

In R studio I am currently using the package quantmod to pull yahoo finance data. I found quantmod because someone recommended on: How to scrape key statistics from Yahoo! Finance with R? in place of scraping. I am trying to pull Book value per share (BVPS) data.

This could be directly with

library(quantmod)

getQuote("AAPL",what=yahooQF(c("Book Value Per Share")))

it throws this ERROR: Error in `[.data.frame`(sq, , "regularMarketTime") : undefined columns selected

I could alternatively calculate it myself if I could pull book value and preferred stock but

getQuote("AAPL",what=yahooQF(c("Book Value")))

throws the same error. So I am at a lose of what to do. Are these errors with quantmod or should I just be learning how to pull from the website myself and not using quantmod?

Shadowhawk
  • 319
  • 1
  • 3
  • 9

1 Answers1

1

You can try this.

If you try to call Book Value with an additional value, it is working. However, when you call only Book Value, the function is giving an error. You can post this bug to the package provider's GitHub. Here is the link

The following producer might work for you for now.


getQuote("AAPL",what=yahooQF(c("Open","Book Value")))

>
              Trade Time   Open Book Value
AAPL 2021-04-30 16:00:04 131.78      4.146

I just requested additional Open price information. With that, API worked.

mustafaakben
  • 501
  • 2
  • 5
  • That is very curious! As I left out my other value out so not to keep it clean. ```getQuote("AAPL",what=yahooQF(c("Open","Book Value")))``` Does work for me but now what was work yesterday is not, sigh. Below is what was working, but now the "Earnings/Share" is throwing the error. I wonder if it is something to do with the markets being open or closed? ```getQuote("AAPL",what=yahooQF(c("Earnings/Share","Book Value")))``` The funny thing is git hub sent me help first, because I didn't want to report and issue that was me just being bad at programming. Thank you. – Shadowhawk May 01 '21 at 14:05
  • I think I figured it out! I added "open" to what was misbehaving and it worked. I think it needs a time stamp to pull from or it wont work. – Shadowhawk May 01 '21 at 14:09
  • Glad to hear that! I think it is a bug or something. Because when you call for another single value, you can get them. For example, `getQuote("AAPL",what=yahooQF(c('Ask'))) ` works. Anyhow, if my answer helped you, you can accept my answer. – mustafaakben May 01 '21 at 14:24
  • You are probably correct. I will try to figure out a concise why to post the issue on git hub. – Shadowhawk May 01 '21 at 14:29