from __future__ import annotations from datetime import datetime from .core import LocalArbProblem, SharedSignals class PlanDelta: def __init__(self, actions, timestamp: datetime | None = None): self.actions = actions self.timestamp = timestamp or datetime.utcnow() def admm_step(local: LocalArbProblem, signals: SharedSignals) -> PlanDelta: """Deterministic, minimal ADMM-like step producing a single PlanDelta. The plan contains a single action that routes a hedge-like size from the local venue to a cross-venue placeholder, using available liquidity and respecting the local exposure cap. """ # Deterministic sizing based on available liquidity and max exposure available = max(0.0, float(signals.liquidity)) size = min(float(local.max_exposure), available * 0.5) action = { "venue_from": local.venue, "venue_to": "CROSS-VENUE", "instrument": local.asset_pair, "size": size, "time": datetime.utcnow().isoformat() + "Z", } return PlanDelta(actions=[action]) __all__ = ["PlanDelta", "admm_step"]