matthiasgomolka / simfinapi

Makes 'SimFin' data (https://simfin.com/) easily accessible in R.
19 stars 4 forks source link

sfa_get_statement() get multiple select years #25

Closed GitHubGeniusOverlord closed 3 years ago

GitHubGeniusOverlord commented 3 years ago

Hello again.

with SimfinR it was possible to retreive fin-statements on every year you wanted, like 2000:2021 with simfinR_get_fin_statements(year = 2000:2021) ....

But simfinapi only gives one entry (row), seemingly only from the current year (?), which makes sfa_get_statement() a lot less usefull. Could it be possible to query a distinct year? Then it would surely also be possible to query a vector of years.

Maybe this feature could be added to the sfa_get_statement() function.

Thank You!

matthiasgomolka commented 3 years ago

Hi and thanks for raising the issue.

Can you provide a reprex including the session info?

GitHubGeniusOverlord commented 3 years ago

Well since its not exactly an error of the simfinapi package I dont see how I can provide a reprex. Its more like a feature request. I know everyone has limited time, but I thought, why not just let the idea here.

matthiasgomolka commented 3 years ago

FYI: This is already possible if you have a SimFin+ account:

> remotes::install_github("https://github.com/matthiasgomolka/simfinapi")
> library(simfinapi)
> 
> sfa_set_api_key("u1ZsJLM1ZPtdwcxcAVHqtfY06FuLi3hX")
> 
> tickers <- c('AAPL')
> bs_data <- sfa_get_statement(tickers, statement = "bs", fyear = 2015:2020)
> unique(bs_data[["fiscal_year"]])
[1] 2015 2016 2017 2018 2019 2020

A solution for non-SimFin+-user would be:

sfa_set_api_key("YourApiKey")
years <- 2015:2020
bs_data <- years |> 
  lapply(function(x) sfa_get_statement(ticker = "AAPL", statement = "bs", fyear = x)) |> 
  data.table::rbindlist()

But I guess, you suggest to implement this internally for non-SimFin+-users?

matthiasgomolka commented 3 years ago

Actually, this is what I meant in #6.

GitHubGeniusOverlord commented 3 years ago

Exactly! Non-SimFin+ - user should also have the option to load all years at once. I can see why restricting which and how much data you get as a Free-User is reasonable as a business incentive. Making the API inconvenient however seems a bit unnecessary from the side of SimFin. Your solution with lapply is already nice. still, one could include that into the package and make people even happier.

GitHubGeniusOverlord commented 3 years ago

You could implement it like this: Have an argument inside of the function which asks, whether someone is SimFin+ [True, False]. The behavior of the function follows accordingly. Or maybe even let it be a global variable. The field would probably have to be mandatory but would mostly benefit people, I guess.

matthiasgomolka commented 3 years ago

You could implement it like this: Have an argument inside of the function which asks, whether someone is SimFin+ [True, False]. The behavior of the function follows accordingly. Or maybe even let it be a global variable. The field would probably have to be mandatory but would mostly benefit people, I guess.

I see. This is basically what I described in #6, right? Or am I missing something?

GitHubGeniusOverlord commented 3 years ago

Yes, that sounds good. Issue solved if you ask me.

matthiasgomolka commented 3 years ago

Glad to hear!