MyNixOS website logo
Description

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

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

RatioDescriptionSource
EPSDiluted Earnings Per Share (USD)EDGAR
NetIncomeNet Income (USD)EDGAR
RevenueTotal Revenue (USD)EDGAR
ROEReturn on Equity (%)EDGAR
ROAReturn on Assets (%)EDGAR
DEDebt-to-Equity ratioEDGAR
CurrentRatioCurrent Assets / Current LiabilitiesEDGAR
GrossMarginGross Profit as % of RevenueEDGAR
OperatingMarginOperating Income as % of RevenueEDGAR
NetMarginNet Income as % of RevenueEDGAR
PEPrice-to-Earnings ratioEDGAR + Yahoo
PBPrice-to-Book ratioEDGAR + Yahoo
DIVDividend 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.

Metadata

Version

0.1.2

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • 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-linux
  • 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
  • sh4-linux
  • 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-uefi
  • x86_64-windows