Implementation:AI4Finance Foundation FinRobot calculate ddm
| Knowledge Sources | |
|---|---|
| Domains | Finance, Valuation, Deterministic_Compute |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
Concrete deterministic engine for running a multi-stage DDM valuation (base case + sensitivity grid) from structured inputs, provided by the FinRobot compute layer.
Description
The calculate_ddm function is the DDM compute operator. It takes a fully-seeded DDMInputs object (produced by seed_ddm_inputs) and performs reproducible arithmetic: projects dividends year-by-year at specified growth rates, discounts each dividend at the CAPM cost of equity, computes a Gordon-Growth terminal value with terminal-payout normalization, and sums to an equity value per share.
The companion calculate_ddm_sensitivity function projects dividends once (they are CoE/TG-independent), then discounts at each (CoE, TG) combination to produce a sensitivity table.
Usage
- DDM_Valuation workflow (Step 3): Called after seed_ddm_inputs to compute the base-case equity value per share and the CoE × terminal-growth sensitivity grid.
- Equity_Research workflow (Step 4): The DDM result is one of the valuation methods aggregated into the football-field synthesis.
- Import this when you need deterministic DDM arithmetic for banks, utilities, or dividend-paying stocks. Raises ValueError when terminal growth ≥ cost of equity, Gordon spread is below floor, or any dividend growth rate < −1.
Code Reference
Source Location
- Repository: FinRobot
- File: finrobot_desktop/finrobot/engine/compute/operators/ddm.py
Signature
def calculate_ddm(inputs: DDMInputs) -> DDMResult:
"""Run a multi-stage DDM valuation from structured inputs.
Args:
inputs: DDMInputs with dividend, growth rates, and CAPM parameters.
Returns:
DDMResult with all intermediate and final valuation numbers.
Raises:
ValueError: If terminal growth rate >= cost of equity (Gordon Growth
perpetuity undefined), if CoE - tg < MIN_GORDON_SPREAD, or if any
dividend_growth_rate < -1 (negative dividend).
"""
def calculate_ddm_sensitivity(
inputs: DDMInputs,
coe_range: list[float],
tg_range: list[float],
) -> DDMSensitivity:
"""Generate sensitivity table: equity value per share for each (CoE, tg) pair.
Returns None for cells where tg >= CoE or Gordon spread below floor.
"""
Import
from finrobot.engine.compute.operators.ddm import calculate_ddm, calculate_ddm_sensitivity
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| inputs | DDMInputs | Yes | Seeded DDM inputs: dividend_per_share, payout_ratio, dividend_growth_rates, terminal_payout_ratio, return_on_equity, beta, risk_free_rate, equity_risk_premium, terminal_growth_rate, current_price |
| coe_range | list[float] | Yes (sensitivity) | Cost of equity values for the sensitivity grid |
| tg_range | list[float] | Yes (sensitivity) | Terminal growth values for the sensitivity grid |
Outputs
| Name | Type | Description |
|---|---|---|
| DDMResult | DDMResult | cost_of_equity, projected_dividends, pv_dividends, pv_dividends_total, terminal_dividend, terminal_value, pv_terminal, equity_value_per_share, inputs |
| sensitivity | DDMSensitivity | coe_values, tg_values, implied_prices (2D grid with None for undefined cells) |
Usage Examples
Basic DDM Valuation
from finrobot.engine.compute.operators.ddm import calculate_ddm, calculate_ddm_sensitivity
from finrobot.engine.compute.operators.ddm_seed import seed_ddm_inputs
# 1. Seed DDM inputs from financials + normalized dividend fields
ddm_inputs = seed_ddm_inputs(
financials=financial_data,
normalized=normalized_financials,
dividend_history=annual_dps_map, # {"2021": 4.0, "2022": 4.4, ...}
)
# 2. Run the base-case DDM
ddm_result = calculate_ddm(ddm_inputs)
print(f"Equity value per share: ${ddm_result.equity_value_per_share:.2f}")
print(f"Cost of equity: {ddm_result.cost_of_equity:.2%}")
# 3. Generate sensitivity table
sensitivity = calculate_ddm_sensitivity(
ddm_inputs,
coe_range=[0.08, 0.09, 0.10, 0.11, 0.12],
tg_range=[0.02, 0.025, 0.03, 0.035],
)