GenServer callbacks for portfolio state management.
Not called directly — use RiskEngine.Portfolio's client API instead.
Each server owns the state for a single portfolio: its trade history,
running cash exposure, and the derived risk metrics (volatility and
drawdown) recomputed by RiskEngine.RiskCalculator after every trade.
Updates are published via RiskEngine.RiskBroadcaster.
Summary
Functions
Returns a specification to start this module under a supervisor.
Types
@type t() :: %{ id: String.t(), trades: [RiskEngine.TradeIngestion.trade()], cash_exposure: float(), peak_exposure: float(), volatility: float(), drawdown_pct: float(), updated_at: DateTime.t() | nil }
A portfolio's state.
:id— the portfolio id.:trades— trades applied so far, most recent first.:cash_exposure— signed net exposure (buys add, sells subtract).:peak_exposure— the highest absolute exposure ever observed; only ever grows, and is the reference point for:drawdown_pct.:volatility— standard deviation of recent signed trade notionals, seeRiskEngine.RiskCalculator.volatility/1.:drawdown_pct— percentage pullback from:peak_exposure, seeRiskEngine.RiskCalculator.drawdown/2.:updated_at— timestamp of the last processed trade, ornilif no trade has been submitted yet.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.