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.
ExampleIn 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:
62747 AMZN 2000-01-03 USD 4.08 4.48 4.00 4.47 4.47 322352000 NA NA 62747 AMZN 2000-01-04 USD 4.27 4.58 4.09 4.10 4.10 349748000 NA NA 62747 AMZN 2000-01-05 USD 3.54 3.76 3.48 3.59 3.59 769148000 NA NA 62747 AMZN 2000-01-06 USD 3.57 3.63 3.20 3.28 3.28 375040000 NA NA 62747 AMZN 2000-01-07 USD 3.35 3.52 3.31 3.48 3.48 210108000 NA NA 62747 AMZN 2000-01-10 USD 3.63 3.63 3.28 3.46 3.46 295158000 NA NALetâ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:
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 directory1 globally before you start downloading data. See ?sfa_set_api_key
and ?sfa_set_cache_dir
for details.
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 tosimfinR
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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4