Skip to content

How to add expense ratio to the list of fields we can source from yahoo #335

Closed
@Courvoisier13

Description

@Courvoisier13

Description

For a fund or ETF, SPY for example:
I would like to add the Expense Ratio (net) (under Summary) or Annual Report Expense Ratio (net) (under profile) to the list of fields that can be scraped. Using my best guess and looking at the html, I added

"Expense Ratio (net)", "Expense Ratio (net)", "annualReportExpenseRatio"

to the end of the variable .yahooQuoteFields in the file getQuote.R. After building the package and try it out, unfortunately I get the following error:

Error in `[.data.frame`(sq, , "regularMarketTime") : 
  undefined columns selected
Called from: `[.data.frame`(sq, , "regularMarketTime"

Is it possible to get some help on rules for .yahooQuoteFields and is it possible to add new fields to extract new info?

Expected behavior

I expect to get the expense ratio for a fund, SPY for example.

Minimal, reproducible example

syms <- "SPY"
what_metrics <- yahooQF(c("Name", "Expense Ratio (net)"))
getQuote(syms, what=what_metrics)

Session Info

R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] quantmod_0.4.18.1 TTR_0.24.2        xts_0.12.1        zoo_1.8-9        

loaded via a namespace (and not attached):
[1] compiler_4.0.5  tools_4.0.5     yaml_2.2.1      curl_4.3.1      grid_4.0.5      jsonlite_1.7.2  lattice_0.20-41 fortunes_1.5-4 

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions