calculate_dcf_valuation
Perform discounted cash flow valuation for A-share stocks. Returns enterprise value; equity and per-share intrinsic value when net debt is provided.
Instructions
Simplified DCF valuation. OCF derived as MBRevenue * CFOToOR (~2% precision).
FCF = OCF * (1 - capex_to_ocf_ratio). Caller must supply capex_to_ocf_ratio because baostock provides no Capex data.
Enterprise value (EV) is always returned. To derive equity value and
per-share intrinsic value, caller must provide net_debt, which baostock
does NOT publish — it must come from the balance sheet (interest-bearing
debt minus cash & equivalents). Without it, only EV is returned and the
caller can compute equity = ev - (their own net_debt).
When akshare is installed and reachable, real operating cash flow (NETCASH_OPERATE) and real capex (CONSTRUCT_LONG_ASSET) are used automatically (capex_to_ocf_ratio is then ignored), and net_debt is computed from the balance sheet if not provided. If akshare is absent or fails at runtime (rate-limit, anti-scrape), the calculation falls back to baostock estimation using capex_to_ocf_ratio. data_provenance indicates which path.
Uses a fixed 5-year FCF history, degrading gracefully to as few as 2 years when reports are missing.
forecast_growth clamps fcf_cagr to growth_clamp_bounds ([-5%, 15%]);
growth_clamped reports which bound (if any) was hit. Read it before using
forecast_growth -- a raw CAGR outside the band was silently overridden.
intermediates.fcf_quality reports negative_years / sign_changes / min / max
on the historical FCF series; fcf_cagr is endpoint-anchored and does not
reflect intra-period volatility.
Args: code: Stock code. discount_rate: WACC / discount rate, e.g. 0.10. terminal_growth_rate: Perpetual growth rate, e.g. 0.025. capex_to_ocf_ratio: Capex as a fraction of OCF. Always required, but used only on the baostock fallback path; ignored when akshare's real capex is available. net_debt: Interest-bearing debt minus cash & equivalents (CNY). Negative = net cash position. Required for per-share valuation. forecast_years: Projection period (must be in [1, 20]).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| discount_rate | Yes | ||
| terminal_growth_rate | Yes | ||
| capex_to_ocf_ratio | Yes | ||
| net_debt | No | ||
| forecast_years | No |