""" Delta-Neutral Maxi Harvests perpetual funding rates while staying delta-neutral. Holds spot exposure against an offsetting perp short, rebalancing whenever net delta drifts beyond a configurable band. Built for sideways markets where directional strategies bleed. Asset class : CRYPTO (native crypto assets on Robinhood Chain) Strategies : arbitrage, market making Published on Wakehood (https://wakehood.com), a decentralized index of AI trading agents on Robinhood Chain. This is a reference implementation. Wakehood stores and indexes this code; it does not execute it. Review any agent's code yourself before trusting it with capital. """ from __future__ import annotations from dataclasses import dataclass, field ASSET_CLASS = "CRYPTO" STRATEGY_TAGS = ["arbitrage","market making"] @dataclass class Position: symbol: str size: float # signed: positive is long, negative is short entry_price: float @dataclass class Decision: symbol: str target_weight: float # fraction of capital, in [-1, 1] reason: str @dataclass class DeltaNeutralMaxi: """Delta-Neutral Maxi — arbitrage, market making.""" max_gross_exposure: float = 1.0 rebalance_threshold: float = 0.05 positions: dict[str, Position] = field(default_factory=dict) def evaluate(self, market: dict) -> list[Decision]: """ Turn a snapshot of market state into target weights. `market` is expected to expose, per symbol, at least: price, and whatever signals this strategy needs (funding, spread, volatility, fundamentals, ...). The concrete feeds are intentionally left to the operator; this skeleton documents the decision logic, not the data plumbing. """ decisions: list[Decision] = [] for symbol, state in market.items(): edge = self._edge(symbol, state) if abs(edge) < self.rebalance_threshold: continue decisions.append( Decision(symbol=symbol, target_weight=self._size(edge), reason=self._why(edge)) ) return decisions def _edge(self, symbol: str, state: dict) -> float: """ The core alpha. For "arbitrage, market making", this is where the signal is computed: the sign is the direction, the magnitude is the conviction. Returns a value the sizer maps to a weight. """ raise NotImplementedError("Implement the arbitrage signal for this market.") def _size(self, edge: float) -> float: weight = max(-1.0, min(1.0, edge)) return weight * self.max_gross_exposure def _why(self, edge: float) -> str: direction = "long" if edge > 0 else "short" return f"arbitrage edge {edge:+.3f} -> {direction}"