-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
128 lines (91 loc) · 3.07 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# fmpapi: An R package for interfacing with the Financial Modeling Prep API <img src='man/figures/logo.png' align="right" height="202.5" />
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/fmpapi)](https://CRAN.R-project.org/package=fmpapi)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
<!-- badges: end -->
The goal of `fmpapi` is to provide a simple and consistent interface to the **Financial Modeling Prep** [Financial Data API](https://financialmodelingprep.com/) that can be used along side and integrated with other common R resources
for collecting and analyzing financial data, such as `tidyquant`, `xts`, `TTR`, and `quantmod`.
## Installation
<!-- You can install the released version of fmp from [CRAN](https://CRAN.R-project.org) with: -->
<!-- --- actually not on CRAN yet -->
<!-- ``` r -->
<!-- install.packages("fmpapi") -->
<!-- ``` -->
You can install the latest development version of fmp from [Github](https://github.com) with:
``` r
remotes::install_github('jpiburn/fmpapi')
```
## Getting Started
Before getting started with `fmpapi` you first must obtain an API key for the Financial Modeling Prep Financial Data API. For details, see [here](https://financialmodelingprep.com/developer/docs/pricing/).
Once you sign up, you can add your API key to your `.Renviron` file by using `fmp_api_key()`. This will add a `FMP_API_KEY` entry to your `.Renviron` file so it will automatically be available in future sessions. When first installed however, you will need to reload your .Renviron file by either restarting R or running `readRenviron('~/.Renviron')`
```{r api-key, eval=FALSE}
library(fmpapi)
api_key <- 'my_api_key'
fmp_api_key(api_key)
# reload
readRenviron('~/.Renviron')
```
## Company Information and Financials
```{r company-info, message=FALSE, warning=FALSE}
library(fmpapi)
library(tidyverse)
my_stocks <- c("AAPL", "GE")
d <- fmp_profile(my_stocks)
glimpse(d)
```
## Discounted Cash Flow Valuation
```{r company-dcf, message=FALSE, warning=FALSE}
fmp_dcf(my_stocks, historical = TRUE, quarterly = TRUE) %>%
ggplot(
aes(x = date, y = dcf, colour = symbol)
) +
geom_line(size = 1) +
theme_minimal() +
labs(
title = "Historical Discounted Cash Flow Valuation",
y = "Discounted Cash Flow Value"
)
```
## Key Metrics
```{r key-metrics}
d <- fmp_key_metrics(my_stocks)
glimpse(d)
```
## Balance Sheets
```{r}
d <- fmp_balance_sheet(my_stocks, quarterly = TRUE)
glimpse(d)
```
## Form 13-F Statements
```{r}
berkshire_cik <- '0001067983'
d <- fmp_13f(berkshire_cik)
glimpse(d)
```
## Earnings Calendar
```{r}
d <- fmp_earnings_calendar()
glimpse(d)
```
## SEC RSS Feed
```{r}
d <- fmp_sec_filings()
glimpse(d)
```
## Quoting Cryptocurrencies
```{r}
d <- fmp_quote_cryptos()
glimpse(d)
```