Pulls fundamental financial data directly from a company's most recent annual 10-K filing in SEC EDGAR and computes key financial ratios. No API key or paid subscription is required.
get_fundamentals(symbol, to_date = as.character(Sys.Date()))A named numeric vector with the following elements:
SEC Central Index Key -- the company's unique EDGAR identifier.
Diluted Earnings Per Share (USD per share) from the most recent qualifying 10-K. Falls back to basic EPS if diluted is unavailable.
Net income attributable to the company (USD).
Total revenue (USD).
Return on Equity as a percentage (NetIncome / StockholdersEquity * 100). A measure of how efficiently the company generates profit from shareholder capital.
Return on Assets as a percentage (NetIncome / TotalAssets * 100). A measure of how efficiently the company uses its assets.
Debt-to-Equity ratio (LongTermDebt / StockholdersEquity). A measure of financial leverage.
Current Assets divided by Current Liabilities. A measure of short-term liquidity; values above 1 indicate the company can cover near-term obligations.
Gross Profit as a percentage of Revenue. Measures pricing power and production efficiency.
Operating Income as a percentage of Revenue. Measures operational efficiency before interest and taxes.
Net Income as a percentage of Revenue. Bottom-line profitability after all expenses.
Price-to-Earnings ratio, computed by dividing the most recent
adjusted closing price (from Yahoo Finance via tidyquant) by EPS.
Returns NA if EPS is zero or negative.
Price-to-Book ratio, computed by dividing the most recent
adjusted closing price by Book Value per Share (StockholdersEquity /
SharesOutstanding). Returns NA if shares outstanding is zero
or unavailable.
Dividend Yield as a percentage (DividendsPerShareDeclared /
Price * 100). Returns NA if no dividend data is available.
A character string containing the stock ticker symbol
(e.g. "LLY"). Case-insensitive.
A character string in "YYYY-MM-DD" format. The
function returns ratios from the most recent 10-K with a period end date
on or before this date. Defaults to today's date.
Financial statement values are extracted from XBRL-tagged 10-K filings via
the SEC EDGAR companyfacts API
(https://data.sec.gov/api/xbrl/companyfacts/). Because data comes
from annual filings, ratios reflect the most recently completed fiscal year
ending on or before to_date, not real-time values.
Fallback XBRL tags are attempted automatically when a company uses a non-standard tag name for a concept. A courtesy pause of 0.5 seconds is inserted after the companyfacts API call to respect the SEC's rate limit of 10 requests per second.
Set your User-Agent once per session:
options(edgarfundamentals.user_agent = "Your Name your@email.com")
if (FALSE) {
options(edgarfundamentals.user_agent = "Jane Smith jane@example.com")
# Fundamentals for Eli Lilly as of end of 2024
get_fundamentals("LLY", "2024-12-31")
# Fundamentals as of today
get_fundamentals("JNJ")
}
Run the code above in your browser using DataLab