Spaces:
Sleeping
Sleeping
Update ml_engine/sniper_engine.py
Browse files- ml_engine/sniper_engine.py +14 -11
ml_engine/sniper_engine.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# ============================================================
|
| 2 |
-
# 🎯 ml_engine/sniper_engine.py (V1.
|
| 3 |
# ============================================================
|
| 4 |
|
| 5 |
import os
|
|
@@ -102,7 +102,7 @@ def _add_standard_features(df):
|
|
| 102 |
return df_feat
|
| 103 |
|
| 104 |
# ============================================================
|
| 105 |
-
# 🎯 2. كلاس المحرك الرئيسي (SniperEngine V1.
|
| 106 |
# ============================================================
|
| 107 |
|
| 108 |
class SniperEngine:
|
|
@@ -116,17 +116,23 @@ class SniperEngine:
|
|
| 116 |
self.entry_threshold = 0.40
|
| 117 |
self.wall_ratio_limit = 0.40 # نسبة الفيتو لجدار البيع
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
self.initialized = False
|
| 120 |
self.LOOKBACK_WINDOW = LOOKBACK_WINDOW
|
| 121 |
self.ORDER_BOOK_DEPTH = 20
|
| 122 |
|
| 123 |
-
print("🎯 [SniperEngine V1.
|
| 124 |
|
| 125 |
-
# ✅ دالة تكوين شاملة
|
| 126 |
-
def configure_settings(self, threshold: float, wall_ratio: float):
|
| 127 |
self.entry_threshold = threshold
|
| 128 |
self.wall_ratio_limit = wall_ratio
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
|
| 131 |
# (إبقاء هذه للدعم القديم إذا لزم الأمر، لكن configure_settings أفضل)
|
| 132 |
def set_entry_threshold(self, new_threshold: float):
|
|
@@ -243,11 +249,8 @@ class SniperEngine:
|
|
| 243 |
if order_book_data:
|
| 244 |
ob_data = self._score_order_book(order_book_data)
|
| 245 |
|
| 246 |
-
#
|
| 247 |
-
|
| 248 |
-
weight_ob = 0.40
|
| 249 |
-
|
| 250 |
-
final_score = (ml_score * weight_ml) + (ob_data['score'] * weight_ob)
|
| 251 |
|
| 252 |
signal = 'WAIT'
|
| 253 |
reason_str = f"Final:{final_score:.2f} (ML:{ml_score:.2f} + OB:{ob_data['score']:.2f})"
|
|
|
|
| 1 |
# ============================================================
|
| 2 |
+
# 🎯 ml_engine/sniper_engine.py (V1.8 - Fully Configurable)
|
| 3 |
# ============================================================
|
| 4 |
|
| 5 |
import os
|
|
|
|
| 102 |
return df_feat
|
| 103 |
|
| 104 |
# ============================================================
|
| 105 |
+
# 🎯 2. كلاس المحرك الرئيسي (SniperEngine V1.8)
|
| 106 |
# ============================================================
|
| 107 |
|
| 108 |
class SniperEngine:
|
|
|
|
| 116 |
self.entry_threshold = 0.40
|
| 117 |
self.wall_ratio_limit = 0.40 # نسبة الفيتو لجدار البيع
|
| 118 |
|
| 119 |
+
# ✅ إضافة متغيرات للأوزان (قابلة للتكوين)
|
| 120 |
+
self.weight_ml = 0.60
|
| 121 |
+
self.weight_ob = 0.40
|
| 122 |
+
|
| 123 |
self.initialized = False
|
| 124 |
self.LOOKBACK_WINDOW = LOOKBACK_WINDOW
|
| 125 |
self.ORDER_BOOK_DEPTH = 20
|
| 126 |
|
| 127 |
+
print("🎯 [SniperEngine V1.8] Created.")
|
| 128 |
|
| 129 |
+
# ✅ دالة تكوين شاملة (محدثة لاستقبال الأوزان)
|
| 130 |
+
def configure_settings(self, threshold: float, wall_ratio: float, w_ml: float = 0.60, w_ob: float = 0.40):
|
| 131 |
self.entry_threshold = threshold
|
| 132 |
self.wall_ratio_limit = wall_ratio
|
| 133 |
+
self.weight_ml = w_ml
|
| 134 |
+
self.weight_ob = w_ob
|
| 135 |
+
# print(f"🔧 [Sniper] Configured: Threshold={self.entry_threshold}, WallVeto={self.wall_ratio_limit}, W_ML={self.weight_ml}")
|
| 136 |
|
| 137 |
# (إبقاء هذه للدعم القديم إذا لزم الأمر، لكن configure_settings أفضل)
|
| 138 |
def set_entry_threshold(self, new_threshold: float):
|
|
|
|
| 249 |
if order_book_data:
|
| 250 |
ob_data = self._score_order_book(order_book_data)
|
| 251 |
|
| 252 |
+
# ✅ استخدام الأوزان المحقونة (Dynamic Weights)
|
| 253 |
+
final_score = (ml_score * self.weight_ml) + (ob_data['score'] * self.weight_ob)
|
|
|
|
|
|
|
|
|
|
| 254 |
|
| 255 |
signal = 'WAIT'
|
| 256 |
reason_str = f"Final:{final_score:.2f} (ML:{ml_score:.2f} + OB:{ob_data['score']:.2f})"
|