Hi!
Skip to main content
Back

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.

MTM VALUATION PIPELINEDATA SOURCESFX Rate FeedsMarket DataPosition DataHistoricalINGESTION LAYERData ConnectorValidationNormalizationSnapshotVALUATION ENGINECalculation Orchestrator (Idempotent)FX MTM CalcFIFO MatcherCross-RateP&L EngineOUTPUT LAYERP&L ReportsDashboardAudit TrailAlertsDeterministicIdempotentAuditableRecalculable

Component Architecture

Layered architecture with dedicated services for rates, valuation, reporting, and audit. Multi-database design integrates with legacy systems without disruption.

MTM COMPONENT ARCHITECTUREPRESENTATION (Next.js)DashboardPositionP&LAuditAdminAPI GATEWAYAuthRate LimitValidateVersionLoggingSERVICE LAYER (Node.js)Rate ServiceFetch • Cache • HistoryValuation ServiceMTM • FIFO • P&LReport ServicePDF • Excel • ExportAudit ServiceSchedule ServiceAlert ServiceREDISSession • Queue • Pub/SubRate CacheCalc CacheDATA LAYER (Multi-Database)PostgreSQLMTM Results • AuditSQL ServerPosition • TradesOracleCore BankingDockerTypeScriptPM2Nginx

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.