Consolidate metric definitions with Rust JSON as single source of truth

- Add core.computed.json with 32 ratio definitions (filing + market derived)
- Add Rust types for ComputedDefinition and ComputationSpec
- Create generate-taxonomy.ts to generate TypeScript from Rust JSON
- Generate lib/generated/ (gitignored) with surfaces, computed, kpis
- Update financial-metrics.ts to use generated definitions
- Add build-time generation via 'bun run generate'
- Add taxonomy architecture documentation

Two-phase ratio computation:
- Filing-derived: margins, returns, per-share, growth (Rust computes)
- Market-derived: valuation ratios (TypeScript computes with price data)

All 32 ratios defined in core.computed.json:
- Margins: gross, operating, ebitda, net, fcf
- Returns: roa, roe, roic, roce
- Financial health: debt_to_equity, net_debt_to_ebitda, cash_to_debt, current_ratio
- Per-share: revenue, fcf, book_value
- Growth: yoy metrics + 3y/5y cagr
- Valuation: market_cap, ev, p/e, p/fcf, p/b, ev/sales, ev/ebitda, ev/fcf
This commit is contained in:
2026-03-15 15:22:51 -04:00
parent ed4420b8db
commit 24aa8e33d4
11 changed files with 1453 additions and 123 deletions

View File

@@ -6,13 +6,14 @@
"scripts": {
"dev": "bun run scripts/dev.ts",
"dev:next": "bun --bun next dev --turbopack",
"generate": "bun run scripts/generate-taxonomy.ts",
"build:sidecar": "cargo build --manifest-path rust/Cargo.toml --release --bin fiscal-xbrl",
"build": "bun --bun next build --turbopack",
"build": "bun run generate && bun --bun next build --turbopack",
"bootstrap:prod": "bun run scripts/bootstrap-production.ts",
"check:sidecar": "cargo check --manifest-path rust/Cargo.toml",
"validate:taxonomy-packs": "bun run scripts/validate-taxonomy-packs.ts",
"start": "bun --bun next start",
"lint": "bun x tsc --noEmit",
"lint": "bun run generate && bun x tsc --noEmit",
"e2e:prepare": "bun run scripts/e2e-prepare.ts",
"e2e:webserver": "bun run scripts/e2e-webserver.ts",
"workflow:setup": "workflow-postgres-setup",