Search code examples
rquantmodyahoo-finance

In R Studio how would I pull a specific piece of data from Yahoo Finance


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?


Solution

  • 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.