78 lines
1.6 KiB
Python
78 lines
1.6 KiB
Python
from __future__ import annotations
|
|
from dataclasses import dataclass, asdict
|
|
from typing import Optional
|
|
import json
|
|
|
|
|
|
@dataclass
|
|
class LocalTrade:
|
|
trade_id: str
|
|
product_id: str
|
|
venue: str
|
|
price: float
|
|
size: int
|
|
side: str # 'buy' or 'sell'
|
|
timestamp: float
|
|
signer_id: str
|
|
signature: str
|
|
|
|
def to_json(self) -> str:
|
|
return json.dumps(asdict(self), sort_keys=True)
|
|
|
|
|
|
@dataclass
|
|
class SharedSignals:
|
|
signals_version: int
|
|
aggregated_risk: float # placeholder for aggregated risk metric
|
|
margin_impact: float
|
|
liquidity_metric: float
|
|
|
|
def to_json(self) -> str:
|
|
return json.dumps(asdict(self), sort_keys=True)
|
|
|
|
|
|
@dataclass
|
|
class PlanDelta:
|
|
delta_version: int
|
|
timestamp: float
|
|
allocations: dict # mapping from trade_id to new allocation
|
|
cryptographic_tag: str
|
|
|
|
def to_json(self) -> str:
|
|
return json.dumps(asdict(self), sort_keys=True)
|
|
|
|
|
|
@dataclass
|
|
class PrivacyBudget:
|
|
budget_id: str
|
|
max_privacy_leakage: float
|
|
spent_privacy: float
|
|
|
|
def to_json(self) -> str:
|
|
return json.dumps(asdict(self), sort_keys=True)
|
|
|
|
|
|
@dataclass
|
|
class AuditLog:
|
|
event_id: str
|
|
timestamp: float
|
|
actor: str
|
|
action: str
|
|
details: Optional[str] = None
|
|
|
|
def to_json(self) -> str:
|
|
return json.dumps(asdict(self), sort_keys=True)
|
|
|
|
|
|
@dataclass
|
|
class ComplianceEvent:
|
|
event_id: str
|
|
venue: str
|
|
constraint: str
|
|
violated: bool
|
|
timestamp: float
|
|
details: Optional[str] = None
|
|
|
|
def to_json(self) -> str:
|
|
return json.dumps(asdict(self), sort_keys=True)
|