Title: | Accessing 'SimFin' Data |
---|---|
Description: | Through simfinapi, you can intuitively access the 'SimFin' Web-API (<https://www.simfin.com/>) to make 'SimFin' data easily available in R. To obtain an 'SimFin' API key (and thus to use this package), you need to register at <https://app.simfin.com/login>. |
Authors: | Matthias Gomolka [aut, cre] |
Maintainer: | Matthias Gomolka <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-13 04:44:00 UTC |
Source: | https://github.com/matthiasgomolka/simfinapi |
Parameter documentation
api_key |
character Your 'SimFin' API key. It's recommended to set the API key globally using sfa_set_api_key. |
cache_dir |
character Your cache directory. It's recommended to set the cache directory globally using sfa_set_cache_dir. |
ticker |
integer Ticker of the companies of interest. |
id |
integer 'SimFin' IDs of the companies of interest. Any
|
asreported |
logical If |
ttm |
logical If |
start |
Date Filter for the report dates (reserved for SimFin+ users). With this filter you can filter the statements by the date on which the reported period ended ('Report Date'). By specifying a value here, only statements will be retrieved with report dates ending AFTER the specified date. |
end |
Date Filter for the report dates (reserved for SimFin+ users). With this filter you can filter the statements by the date on which the reported period ended ('Report Date'). By specifying a value here, only statements will be retrieved with report dates ending BEFORE the specified date. |
period |
character Filter for periods. As a non-SimFin+ user, you have to provide exactly one period. As SimFin+ user, this filter can be omitted to retrieve all statements available for the company.
|
fyear |
integer Filter for fiscal year. As a non-SimFin+ user, you have to provide exactly one fiscal year. As SimFin+ user, this filter can be omitted to retrieve all data available for the company. |
ratios |
logical With
|
This function supports parallel processing via future.apply
. If your
machine has several cores (most have), you can make the API calls in
parallel. To do so, define a future::plan()
before calling the function.
Get a list of all companies in the SimFin database. See https://simfin.readme.io/reference/list-1 and https://simfin.readme.io/reference/general-1 for more information.
sfa_load_companies( api_key = getOption("sfa_api_key"), cache_dir = getOption("sfa_cache_dir"), details = FALSE )
sfa_load_companies( api_key = getOption("sfa_api_key"), cache_dir = getOption("sfa_cache_dir"), details = FALSE )
api_key |
character Your 'SimFin' API key. It's recommended to set the API key globally using sfa_set_api_key. |
cache_dir |
character Your cache directory. It's recommended to set the cache directory globally using sfa_set_cache_dir. |
details |
|
data.table::data.table()
containing basic company information.
Fundamentals and derived figures can be retrieved here.
sfa_load_statements( ticker = NULL, id = NULL, statements, period = "fy", fyear = NULL, start = NULL, end = NULL, ttm = FALSE, asreported = FALSE, api_key = getOption("sfa_api_key"), cache_dir = getOption("sfa_cache_dir") )
sfa_load_statements( ticker = NULL, id = NULL, statements, period = "fy", fyear = NULL, start = NULL, end = NULL, ttm = FALSE, asreported = FALSE, api_key = getOption("sfa_api_key"), cache_dir = getOption("sfa_cache_dir") )
ticker |
integer Ticker of the companies of interest. |
id |
integer 'SimFin' IDs of the companies of interest. Any
|
statements |
character vector of statements, available values: pl (Profit & Loss), bs (Balance Sheet), cf (Cash Flow), derived (Derived Ratios and Indicators). |
period |
character Filter for periods. As a non-SimFin+ user, you have to provide exactly one period. As SimFin+ user, this filter can be omitted to retrieve all statements available for the company.
|
fyear |
integer Filter for fiscal year. As a non-SimFin+ user, you have to provide exactly one fiscal year. As SimFin+ user, this filter can be omitted to retrieve all data available for the company. |
start |
Date Filter for the report dates (reserved for SimFin+ users). With this filter you can filter the statements by the date on which the reported period ended ('Report Date'). By specifying a value here, only statements will be retrieved with report dates ending AFTER the specified date. |
end |
Date Filter for the report dates (reserved for SimFin+ users). With this filter you can filter the statements by the date on which the reported period ended ('Report Date'). By specifying a value here, only statements will be retrieved with report dates ending BEFORE the specified date. |
ttm |
logical If |
asreported |
logical If |
api_key |
character Your 'SimFin' API key. It's recommended to set the API key globally using sfa_set_api_key. |
cache_dir |
character Your cache directory. It's recommended to set the cache directory globally using sfa_set_cache_dir. |
data.table containing the statement(s) data.
This function supports parallel processing via future.apply
. If your
machine has several cores (most have), you can make the API calls in
parallel. To do so, define a future::plan()
before calling the function.
It is highly recommended to set the API key globally as it makes
specifying the api_key
argument of other sfa_*
functions obsolete.
There are two ways to set your API key globally:
Provide the API key directly as a string (api_key = 'YourApiKey'
).
Create a system-wide environment variable containing you API key and
refer to that (env_var = 'YourEnvVar'
). How to create a system-wide
environment variable depends on your operating system.
The second option is recommended because your R scripts won't contain your API key and it is safe to keep your scripts in an open repository like GitHub.
sfa_set_api_key(api_key, env_var)
sfa_set_api_key(api_key, env_var)
api_key |
character You API key. Ignored if you specify |
env_var |
character Name of an environment variable holding you API
key, e.g. |
character The API key (invisibly).
## Not run: # set API key directly sfa_set_api_key(api_key = 'YourApiKey') # set API key via environment variable # (this assumes you already created an environment variable called # 'SIMFIN_API_KEY' which contains you API key) sfa_set_api_key(env_var = 'SIMFIN_API_KEY') ## End(Not run)
## Not run: # set API key directly sfa_set_api_key(api_key = 'YourApiKey') # set API key via environment variable # (this assumes you already created an environment variable called # 'SIMFIN_API_KEY' which contains you API key) sfa_set_api_key(env_var = 'SIMFIN_API_KEY') ## End(Not run)
It is highly recommended to set the cache directory globally. This has two advantages:
Results from the 'SimFin' API calls are cached over the end of the session. This is especially interesting if you don't have a SimFin+ account and the number of API calls is limited to 2,000 per day.
It makes specifying the cache_dir
argument of other sfa_*
functions
obsolete.
sfa_set_cache_dir(path, create = FALSE)
sfa_set_cache_dir(path, create = FALSE)
path |
character The directory where you want to cache the responses from the 'SimFin' API calls. |
create |
logical Set |
character The cache directory (invisibly).