fix: correct DCF engine — FCFF/WACC consistency, smooth growth fade, mid-year convention - #3
Closed
blackswan127 wants to merge 0 commit into
Closed
blackswan127 wants to merge 0 commit into
blackswan127 wants to merge 0 commit into
Conversation
blackswan127
force-pushed
the
claude/stocklens-ui-alphavintage-fallback-7tswp4
branch
from
July 9, 2026 12:58
d4ff513 to
304ad05
Compare
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Six correctness fixes to the DCF valuation engine, covering financial accuracy, numerical stability, and code quality.
Changes
1. FCFF / WACC consistency
dcfService.ts: computeshistoricalFCFFserver-side by adding back after-tax interest expense to reported (levered) FCF2. SEC EDGAR confidence period fix
dcfService.ts: captureslatestAnnualFCF/latestAnnualRevbefore TTM is appendeddataConfidenceblock now compares annual-vs-annual data, eliminating false-medium signals caused by the TTM period mismatch3. Smooth 2-stage growth fade for any projection length
dcfCalculator.ts: replaces the hard-coded 5-year stage-1 cliff with adaptive split —stage1Years = min(5, ceil(N/2))4. Monte Carlo initial-margin standard deviation
monteCarlo.ts: separatesfcfMarginStdDev(initial-year dispersion) fromtargetFcfMarginStdDev(long-run target dispersion)5. Deduplicated projection core
dcfCalculator.ts: extractsrunProjection(inputs, wacc, currentPrice)as a single shared functioncomputeDCFandcomputeDCFWithFixedWACCboth delegate to it, eliminating ~80 lines of duplicated logic6. Mid-year discounting convention
dcfCalculator.ts: adds optionalmidYearConvention?: booleanflagi − 0.5; terminal value at periodN − 0.5Tests
computeDCFWithFixedWACCmatchescomputeDCFat the same WACC), FCFF series assertions on the DCF routevitest run)npx tsc --noEmitexits 0vite build)Generated by Claude Code