Răsfoiți Sursa

Extend strategy supervision contract

Lukas Goldschmidt 3 săptămâni în urmă
părinte
comite
1e4324f2e8

+ 22 - 0
src/trader_mcp/strategy_sdk.py

@@ -16,6 +16,16 @@ class Strategy:
         "avoids": {},
         "risk_profile": "unknown",
         "capabilities": [],
+        # These fields are the minimum contract Hermes needs for safe strategy
+        # supervision and switching. They describe how a strategy behaves with
+        # inventory, whether rebalancing is needed around lifecycle transitions,
+        # and whether the strategy can coexist with companions.
+        "role": "primary",
+        "inventory_behavior": "unknown",
+        "requires_rebalance_before_start": False,
+        "requires_rebalance_before_stop": False,
+        "safe_when_unbalanced": True,
+        "can_run_with": [],
     }
     TICK_MINUTES: float = 1.0
 
@@ -97,6 +107,18 @@ class Strategy:
                 "execution_quality": None,
                 "stress": None,
             },
+            # Hermes-facing supervision hints. Individual strategies can fill
+            # these out more precisely over time, but the normalized shape stays
+            # stable for the decision layer.
+            "supervision": {
+                "health": "unknown",
+                "degraded": False,
+                "inventory_pressure": "unknown",
+                "capacity_available": None,
+                "switch_readiness": "unknown",
+                "last_reason": None,
+                "desired_companion": None,
+            },
         }
 
     def render(self):

+ 6 - 0
strategies/exposure_protector.py

@@ -23,6 +23,12 @@ class Strategy(Strategy):
         },
         "risk_profile": "defensive",
         "capabilities": ["exposure_trim", "trail_protection", "balance_recovery"],
+        "role": "defensive",
+        "inventory_behavior": "rebalancing",
+        "requires_rebalance_before_start": False,
+        "requires_rebalance_before_stop": False,
+        "safe_when_unbalanced": True,
+        "can_run_with": ["grid_trader", "trend_follower"],
     }
     TICK_MINUTES = 0.2
     CONFIG_SCHEMA = {

+ 6 - 0
strategies/grid_trader.py

@@ -24,6 +24,12 @@ class Strategy(Strategy):
         },
         "risk_profile": "medium",
         "capabilities": ["structure_harvesting", "range_making", "liquidity_harvesting"],
+        "role": "primary",
+        "inventory_behavior": "balanced",
+        "requires_rebalance_before_start": False,
+        "requires_rebalance_before_stop": False,
+        "safe_when_unbalanced": False,
+        "can_run_with": ["exposure_protector"],
     }
     TICK_MINUTES = 0.50
     CONFIG_SCHEMA = {

+ 6 - 0
strategies/trend_follower.py

@@ -23,6 +23,12 @@ class Strategy(Strategy):
         },
         "risk_profile": "growth",
         "capabilities": ["trend_capture", "momentum_following", "position_persistence"],
+        "role": "primary",
+        "inventory_behavior": "accumulative_long",
+        "requires_rebalance_before_start": False,
+        "requires_rebalance_before_stop": False,
+        "safe_when_unbalanced": True,
+        "can_run_with": ["exposure_protector"],
     }
     TICK_MINUTES = 0.5
     CONFIG_SCHEMA = {