DCF Valuation with Valuein SDK
Build a discounted cash flow model using SEC EDGAR fundamentals. Fetch free cash flow per share from the API, supply your own discount-rate and growth assumptions, and compute intrinsic value per share.
Overview
A Discounted Cash Flow (DCF) model estimates a company's intrinsic value by projecting future free cash flows and discounting them back to present value. Valuein does not publish a single precomputed intrinsic value — a fair-value number is a function of the discount rate, growth rate, and horizon YOU choose, so those assumptions are always supplied by the caller, never pipeline-baked-in. Pull the real per-share free cash flow from the `ratio` table via the Python SDK below, or call the MCP `compute_dcf` tool directly with your own assumptions to get a per-share value plus a 5x5 sensitivity grid in one call.
Install and Authenticate
Install the Valuein SDK with either pip or uv. An API token is optional — without one, the SDK runs against the SAMPLE dataset (S&P 500, last 5 years) so the snippets below still work.
pip install valuein-sdk # or: uv pip install valuein-sdkexport VALUEIN_API_KEY="your_token" # optional: with no key the SDK reads the free sampleCompute Intrinsic Value
Implement the two-stage DCF on a per-share basis: high-growth phase followed by a terminal value. wacc, growth, and terminal_growth are YOUR assumptions — Valuein does not compute or publish them for you.
from valuein_sdk import ValueinClient def dcf_two_stage(fcf_per_share, growth, wacc, terminal_growth, years): # Stage 1: explicit growth period pv_fcfs = 0 for t in range(1, years + 1): fcf_t = fcf_per_share * (1 + growth) ** t pv_fcfs += fcf_t / (1 + wacc) ** t # Stage 2: terminal value (Gordon Growth) terminal_fcf = fcf_per_share * (1 + growth) ** years * (1 + terminal_growth) terminal_value = terminal_fcf / (wacc - terminal_growth) pv_terminal = terminal_value / (1 + wacc) ** years return pv_fcfs + pv_terminal # Latest annual free cash flow per share for Apple (same query as the previous step).with ValueinClient() as client: df = client.run_query(""" SELECT entity_id, period_end, accepted_at, value AS fcf_per_share FROM ratio WHERE entity_id = '0000320193' -- AAPL CIK AND ratio_name = 'fcf_per_share' AND fiscal_period = 'FY' -- latest fiscal year ORDER BY period_end DESC LIMIT 1 """) row = df.iloc[0] # YOUR assumptions — Valuein publishes no WACC, growth, or terminal rate.# The MCP compute_dcf tool takes the same three inputs and returns a# 5x5 sensitivity grid across them in one call.wacc, growth, terminal_growth, years = 0.09, 0.08, 0.025, 5intrinsic_value = dcf_two_stage(row['fcf_per_share'], growth, wacc, terminal_growth, years)print(f"Intrinsic value per share (your assumptions): ${intrinsic_value:.2f}")Point-in-Time Backtest
To avoid look-ahead bias, create the client with `as_of` set to the historical date: the SDK then keeps only the ratio vintages the SEC had accepted by then, so a later restatement cannot leak in. Then apply the same caller-supplied assumptions above.
# Only use fundamentals known before 2023-01-01from datetime import datetime, timezone from valuein_sdk import ValueinClient, ValueinError try: # as_of hides every ratio vintage accepted after the cutoff, so a later # restatement can never leak into the historical value. with ValueinClient(as_of=datetime(2023, 1, 1, tzinfo=timezone.utc)) as client: df = client.run_query(""" SELECT period_end, accepted_at, value AS fcf_per_share FROM ratio WHERE entity_id = '0000320193' AND ratio_name = 'fcf_per_share' AND fiscal_period = 'FY' ORDER BY period_end DESC LIMIT 1 """) row = df.iloc[0] print(row)except ValueinError as e: print(f"Error: {e}")Up next
Point-in-Time Backtesting
Construct survivorship-bias-free factor portfolios using accepted_at timestamps and PIT universe snapshots.