Riy777 commited on
Commit
9111e39
·
verified ·
1 Parent(s): fe46c94

Auto-Fix by Architect: Auto-Fix: ASSIGN_ARCHITECT | Quant Silence indicates a failure in automated analysis generation, suggesting a potential code bug or technical issue requiring Python code fixes to resolve. by Agent Architect

Browse files
Files changed (1) hide show
  1. ml_engine/sniper_engine.py +5 -6
ml_engine/sniper_engine.py CHANGED
@@ -28,10 +28,9 @@ def _z_score_rolling(x, w=500):
28
  def _add_liquidity_proxies(df):
29
  """حساب مؤشرات السيولة المتقدمة (Amihud, VPIN, OFI, etc.)"""
30
  df_proxy = df.copy()
31
- if 'datetime' not in df_proxy.index:
32
- if 'timestamp' in df_proxy.columns:
33
- df_proxy['datetime'] = pd.to_datetime(df_proxy['timestamp'], unit='ms')
34
- df_proxy = df_proxy.set_index('datetime')
35
 
36
  df_proxy['ret'] = df_proxy['close'].pct_change().fillna(0)
37
  df_proxy['dollar_vol'] = df_proxy['close'] * df_proxy['volume']
@@ -69,7 +68,7 @@ def _add_liquidity_proxies(df):
69
  # Composite Liquidity Score
70
  df_proxy['L_score'] = (
71
  _z_score_rolling(df_proxy['volume']) +
72
- _z_score_rolling(1 / df_proxy['amihud'].replace(np.inf, np.nan)) +
73
  _z_score_rolling(-df_proxy['roll_spread']) +
74
  _z_score_rolling(-df_proxy['rv_gk'].abs()) +
75
  _z_score_rolling(-df_proxy['vwap_dev'].abs()) +
@@ -315,7 +314,7 @@ class SniperEngine:
315
  df_features = self._calculate_features_live(df)
316
  if not df_features.empty:
317
  X_live = df_features.iloc[-1:][self.feature_names].fillna(0)
318
- preds = [m.predict(X_live)[0][1] for m in self.models]
319
  ml_score = float(np.mean(preds))
320
  ml_reason = f"ML:{ml_score:.2f}"
321
  except Exception as e:
 
28
  def _add_liquidity_proxies(df):
29
  """حساب مؤشرات السيولة المتقدمة (Amihud, VPIN, OFI, etc.)"""
30
  df_proxy = df.copy()
31
+ if 'datetime' not in df_proxy.index.names and 'timestamp' in df_proxy.columns:
32
+ df_proxy['datetime'] = pd.to_datetime(df_proxy['timestamp'], unit='ms')
33
+ df_proxy = df_proxy.set_index('datetime')
 
34
 
35
  df_proxy['ret'] = df_proxy['close'].pct_change().fillna(0)
36
  df_proxy['dollar_vol'] = df_proxy['close'] * df_proxy['volume']
 
68
  # Composite Liquidity Score
69
  df_proxy['L_score'] = (
70
  _z_score_rolling(df_proxy['volume']) +
71
+ _z_score_rolling(1 / df_proxy['amihud'].replace([np.inf, -np.inf], np.nan)) +
72
  _z_score_rolling(-df_proxy['roll_spread']) +
73
  _z_score_rolling(-df_proxy['rv_gk'].abs()) +
74
  _z_score_rolling(-df_proxy['vwap_dev'].abs()) +
 
314
  df_features = self._calculate_features_live(df)
315
  if not df_features.empty:
316
  X_live = df_features.iloc[-1:][self.feature_names].fillna(0)
317
+ preds = [m.predict(X_live)[0] for m in self.models] # Fixed indexing for prediction output
318
  ml_score = float(np.mean(preds))
319
  ml_reason = f"ML:{ml_score:.2f}"
320
  except Exception as e: