Skip to content

matthiasgomolka/simfinapi

Repository files navigation

simfinapi

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:

name id ticker currency Date Dividend Paid Common Shares Outstanding Last Closing Price Adjusted Closing Price Highest Price Lowest Price Opening Price Trading Volume
Alphabet (Google) 18 GOOG USD 2014-03-27 NA 6721016620 27.92 27.92 28.40 27.65 28.40 262000
Alphabet (Google) 18 GOOG USD 2014-03-28 NA 6721016620 28.00 28.00 28.32 27.93 28.06 822000
Alphabet (Google) 18 GOOG USD 2014-03-31 NA 13489240000 27.85 27.85 28.35 27.85 28.34 216000
Alphabet (Google) 18 GOOG USD 2014-04-01 NA 13489240000 28.36 28.36 28.42 27.94 27.94 158000
Alphabet (Google) 18 GOOG USD 2014-04-02 NA 13489240000 28.35 28.35 30.24 28.11 28.26 2934000
Alphabet (Google) 18 GOOG USD 2014-04-03 NA 13489240000 28.49 28.49 29.36 28.21 28.49 101704000

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()

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.