Algorithmic Trading Platform

Architecture / Component

Overview

Performs pre-trade risk checks before orders are accepted and post-trade exposure checks after simulated executions. Enforces risk limits defined by risk officers.

Navigation

Design

Referenced By 1

Architecture

Documents

Risk Management Engine README document repo://graph/nodes/91273389b128443d47a091eda6a3e469/artifacts/risk-engine-readme.md

Risk Management Engine

Responsibilities

Runs pre-trade risk checks against every Signal before an order is placed.

  • Subscribes to Signal events; runs all registered IRiskCheck instances
  • Publishes RiskDecision (approved/rejected) and AuditEvent
  • Subscribes to Execution events to accumulate realized daily loss

Built-in Checks

Check Rule
PositionSizeCheck order_qty ≤ max_position_qty
OrderValueCheck order_qty × price ≤ max_order_value
DailyLossLimitCheck accumulated daily loss < max_daily_loss

IRiskCheck Protocol

class IRiskCheck(Protocol):
    @property
    def name(self) -> str: ...
    def evaluate(self, signal: Signal) -> tuple[bool, str]: ...

Interface

Method Description
add_check(check) Register a new IRiskCheck at runtime
remove_check(name) Remove a check by name
checks List of registered check names

Event Flow

Signal → RiskEngine → IRiskCheck.evaluate() × N → RiskDecision + AuditEvent
Execution → RiskEngine → accumulate daily loss

Source

src/components/risk_management_engine.py