SPB Git forge

spb/hfmarketdata

Public

Open high-frequency market data platform — FirstRate full-history downloader, DuckDB/Parquet lake, open REST API and React docs platform (www.hfmarketdata.io)

127commits 1branches 0releases
24.7 MBsize
maindefault branch
11 days agolast push
JavaScript 53.7% Python 38.3% CSS 4.6% TypeScript 3.1%
7.6 KB

# Fundamentals — ratio formulas

Generated from hfmarketdata/api/fundamentals/ratios.py (render_docs()); do not edit by hand.

Conventions: flows are trailing twelve months (sum of the last four discrete quarters — or the fiscal year with period=annual), balances are the latest balance sheet, price is the last close known at the valuation date. A ratio is null (with a reason in meta.reasons) whenever an input is missing or the denominator is not positive — nothing is ever invented.

# Valuation

# market_cap

market_cap = price × shares_outstanding

shares_outstanding is the cover-page share count (dei:EntityCommonStockSharesOutstanding, all classes summed) of the latest filing known at the valuation date; falls back to weighted-average diluted shares (flagged shares_source=weighted_diluted).

Inputs: price, shares_outstanding

# enterprise_value

enterprise_value = market_cap + total_debt − cash_and_equivalents − short_term_investments

Missing short_term_investments is treated as 0 (flagged); missing total_debt is treated as 0 only when the balance sheet has no debt account at all (flagged total_debt_assumed_zero).

Inputs: market_cap, total_debt, cash_and_equivalents, short_term_investments

# pe

pe = price / eps_diluted (TTM)

Null when TTM diluted EPS ≤ 0 (a negative P/E is not meaningful).

Inputs: price, eps_diluted

# forward_pe

forward_pe = price / forward_eps

HF Market Data does not carry analyst consensus estimates, so forward_eps is never available and forward_pe is always null with reason no_estimates — we do not extrapolate.

Inputs: forward_eps

# pb

pb = market_cap / total_equity

Null when book equity ≤ 0.

Inputs: market_cap, total_equity

# ps

ps = market_cap / revenue (TTM)

Inputs: market_cap, revenue

# ev_ebitda

ev_ebitda = enterprise_value / ebitda (TTM)

Null when EBITDA ≤ 0.

Inputs: enterprise_value, ebitda

# ev_sales

ev_sales = enterprise_value / revenue (TTM)

Inputs: enterprise_value, revenue

# ev_fcf

ev_fcf = enterprise_value / free_cash_flow (TTM)

Null when FCF ≤ 0.

Inputs: enterprise_value, free_cash_flow

# earnings_yield

earnings_yield = net_income (TTM) / market_cap

Inputs: net_income, market_cap

# fcf_yield

fcf_yield = free_cash_flow (TTM) / market_cap

Inputs: free_cash_flow, market_cap

# dividend_yield

dividend_yield = dividends paid (TTM, cash flow statement) / market_cap

Inputs: dividends, market_cap

# buyback_yield

buyback_yield = buybacks (TTM, cash paid for repurchases) / market_cap

Inputs: buybacks, market_cap

# Profitability

# gross_margin

gross_margin = gross_profit / revenue (TTM)

Inputs: gross_profit, revenue

# operating_margin

operating_margin = operating_income / revenue (TTM)

Inputs: operating_income, revenue

# net_margin

net_margin = net_income / revenue (TTM)

Inputs: net_income, revenue

# ebitda_margin

ebitda_margin = ebitda / revenue (TTM)

Inputs: ebitda, revenue

# fcf_margin

fcf_margin = free_cash_flow / revenue (TTM)

Inputs: free_cash_flow, revenue

# roe

roe = net_income (TTM) / total_equity (latest)

Uses the latest book equity, not the average — simpler and point-in-time consistent. Null when equity ≤ 0.

Inputs: net_income, total_equity

# roa

roa = net_income (TTM) / total_assets (latest)

Inputs: net_income, total_assets

# roic

roic = operating_income × (1 − tax_rate) / (total_debt + total_equity − cash_and_equivalents)

tax_rate = income_tax / pretax_income (TTM), only accepted in [0, 1]; when the effective rate is not computable the ratio is null (tax_rate_unavailable) — no statutory rate is assumed. Null when invested capital ≤ 0.

