Architecture Note · Finance & Legal
Deterministic Treasury Cash-Flow & FX Exposure Architecture: Covenant Stress Tests, 95% VaR, and Human Sign-Off
Why probabilistic LLM wrappers break multi-bank cash consolidation and FX hedging—and how deterministic MT940/BAI2 parsing, 13-week covenant stress testing, 95% FX VaR, and SQLite approval gates fix it.
The Operational Problem: Fragmented Multi-Bank Liquidity and FX Drift
Corporate treasurers, VPs of Finance, and multinational CFOs rarely lack raw banking data; they lack a unified, deterministic view of what cash is actually deployable before markets close. Operating, payroll, and sweep accounts spread across seven currencies—USD, EUR, GBP, JPY, AUD, CAD, and CHF—mix freely sweepable liquidity with trapped statutory reserves such as PAYE payroll escrows, VAT/GST holdbacks, and intercompany dividend holds. When teams reconcile SWIFT MT940, BAI2, and bank CSV files in manual spreadsheets, an unexpected 10-day accounts-receivable slip or quarterly tax remittance can breach a minimum liquidity covenant before the weekly cash call.
Why Naive AI Wrappers Fail
Dropping a general-purpose chat model on top of bank statements introduces four structural failure modes that finance teams cannot tolerate:
- Nondeterministic financial math: Language models approximate arithmetic and silently drop rounding or FX cross-rate precision. A 13-week direct cash-flow schedule or 95% parametric Value-at-Risk calculation must reproduce identical cent-level outputs on every run.
- Unbounded bank-data egress: Shipping raw IBANs, counterparty remittance strings, and subsidiary cash balances to third-party LLM endpoints violates corporate treasury security boundaries and exposes sensitive M&A or payroll liquidity positions.
- Hallucinated liquidity availability: Generic summarizers routinely conflate headline ledger balances with sweepable cash, ignoring ring-fenced tax escrows and inflating apparent covenant headroom.
- Missing execution and audit controls: Treasury desks cannot permit autonomous hedge execution or cash sweeps without dual-control sign-off, rationale capture, and formula-safe board exports.
The Deterministic Architecture That Fixes It
Our reference architecture separates deterministic treasury computation from optional narrative summarization inside a private FastAPI and SQLite stack configured with WAL journaling and BEGIN IMMEDIATE write serialization:
- Multi-bank ingestion with automatic file expiry:
POST /api/treasury/positionsparses SWIFT MT940, BAI2, normalized CSV, and structured JSON across operating, payroll, and sweep buckets, converting balances into the active base currency while preserving trapped-cash tags. Multipart uploads are stored with SHA-256 checksums and purged automatically after a 1-hour (3600s) TTL via both a background lifespan task and opportunistic request-path cleanup. - Deterministic 13-week direct forecasting:
POST /api/treasury/forecast-13wmodels weekly opening cash, shifted AR inflows, AP/payroll outflows, and minimum liquidity covenant floors. Treasury teams can stress-test AR collection delays (0–21 days), statutory payroll/VAT spikes, and top-customer concentration holds, flagging tight-buffer and breach weeks deterministically in SQLite. - FX exposure matrix and correlated 95% VaR:
POST /api/fx/hedge-simulatenets 90-day receivables against payables across non-base currencies, evaluates target forward-hedge coverage ratios from 0% to 100%, and computes P&L sensitivity across-10%,-5%,0%,+5%, and+10%parallel spot shocks alongside a diversified 95% parametric FX VaR. - Atomic human-in-the-loop sign-off gates: Every FX hedge proposal enters a
pending_approvalstate enforced byPOST /api/fx/hedge-proposals/{proposal_id}/decide, requiring an explicitfx:approvescope, verification checkbox, and rationale while rejecting duplicate approvals with409 Conflict. Similarly, idle-cash allocation across 30-day/60-day T-bills and 90-day institutional MMFs above an overnight operating buffer requires CFO sign-off into the immutable audit log. - Zero-egress defaults and formula-safe exports: The LLM adapter defaults to
TREASURY_LLM_MODE=offlinewith zero external API keys, invite tokens store only SHA-256 hashes with sliding-window rate limits, andGET /api/treasury/liquidity-reportneutralizes CSV formula injection (=,+,-,@). The backend is verified across 20 automatedpytestcases covering ingestion, forecasting, VaR approval guards, auth, cleanup, and reporting.
Operational Takeaway
Corporate treasury automation succeeds when deterministic parsers, repeatable cash-flow stress engines, and atomic SQLite approval gates own every number—keeping raw bank feeds private, isolating trapped subsidiary cash, and ensuring no FX forward or sweep ladder executes without documented human sign-off.