Riy777 commited on
Commit
77ebc20
·
verified ·
1 Parent(s): c7a2c30

Update learning_hub/adaptive_hub.py

Browse files
Files changed (1) hide show
  1. learning_hub/adaptive_hub.py +35 -4
learning_hub/adaptive_hub.py CHANGED
@@ -1,6 +1,6 @@
1
  # ==============================================================================
2
  # 🧠 learning_hub/adaptive_hub.py
3
- # (V60.1 - GEM-Architect: Golden Values + Full Sync)
4
  # ==============================================================================
5
 
6
  import json
@@ -76,10 +76,10 @@ class StrategyDNA:
76
  class AdaptiveHub:
77
  def __init__(self, r2_service=None):
78
  self.r2 = r2_service
79
- self.dna_file_key = "learning/strategic_dna_v60_layered.json"
80
  self.current_market_regime = "RANGE"
81
  self.strategies: Dict[str, StrategyDNA] = {}
82
- print("🧠 [AdaptiveHub V60.1] Golden DNA Injection Active.")
83
 
84
  def get_learning_progress(self) -> str:
85
  """يعيد نسبة التقدم في التعلم السريع"""
@@ -125,7 +125,7 @@ class AdaptiveHub:
125
 
126
  # 2. BEAR MARKET (Golden Config)
127
  d_guards_bear = {"hydra_crash": 0.60, "hydra_giveback": 0.60, "legacy_v2": 0.85}
128
- d_filters_bear = {"l1_min_score": 0.60, "l3_oracle_thresh": 0.75, "l4_sniper_thresh": 0.30} # Sniper lower
129
 
130
  self.strategies["BEAR"] = StrategyDNA(
131
  "BEAR",
@@ -172,6 +172,36 @@ class AdaptiveHub:
172
  self.strategies[key] = dna
173
  self.current_market_regime = data.get("current_regime", "RANGE")
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  # ============================================================
176
  # 🧪 STRATEGIC BACKTEST LINK (Base Updater)
177
  # ============================================================
@@ -275,6 +305,7 @@ class AdaptiveHub:
275
  # 💉 INJECTION
276
  # ============================================================
277
  def _inject_current_parameters(self):
 
278
  if self.current_market_regime not in self.strategies or SystemLimits is None: return
279
  dna = self.strategies[self.current_market_regime]
280
 
 
1
  # ==============================================================================
2
  # 🧠 learning_hub/adaptive_hub.py
3
+ # (V61.0 - GEM-Architect: Per-Asset Context Injection)
4
  # ==============================================================================
5
 
6
  import json
 
76
  class AdaptiveHub:
77
  def __init__(self, r2_service=None):
78
  self.r2 = r2_service
79
+ self.dna_file_key = "learning/strategic_dna_v61_context.json"
80
  self.current_market_regime = "RANGE"
81
  self.strategies: Dict[str, StrategyDNA] = {}
82
+ print("🧠 [AdaptiveHub V61.0] Per-Asset Context Engine Ready.")
83
 
84
  def get_learning_progress(self) -> str:
85
  """يعيد نسبة التقدم في التعلم السريع"""
 
125
 
126
  # 2. BEAR MARKET (Golden Config)
127
  d_guards_bear = {"hydra_crash": 0.60, "hydra_giveback": 0.60, "legacy_v2": 0.85}
128
+ d_filters_bear = {"l1_min_score": 0.60, "l3_oracle_thresh": 0.75, "l4_sniper_thresh": 0.30}
129
 
130
  self.strategies["BEAR"] = StrategyDNA(
131
  "BEAR",
 
172
  self.strategies[key] = dna
173
  self.current_market_regime = data.get("current_regime", "RANGE")
174
 
175
+ # ============================================================
176
+ # 🧬 CONTEXT API (Per-Asset Injection)
177
+ # ============================================================
178
+ def get_regime_config(self, regime_name: str) -> Dict[str, Any]:
179
+ """
180
+ 💎 Returns the specific configuration (DNA) for a given market regime.
181
+ Used to inject 'Per-Asset' limits dynamically.
182
+ """
183
+ target_regime = regime_name if regime_name in self.strategies else "RANGE"
184
+ dna = self.strategies[target_regime]
185
+ filters = dna.get_final_filters()
186
+ guards = dna.get_final_guards()
187
+ mw = dna.model_weights
188
+
189
+ return {
190
+ "regime": target_regime,
191
+ # Layer 2 Weights
192
+ "w_titan": mw.get("titan", 0.4),
193
+ "w_patt": mw.get("structure", 0.3),
194
+ # Layer 3 & 4 Thresholds
195
+ "l1_min_score": filters.get("l1_min_score", 0.65),
196
+ "l3_oracle_thresh": filters.get("l3_oracle_thresh", 0.65),
197
+ "l4_sniper_thresh": filters.get("l4_sniper_thresh", 0.40),
198
+ "l4_ob_wall_ratio": dna.ob_settings.get("wall_ratio_limit", 0.4),
199
+ # Guard Thresholds
200
+ "hydra_crash": guards.get('hydra_crash', 0.85),
201
+ "hydra_giveback": guards.get('hydra_giveback', 0.70),
202
+ "legacy_v2": guards.get('legacy_v2', 0.95)
203
+ }
204
+
205
  # ============================================================
206
  # 🧪 STRATEGIC BACKTEST LINK (Base Updater)
207
  # ============================================================
 
305
  # 💉 INJECTION
306
  # ============================================================
307
  def _inject_current_parameters(self):
308
+ """Injects Global Fallback Parameters"""
309
  if self.current_market_regime not in self.strategies or SystemLimits is None: return
310
  dna = self.strategies[self.current_market_regime]
311