MyNixOS website logo
Description

Accessing 'SimFin' Data.

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

simfinapi

CRANrelease 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_get_prices(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:

idtickerdatecurrencyopenhighlowcloseadj_closevolumedividendcommon_shares_outstanding
62747AMZN2000-01-03USD4.084.484.004.474.47322352000NANA
62747AMZN2000-01-04USD4.274.584.094.104.10349748000NANA
62747AMZN2000-01-05USD3.543.763.483.593.59769148000NANA
62747AMZN2000-01-06USD3.573.633.203.283.28375040000NANA
62747AMZN2000-01-07USD3.353.523.313.483.48210108000NANA
62747AMZN2000-01-10USD3.633.633.283.463.46295158000NANA

Let’s turn that into a simple plot.

# load ggplot2
library(ggplot2)

# create plot
ggplot(prices) +
  aes(x = date, y = close, color = ticker) +
  geom_line()

Suppose we would like to display the actual company name instead of the ticker. To do so, we download additional company information and merge it to the prices data:

company_info <- sfa_get_info(tickers)

company_info contains these information:

idtickercompany_nameindustry_idmonth_fy_endnumber_employeesbusiness_summary
62747AMZNAMAZON COM INC103002121298000Amazon.com Inc is an online retailer. The Company sells its products through the website which provides services, such as advertising services and co-branded credit card agreements. It also offers electronic devices like Kindle e-readers and Fire tablets.
18GOOGAlphabet (Google)10100212135301Alphabet (formerly known as Google) offers a variety of IT services to individuals and corporations alike. Their main revenues come from online advertising.

Now we merge both datasets and recreate the plot with the actual company names.

# merge data
merged <- merge(prices, company_info, by = "ticker")

# recreate plot
ggplot(merged) +
  aes(x = date, y = close, color = company_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.

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.

Relation to simfinR

In case you also found simfinR (CRAN, GitHub) you might want to know about the differences between the simfinapi and simfinR. I tried to compile a list in this issue.


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

Metadata

Version

1.0.0

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows