Retrieve Fundamental Financial Data from SEC 'EDGAR'

Provides a simple, ticker-based interface for retrieving fundamental financial data from the United States Securities and Exchange Commission's 'EDGAR' 'XBRL' API < https://www.sec.gov/edgar/sec-api-documentation>. Functions return key financial ratios including earnings per share, return on equity, return on assets, debt-to-equity, current ratio, gross margin, operating margin, net margin, price-to-earnings, price-to-book, and dividend yield for any publicly traded U.S. company. Data is sourced directly from company 10-K annual filings, requiring no API key or paid subscription. Designed for use in quantitative finance courses and research workflows.


edgarfundamentals

Retrieve Fundamental Financial Data from SEC EDGAR

edgarfundamentals provides a simple, ticker-based interface for retrieving key fundamental financial ratios directly from SEC EDGAR 10-K filings. No API key or paid subscription is required.

Installation

# From CRAN (once published)
install.packages("edgarfundamentals")

# Development version
devtools::install_github("robschumaker/edgarfundamentals")

Setup

The SEC requests that automated tools identify themselves via a User-Agent header. Set this once per session:

options(edgarfundamentals.user_agent = "Your Name [email protected]")

Functions

Function Description
get_cik(symbol) Translate a ticker to its SEC Central Index Key
get_fundamentals(symbol, to_date) Key ratios for one stock from its most recent 10-K
get_fundamentals_batch(symbols, to_date) Key ratios for a portfolio of stocks
get_filing_history(symbol, form_type, n) Recent SEC filing history for a stock

Quick Example

library(edgarfundamentals)
options(edgarfundamentals.user_agent = "Jane Smith [email protected]")

# Single stock
get_fundamentals("LLY", to_date = "2024-12-31")

# Portfolio
healthcare <- c("UNH", "PFE", "MRK", "ABT", "LLY", "CVS", "AMGN")
get_fundamentals_batch(healthcare, to_date = "2024-12-31")

Ratios Returned

get_fundamentals() and get_fundamentals_batch() return the following:

Ratio Description Source
EPS Diluted Earnings Per Share (USD) EDGAR
NetIncome Net Income (USD) EDGAR
Revenue Total Revenue (USD) EDGAR
ROE Return on Equity (%) EDGAR
ROA Return on Assets (%) EDGAR
DE Debt-to-Equity ratio EDGAR
CurrentRatio Current Assets / Current Liabilities EDGAR
GrossMargin Gross Profit as % of Revenue EDGAR
OperatingMargin Operating Income as % of Revenue EDGAR
NetMargin Net Income as % of Revenue EDGAR
PE Price-to-Earnings ratio EDGAR + Yahoo
PB Price-to-Book ratio EDGAR + Yahoo
DIV Dividend Yield (%) EDGAR + Yahoo

After cloning, generate documentation and check the package before submission:

devtools::document()   # generates man/ files from roxygen2 comments
devtools::check()      # runs R CMD check -- must pass with 0 errors, 0 warnings
devtools::build()      # builds the .tar.gz for CRAN submission

The man/ directory is generated automatically by devtools::document() and is not tracked in version control.

Data Source

All financial statement data comes from the SEC EDGAR XBRL API (data.sec.gov), specifically the companyfacts endpoint. Ratios reflect the most recently completed fiscal year from 10-K filings. PE, PB, and DIV additionally use current market prices from Yahoo Finance via tidyquant.

License

MIT © Robert P Schumaker

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("edgarfundamentals")

0.1.2 by Robert P Schumaker, 6 months ago


https://github.com/robschumaker/edgarfundamentals


Report a bug at https://github.com/robschumaker/edgarfundamentals/issues


Browse source code at https://github.com/cran/edgarfundamentals


Authors: Robert P Schumaker [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, dplyr, httr, jsonlite, rlang, tidyquant

Suggests knitr, rmarkdown


See at CRAN