Skip to main content

Module risk_account_builder

Module risk_account_builder 

Source
Expand description

Risk Account Builder - Assembles Portfolio Margin inputs.

This service provides a unified way to build PM snapshot inputs by combining:

  • BalanceProvider: Engine-owned runtime balances
  • PortfolioService: Executed positions with cost basis
  • OpenOrdersSource: Resting orders for PM calculations

Both UnifiedEngine (for order admission) and API handlers (for /risk/grid) use this builder, keeping UnifiedEngine out of the API hot path.

Structsยง

RiskAccountBuilder
RiskAccountBuilder assembles PM inputs from balances, positions, and open orders.

Enumsยง

RiskError
Error type for risk account building.
SnapshotMode ๐Ÿ”’

Traitsยง

OpenOrdersSource
Source for open orders. Implemented by SnapshotOpenOrdersSource.
SpotPriceSource
Source for spot prices. Implemented by GreeksCache.

Functionsยง

decimal_from_f64 ๐Ÿ”’
executed_perp_underlying ๐Ÿ”’
new_underlying_snapshot ๐Ÿ”’
open_order_perp_underlying ๐Ÿ”’
parse_executed_option_symbol ๐Ÿ”’
parse_open_order_option_symbol ๐Ÿ”’
validated_expiry_ts ๐Ÿ”’