72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Dict, List, Optional
|
|
from dataclasses import dataclass
|
|
import time
|
|
|
|
"""Core domain primitives for DeltaForge MVP.
|
|
|
|
- Asset: canonical representation of a tradable instrument (equity/option/etc).
|
|
- MarketSignal: market data snapshot for an asset.
|
|
- StrategyDelta: local hedge decision/delta for an asset.
|
|
- PlanDelta: a collection of StrategyDelta objects, annotated with venue/author info.
|
|
"""
|
|
|
|
|
|
@dataclass
|
|
class Asset:
|
|
type: str
|
|
symbol: Optional[str] = None
|
|
underlying: Optional[str] = None
|
|
strike: Optional[float] = None
|
|
expires: Optional[str] = None
|
|
|
|
|
|
@dataclass
|
|
class MarketSignal:
|
|
asset: Asset
|
|
price: float
|
|
volatility: float
|
|
liquidity: float
|
|
timestamp: float
|
|
|
|
|
|
@dataclass
|
|
class StrategyDelta:
|
|
asset: Asset
|
|
delta: float
|
|
timestamp: float
|
|
|
|
|
|
@dataclass
|
|
class PlanDelta:
|
|
deltas: List[StrategyDelta]
|
|
venue: Optional[str] = None
|
|
author: str = ""
|
|
timestamp: float = 0.0
|
|
|
|
|
|
from .dsl import LocalArbProblem, SharedSignals # kept for potential internal use
|
|
|
|
|
|
class ADMMCoordinator:
|
|
"""Tiny ADMM-inspired coordinator stub for cross-venue coherence.
|
|
|
|
It returns a minimal PlanDelta reflecting the input local arb problems.
|
|
"""
|
|
|
|
def coordinate(self, problems: Dict[str, LocalArbProblem], signals: SharedSignals) -> PlanDelta:
|
|
# Create a trivial delta list that represents no changes yet but records activity
|
|
# This maintains compatibility with the PlanDelta dataclass defined above.
|
|
deltas: List[StrategyDelta] = []
|
|
# Build a no-op delta for each asset referenced in problems
|
|
for p in problems.values():
|
|
for asset in p.assets:
|
|
# We synthesize an Asset from the string; keep minimal fields
|
|
a = Asset(type="unknown", symbol=asset)
|
|
deltas.append(StrategyDelta(asset=a, delta=0.0, timestamp=time.time()))
|
|
return PlanDelta(deltas=deltas, venue="coordinator", author="ADMM", timestamp=time.time())
|
|
|
|
|
|
__all__ = ["ADMMCoordinator"]
|