86 lines
2.0 KiB
Python
86 lines
2.0 KiB
Python
"""Core data contracts for BeVault MVP (toy DSL seeds)."""
|
|
from __future__ import annotations
|
|
from dataclasses import dataclass, field
|
|
from typing import List, Optional
|
|
import time
|
|
|
|
|
|
@dataclass
|
|
class LocalArbProblem:
|
|
asset: str
|
|
objective: str # e.g., 'min_cost', 'maximize_profit'
|
|
risk_budget: float
|
|
constraints: dict = field(default_factory=dict)
|
|
|
|
|
|
@dataclass
|
|
class SharedSignals:
|
|
asset: str
|
|
price: float
|
|
latency_ms: float
|
|
timestamp: float = field(default_factory=lambda: time.time())
|
|
metadata: dict = field(default_factory=dict)
|
|
|
|
|
|
@dataclass
|
|
class HedgeDelta:
|
|
asset: str
|
|
hedge_size: float
|
|
timestamp: float = field(default_factory=lambda: time.time())
|
|
policy_tag: str = "default"
|
|
signature: Optional[str] = None
|
|
|
|
|
|
@dataclass
|
|
class AuditLog:
|
|
events: List[str] = field(default_factory=list)
|
|
entry_ts: float = field(default_factory=lambda: time.time())
|
|
|
|
|
|
@dataclass
|
|
class PrivacyBudget:
|
|
asset: str
|
|
remaining: float
|
|
reset_epoch: float = field(default_factory=lambda: time.time())
|
|
|
|
|
|
__all__ = [
|
|
"LocalArbProblem",
|
|
"SharedSignals",
|
|
"HedgeDelta",
|
|
"AuditLog",
|
|
"PrivacyBudget",
|
|
# Toy DSL seed helper (MVP utility)
|
|
"generate_toy_seed",
|
|
]
|
|
|
|
|
|
def generate_toy_seed(asset: str = "AAPL", price: float = 100.0):
|
|
"""Generate a minimal toy DSL seed pair for MVP testing.
|
|
|
|
Returns a tuple of (LocalArbProblem, SharedSignals) suitable for
|
|
driving a toy cross-venue hedge scenario and deterministic delta-sync
|
|
tests without requiring real market data.
|
|
|
|
This helper is intentionally lightweight and is meant for local testing
|
|
and documentation purposes within the MVP boundaries.
|
|
"""
|
|
from time import time
|
|
|
|
local = LocalArbProblem(
|
|
asset=asset,
|
|
objective="min_cost",
|
|
risk_budget=float(price) * 0.1,
|
|
constraints={},
|
|
)
|
|
|
|
signals = SharedSignals(
|
|
asset=asset,
|
|
price=price,
|
|
latency_ms=0.5,
|
|
timestamp=time(),
|
|
metadata={"toy_seed": True},
|
|
)
|
|
|
|
return local, signals
|