from __future__ import annotations from dataclasses import dataclass from typing import List, Optional @dataclass class Asset: """Canonical asset representation. Example: {"type": "equity", "symbol": "AAPL"} or {"type": "option", "underlying": "AAPL", "strike": 150, "expires": "2026-12-17"} """ type: str # 'equity', 'option', 'future' symbol: Optional[str] = None underlying: Optional[str] = None strike: Optional[float] = None expires: Optional[str] = None def canonical_id(self) -> str: if self.type == "equity": return f"EQ:{self.symbol}" if self.type == "option": return f"OP:{self.underlying}:{self.strike}:{self.expires}" if self.type == "future": return f"FU:{self.symbol or self.underlying}:{self.expires}" return f"UNK:{self.symbol or 'UNDEF'}" @dataclass class MarketSignal: """Lightweight market signal used by adapters to convey prices, liquidity, etc.""" asset: Asset price: float volatility: float = 0.0 liquidity: float = 1.0 timestamp: float = 0.0 @dataclass class StrategyDelta: """Local decision block; describes intent to adjust hedges for an asset. This is a light DSL-like structure that adapters translate into venue orders. """ asset: Asset delta: float # directional hedge to apply (positive means buy delta exposure, etc.) vega: float = 0.0 gamma: float = 0.0 target_pnl: Optional[float] = None max_order_size: float = 1.0 timestamp: float = 0.0 @dataclass class PlanDelta: """Incremental hedges/adjustments with metadata for auditability.""" deltas: List[StrategyDelta] confidence: float = 1.0 venue: Optional[str] = None author: str = "system" timestamp: float = 0.0 signature: Optional[str] = None # placeholder for cryptographic tag