Home

Awesome

simfinapi <img src="man/figures/logo.png" align="right" height="139"/>

CRAN release Status R-CMD-check Dependencies

What does simfinapi do?

simfinapi wraps the https://www.simfin.com/ Web-API to make ‘SimFin’ data easily available in R.

To use the package, you need to register at https://app.simfin.com/login and obtain a ‘SimFin’ API key.

Example

In this example, we download some stock price data and turn these into a simple plot.

# load package
# library(simfinapi)
devtools::load_all()
#> ℹ Loading simfinapi

# download stock price data
tickers <- c("AMZN", "GOOG") # Amazon, Google
prices <- sfa_load_shareprices(tickers)

Please note that all functions in simfinapi start with the prefix sfa_. This makes it easy to find all available functionality.

The downloaded data looks like this:

nameidtickercurrencyDateDividend PaidCommon Shares OutstandingLast Closing PriceAdjusted Closing PriceHighest PriceLowest PriceOpening PriceTrading Volume
Alphabet (Google)18GOOGUSD2014-03-27NA672101662027.9227.9228.4027.6528.40262000
Alphabet (Google)18GOOGUSD2014-03-28NA672101662028.0028.0028.3227.9328.06822000
Alphabet (Google)18GOOGUSD2014-03-31NA1348924000027.8527.8528.3527.8528.34216000
Alphabet (Google)18GOOGUSD2014-04-01NA1348924000028.3628.3628.4227.9427.94158000
Alphabet (Google)18GOOGUSD2014-04-02NA1348924000028.3528.3530.2428.1128.262934000
Alphabet (Google)18GOOGUSD2014-04-03NA1348924000028.4928.4929.3628.2128.49101704000

Let’s turn that into a simple plot.

# load ggplot2
library(ggplot2)

# create plot
ggplot(prices) +
  aes(x = Date, y = `Last Closing Price`, color = name) +
  geom_line()
<img src="man/figures/README-plot_data-1.png" width="100%"/>

Installation

From CRAN:

install.packages("simfinapi")

If you want to try out the newest features you may want to give the development version a try and install it from GitHub:

remotes::install_github("https://github.com/matthiasgomolka/simfinapi")

Setup

Using simfinapi is much more convenient if you set your API key and cache directory1 globally before you start downloading data. See ?sfa_set_api_key and ?sfa_set_cache_dir for details.

Code of Conduct

Please note that the ‘simfinapi’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Footnotes

  1. simfinapi always caches the results from your API calls to obtain results quicker and to reduce the number of API calls. If you set the cache directory to a permanent directory (the default is tempdir()), simfinapi will be able to reuse this cache in subsequent R sessions.