Update data_manager.py
Browse files- data_manager.py +17 -3
data_manager.py
CHANGED
|
@@ -179,8 +179,21 @@ class DataManager:
|
|
| 179 |
try:
|
| 180 |
await asyncio.sleep(0.5)
|
| 181 |
url = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd"
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
response = await client.get(url, timeout=10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
response.raise_for_status()
|
| 185 |
data = response.json()
|
| 186 |
|
|
@@ -672,7 +685,7 @@ class DataManager:
|
|
| 672 |
|
| 673 |
# تحسين: قبول البيانات حتى لو كانت غير مكتملة
|
| 674 |
successful_timeframes = 0
|
| 675 |
-
min_required_timeframes =
|
| 676 |
|
| 677 |
# معالجة النتائج
|
| 678 |
for i, (timeframe, limit) in enumerate(timeframes):
|
|
@@ -698,6 +711,7 @@ class DataManager:
|
|
| 698 |
result_data = {
|
| 699 |
'symbol': symbol,
|
| 700 |
'ohlcv': ohlcv_data,
|
|
|
|
| 701 |
'current_price': current_price,
|
| 702 |
'timestamp': datetime.now().isoformat(),
|
| 703 |
'candles_count': {tf: len(data) for tf, data in ohlcv_data.items()},
|
|
@@ -830,4 +844,4 @@ class DataManager:
|
|
| 830 |
'source': 'whale_analysis'
|
| 831 |
}
|
| 832 |
|
| 833 |
-
print("✅ DataManager loaded - Parallel OHLCV Fetching System with Whale Data Support &
|
|
|
|
| 179 |
try:
|
| 180 |
await asyncio.sleep(0.5)
|
| 181 |
url = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd"
|
| 182 |
+
|
| 183 |
+
# إضافة headers لتجنب rate limiting
|
| 184 |
+
headers = {
|
| 185 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
| 186 |
+
'Accept': 'application/json'
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
async with httpx.AsyncClient(headers=headers) as client:
|
| 190 |
response = await client.get(url, timeout=10)
|
| 191 |
+
|
| 192 |
+
if response.status_code == 429:
|
| 193 |
+
print("⏰ Rate limit من CoinGecko - الانتظار 2 ثانية")
|
| 194 |
+
await asyncio.sleep(2)
|
| 195 |
+
response = await client.get(url, timeout=10)
|
| 196 |
+
|
| 197 |
response.raise_for_status()
|
| 198 |
data = response.json()
|
| 199 |
|
|
|
|
| 685 |
|
| 686 |
# تحسين: قبول البيانات حتى لو كانت غير مكتملة
|
| 687 |
successful_timeframes = 0
|
| 688 |
+
min_required_timeframes = 2 # تخفيف الشرط من 3 إلى 2 أطر زمنية
|
| 689 |
|
| 690 |
# معالجة النتائج
|
| 691 |
for i, (timeframe, limit) in enumerate(timeframes):
|
|
|
|
| 711 |
result_data = {
|
| 712 |
'symbol': symbol,
|
| 713 |
'ohlcv': ohlcv_data,
|
| 714 |
+
'raw_ohlcv': ohlcv_data, # ✅ إضافة البيانات الخام مباشرة
|
| 715 |
'current_price': current_price,
|
| 716 |
'timestamp': datetime.now().isoformat(),
|
| 717 |
'candles_count': {tf: len(data) for tf, data in ohlcv_data.items()},
|
|
|
|
| 844 |
'source': 'whale_analysis'
|
| 845 |
}
|
| 846 |
|
| 847 |
+
print("✅ DataManager loaded - Parallel OHLCV Fetching System with Whale Data Support & Improved Error Handling")
|