Skip to main content

Module: lib/dcf_engine.py

The core computation engine for the FCFF valuation model. Accepts pre-computed 10-year schedules from the curve shapes library and produces a complete valuation.

Key function

dcf_valuation()

The main entry point. Runs the full DCF: 10-year projection, terminal value, and equity bridge. Schedule inputs (from growth-and-profitability via curve_shapes.py):
  • growth_schedule — 10-element list of revenue growth rates (year 1–10)
  • margin_schedule — 10-element list of operating margins (year 1–10)
  • s2c_schedule — 10-element list of sales-to-capital ratios (year 1–10)
  • coc_schedule — 10-element list of cost of capital rates (year 1–10)
Base year financials (from LTM):
  • revenue, ebit, book_equity, book_debt, cash
  • minority_interests, non_operating_assets
  • shares_outstanding, stock_price
  • effective_tax_rate, marginal_tax_rate, riskfree_rate
Adjustment inputs (optional): 9 structural overrides (default assumption toggles):
  • Terminal cost of capital, terminal ROIC, failure probability, reinvestment lag, tax convergence, NOL carryforward, risk-free rate override, growth rate override, trapped cash
Returns: Dictionary containing yearly projections (10 years + terminal), terminal value, PV of cash flows, equity bridge, value per share, stock price, and price-as-percentage-of-value.

How schedules flow through

When schedules are provided, they take precedence over the legacy scalar inputs:
growth_schedule → Revenue growth rates (rows D26:M26)
margin_schedule → Operating margins (rows D28:M28)
s2c_schedule    → Sales-to-capital ratios (rows D35:M35)
coc_schedule    → Cost of capital rates (rows D36:M36)
If no schedules are provided, the engine falls back to linear interpolation from legacy scalar inputs (e.g., revenue_growth_next_year, revenue_growth_years_2_5). This ensures backward compatibility with older runs.

Terminal value computation

compute_terminal_growth_rate()

Priority: user growth override → user risk-free override → current risk-free rate.

compute_terminal_cost_of_capital()

Priority: user stable CoC override → risk-free override + base ERP → current risk-free + base ERP.

compute_terminal_tax_rate()

If tax convergence override is on, stays at effective tax rate. Otherwise converges to industry average effective tax rate (preferred) or marginal rate.

compute_terminal_roic()

If override is on, uses user-specified ROIC. Otherwise ROIC converges to cost of capital (no excess returns in perpetuity).

Equity bridge

equity_bridge()

Converts operating value to equity value per share. See equity bridge documentation for the full walkthrough.