MTM Financial Module
Financial Systems · 2024
Context
Mark-to-Market valuation engine for financial positions. A core finance system, not a side feature—this handles daily valuation of positions and P&L calculations.
Problem
Manual valuation processes were slow and inconsistent. FX rate integration was fragmented. Recalculation for audit purposes required significant manual effort.
Constraints
- Deterministic calculation logic (same input = same output)
- Daily processing under strict time constraints
- Multiple data sources (FX rates, market data)
- Traceable outputs for audit and investigation
System Architecture
The MTM system is designed as a 4-stage pipeline with clear separation between data ingestion, validation, calculation, and output.
Component Architecture
Layered architecture with dedicated services for rates, valuation, reporting, and audit. Multi-database design integrates with legacy systems without disruption.
Key Architectural Decisions
1. Deterministic Calculation Logic
All calculations use snapshot data (point-in-time). No external calls during calculation phase. Floating-point operations use decimal precision library for financial accuracy.
2. Idempotent Processing
Each calculation run has unique ID. Results are upserted, not inserted. State machine tracks processing stages for safe re-runs and easy debugging.
3. Multi-Database Architecture
Database-per-domain pattern. PostgreSQL as primary for MTM results. SQL Server for legacy position data. Oracle for core banking connection. No disruption to existing systems.
Tech Stack
Next.js (Frontend), Node.js (Backend), PostgreSQL, SQL Server, Oracle, Redis, Docker containers.
Outcome
Improved valuation accuracy and consistency. Reduced manual recalculation effort. Supports finance and risk reporting workflows. Reliable daily processing under time constraints.
What I'd Improve Next
Would add real-time valuation capability for intraday positions. Consider streaming architecture for live market data.