/** * RiskEngine — pre-trade guardrails the agent must clear before an order * touches the exchange. Pure function style: the engine holds only config; * Portfolio state is passed in per call so the same engine is reusable. * * Guardrails enforced (MVP): * - Per-position cap (USD notional any single symbol may hold) * - Total exposure cap (sum of all open positions' notional) * - Cash sufficiency (can't buy what you can't pay for) * - Sell integrity handled by Portfolio itself (no open position → throws) * * Exit orders (sells of existing positions) bypass exposure caps — a paranoid * cap could otherwise trap the agent in a losing position it wants to exit. */ import type { Portfolio, Side } from './portfolio.js'; export interface RiskConfig { maxPositionUsd: number; maxTotalExposureUsd: number; } export interface OrderRequest { symbol: string; side: Side; qty: number; priceUsd: number; } export interface RiskDecision { allowed: boolean; reason?: string; } export declare class RiskEngine { private config; constructor(config: RiskConfig); check(portfolio: Portfolio, order: OrderRequest): RiskDecision; }