Inputs: operating_income, income_tax, pretax_income, total_debt, total_equity, cash_and_equivalents

# Liquidity

# current_ratio

current_ratio = total_current_assets / total_current_liabilities

Inputs: total_current_assets, total_current_liabilities

# quick_ratio

quick_ratio = (cash_and_equivalents + short_term_investments + receivables) / total_current_liabilities

Missing short_term_investments or receivables are treated as 0 (flagged).

Inputs: cash_and_equivalents, short_term_investments, receivables, total_current_liabilities

# cash_ratio

cash_ratio = (cash_and_equivalents + short_term_investments) / total_current_liabilities

Inputs: cash_and_equivalents, short_term_investments, total_current_liabilities

# Solvency

# debt_to_equity

debt_to_equity = total_debt / total_equity

Null when equity ≤ 0.

Inputs: total_debt, total_equity

# debt_to_assets

debt_to_assets = total_debt / total_assets

Inputs: total_debt, total_assets

# net_debt_to_ebitda

net_debt_to_ebitda = net_debt / ebitda (TTM)

Null when EBITDA ≤ 0.

Inputs: net_debt, ebitda

# interest_coverage

interest_coverage = operating_income / interest_expense (TTM)

Null when interest expense is 0 or not reported.

Inputs: operating_income, interest_expense

# Efficiency

# asset_turnover

asset_turnover = revenue (TTM) / total_assets (latest)

Inputs: revenue, total_assets

# inventory_turnover

inventory_turnover = cost_of_revenue (TTM) / inventory (latest)

Inputs: cost_of_revenue, inventory

# receivables_turnover

receivables_turnover = revenue (TTM) / receivables (latest)

Inputs: revenue, receivables

# days_sales_outstanding

days_sales_outstanding = 365 × receivables / revenue (TTM)

Inputs: receivables, revenue

# cash_conversion_cycle

cash_conversion_cycle = DSO + DIO − DPO

DSO = 365 × receivables / revenue · DIO = 365 × inventory / cost_of_revenue · DPO = 365 × accounts_payable / cost_of_revenue (all flows TTM, balances latest).

Inputs: receivables, revenue, inventory, accounts_payable, cost_of_revenue

# Growth

# revenue_growth_yoy

revenue_growth_yoy = revenue (TTM) / revenue (TTM one year earlier) − 1

Inputs: revenue, revenue_prev_year

# revenue_growth_qoq

revenue_growth_qoq = revenue (latest quarter) / revenue (previous quarter) − 1

Inputs: revenue_q, revenue_prev_quarter

# eps_growth_yoy

eps_growth_yoy = eps_diluted (TTM) / eps_diluted (TTM one year earlier) − 1

Null when the base EPS ≤ 0.

Inputs: eps_diluted, eps_diluted_prev_year

# fcf_growth_yoy

fcf_growth_yoy = free_cash_flow (TTM) / free_cash_flow (TTM one year earlier) − 1

Inputs: free_cash_flow, free_cash_flow_prev_year

# revenue_cagr_3y

revenue_cagr_3y = (revenue TTM / revenue TTM 3 years earlier)^(1/3) − 1

Inputs: revenue, revenue_3y

# revenue_cagr_5y

revenue_cagr_5y = (revenue TTM / revenue TTM 5 years earlier)^(1/5) − 1

Inputs: revenue, revenue_5y

# revenue_cagr_10y

revenue_cagr_10y = (revenue TTM / revenue TTM 10 years earlier)^(1/10) − 1

Inputs: revenue, revenue_10y

# eps_cagr_5y

eps_cagr_5y = (eps_diluted TTM / eps_diluted TTM 5 years earlier)^(1/5) − 1

Inputs: eps_diluted, eps_diluted_5y

# Per Share

# revenue_ps

revenue_ps = revenue (TTM) / shares_diluted (weighted average, latest quarter)

Inputs: revenue, shares_diluted

# book_value_ps

book_value_ps = total_equity / shares_outstanding

Inputs: total_equity, shares_outstanding

# fcf_ps

fcf_ps = free_cash_flow (TTM) / shares_diluted

Inputs: free_cash_flow, shares_diluted

# cash_ps

cash_ps = (cash_and_equivalents + short_term_investments) / shares_outstanding

Inputs: cash_and_equivalents, short_term_investments, shares_outstanding