user8270077
user8270077

Reputation: 5071

How to use getFin in quantmod in R to download financial

I am trying to download company financials using the quantmod function getFin.

Here is the relevant part from the quantmod documentation:

enter image description here enter image description here

However, when I run the same command I get an error message:

getFin('AAPL')  # or getFinancials('AAPL')

Error in thead[x]:thead[x + 1]: NA/NaN argument
Traceback:

1. getFin("AAPL")
2. lapply(seq(1, 11, 2), function(x) Symbol[thead[x]:thead[x + 1]])
3. FUN(X[[i]], ...)

When using package finreportr I also get an error message:

library(finreportr)
GetIncome('FB', 2015)
Error in mutate_impl(.data, dots): Evaluation error: `as_dictionary()` is defunct as of rlang 0.3.0.
Please use `as_data_pronoun()` instead.
Traceback:

1. GetIncome("FB", 2015)
2. GetFinancial(income.descriptions, symbol, year)
3. GetURL(symbol, year)
4. GetAccessionNo(symbol, year, foreign = FALSE)
5. mutate(reports.df, filing.year = substr(reports.df$filing.date, 
 .     1, 4)) %>% filter(filing.year == year.char) %>% filter(filing.name == 
 .     "10-K" | filing.name == "20-F")
6. eval(lhs, parent, parent)
7. eval(lhs, parent, parent)
8. mutate(reports.df, filing.year = substr(reports.df$filing.date, 
 .     1, 4))
9. mutate.data.frame(reports.df, filing.year = substr(reports.df$filing.date, 
 .     1, 4))
10. as.data.frame(mutate(tbl_df(.data), ...))
11. mutate(tbl_df(.data), ...)
12. mutate.tbl_df(tbl_df(.data), ...)
13. mutate_impl(.data, dots)

Upvotes: 1

Views: 1532

Answers (1)

phiver
phiver

Reputation: 23608

The getFin function is not working anymore. See quantmod version 0.4-15

getFin("AAPL")    

Error: ‘getFinancials.google’ is defunct.
Google Finance stopped providing data in March, 2018.
You could try some of the data sources via Quandl instead.
See help("Defunct") and help("quantmod-defunct")

Either use a package like finreportr, or one of the other packages that tries to read the edgar data.

Upvotes: 1

Related Questions