library(badger)
library(knitr)
library(ggplot2)

opts_chunk$set(
    fig.width = 8,
    fig.height = 4.5,
    fig.path = "man/figures/README-",
    dpi = 150,
    collapse = TRUE,
    comment = "#>",
    out.width = "100%"
)

options(sfa_api_key = Sys.getenv("SIMFIN_API_KEY"))
options(sfa_cache_dir = tempdir())
options("future.rng.onMisuse" = "ignore")

theme_set(theme_minimal())

simfinapi

r badge_lifecycle("experimental") CRAN
release Status R-CMD-check r badge_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()

# 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:

kable(head(prices))

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 directory[^1] globally before you start downloading data. See ?sfa_set_api_key and ?sfa_set_cache_dir for details.

[^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.

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.



matthiasgomolka/simfinapi documentation built on April 22, 2024, 5:28 a.m.