KatInterview

Design a Bitemporal Compliance Engine for Securities Trading

System DesignModel answer
HardModel answerSystem Designsystem designbitemporaldata modeling

Last updated

Design a bitemporal data model and low-latency system architecture to track effective-dated trading compliance rules and dynamic security identifier resolutions.

In modern financial markets, regulatory bodies and internal risk control teams regularly institute trading restrictions (such as full trading bans, pre-approval requirements, or short-sale blocks). Enforcing these restrictions is complicated by two facts:

  1. Business rules have complex valid dates (including retroactive applications and future-dated policies).
  2. Securities regularly undergo identifier changes (such as symbol/ticker changes, venue transfers, ISIN updates, or corporate restructuring), meaning human-readable tickers cannot serve as static keys.

Design a scalable system architecture and bitemporal data layer to store, manage, and query trading compliance restrictions.

System Requirements

  1. Bitemporal Data Architecture: The data model must track both Valid Time (when a restriction or identifier mapping is active in the business world) and System Time (when the database recorded that knowledge). The system must support retroactive entries while maintaining complete, point-in-time auditability.
  2. Identifier Resolution: Resolve market identifiers (e.g., Ticker XYZ on exchange XNYS) to the underlying permanent entity as of any historical date. Explain how your schema handles ticker reuse across different time windows and execution venues without introducing look-ahead bias.
  3. Multi-Layered Rule Resolution: Multiple active restrictions might apply simultaneously to the same asset (e.g., an internal policy, a country-level regulatory ban, and an account-level lock). Define deterministic precedence and conflict-resolution rules across overlapping policies.
  4. Pre-Trade High Throughput & Auditability: The engine must serve real-time pre-trade validation checks during market peak hours while guaranteeing point-in-time snapshot checks ($as_of$) for regulatory audits.

Scope & Constraints

  • Security Universe: ~100,000 active securities; historical mapping table will contain several million rows.
  • Write Volume: ~500 rule adjustments/ingestions per day by compliance officers.
  • Read Latency & Throughput: Peak load of 25,000 pre-trade check requests/sec with a $p99 \le 5\text{ ms}$.
  • Safety: Fail-closed semantics for invalid, ambiguous, or unresolvable identifiers.

Hints

Hint 1

Model two distinct time dimensions on every record: Valid Time (valid_from, valid_to) for real-world application and System Time (sys_from, sys_to) for database record ingestion history.

Hint 2

Never attach compliance rules directly to temporary identifiers like tickers; map tickers to an immutable internal surrogate key (sec_id) valid for a specific date range.

Hint 3

To maintain p99 < 5ms under heavy read traffic, separate the relational database of record from an in-memory evaluation cache refreshed via an event-driven change-data-capture stream.