diff --git a/deltaforge_mvp/coordination.py b/deltaforge_mvp/coordination.py index 5ac1e97..4e52375 100644 --- a/deltaforge_mvp/coordination.py +++ b/deltaforge_mvp/coordination.py @@ -26,6 +26,28 @@ class CentralCurator: merged = [] for p in plans: merged.extend(p.deltas) + + # ADMM-lite balancing: attempt to enforce cross-venue coherence by + # driving the net delta toward zero. This is a lightweight, deterministic + # adjustment suitable for a toy MVP and deterministic replay. + if len(merged) > 0: + total = sum(d.delta for d in merged) + mean_adjust = total / len(merged) + # Create adjusted copies to avoid mutating existing deltas + adjusted = [] + for d in merged: + adj = StrategyDelta( + asset=d.asset, + delta=d.delta - mean_adjust, + vega=d.vega, + gamma=d.gamma, + target_pnl=d.target_pnl, + max_order_size=d.max_order_size, + timestamp=d.timestamp, + ) + adjusted.append(adj) + merged = adjusted + return PlanDelta(deltas=merged, venue=None, author="curator") def enforce_with_fallback(self, plans: List[PlanDelta], fallback: Optional["ShadowFallback"] = None) -> PlanDelta: diff --git a/dsl_sketch.md b/dsl_sketch.md new file mode 100644 index 0000000..9c7694b --- /dev/null +++ b/dsl_sketch.md @@ -0,0 +1,28 @@ +DSL Sketch: Core Primitives for DeltaForge MVP + +- Asset + - Canonical representation of tradable instruments. + - Fields: type (equity, option, future), symbol/underlying, strike, expires + - Methods: canonical_id() for stable identifiers + +- MarketSignal + - Encapsulates observable market data used by adapters to produce StrategyDelta inputs. + - Fields: asset (Asset), price, volatility, liquidity, timestamp + +- StrategyDelta + - Local hedge/trade intent for an asset; acts as a primitive building block for plans. + - Fields: asset, delta, vega, gamma, target_pnl, max_order_size, timestamp + +- PlanDelta + - Incremental set of StrategyDelta decisions for one or more venues. + - Fields: deltas (List[StrategyDelta]), confidence, venue, author, timestamp, signature + +- LocalProblem (concept, not yet implemented) +- SharedVariables (concept, not yet implemented) +- DualVariables (concept, not yet implemented) +- AuditLog (concept, not yet implemented) + +Notes +- The MVP uses a lightweight, in-process coordination between two venues. The DSL above is: + a) lightweight, self-describing, and easily serializable; b) designed so adapters can plug into it without deep coupling. +- This document is a living sketch; future iterations may formalize validation, schemas, and a small encoder/decoder for wire transport.