Riy777 commited on
Commit
7386311
·
1 Parent(s): 396f10a

Update data_manager.py

Browse files
Files changed (1) hide show
  1. data_manager.py +9 -9
data_manager.py CHANGED
@@ -45,7 +45,7 @@ class DataManager:
45
  return
46
 
47
  print("🔄 جلب أحدث بيانات الأسواق من KuCoin...")
48
- await asyncio.to_thread(self.exchange.load_markets)
49
  self.market_cache = self.exchange.markets
50
  self.last_market_load = datetime.now()
51
  print(f"✅ تم تحميل {len(self.market_cache)} سوق من KuCoin")
@@ -155,12 +155,12 @@ class DataManager:
155
  try:
156
  prices = {'bitcoin': None, 'ethereum': None}
157
 
158
- btc_ticker = await asyncio.to_thread(self.exchange.fetch_ticker, 'BTC/USDT')
159
  btc_price = float(btc_ticker.get('last', 0)) if btc_ticker.get('last') else None
160
  if btc_price and btc_price > 0:
161
  prices['bitcoin'] = btc_price
162
 
163
- eth_ticker = await asyncio.to_thread(self.exchange.fetch_ticker, 'ETH/USDT')
164
  eth_price = float(eth_ticker.get('last', 0)) if eth_ticker.get('last') else None
165
  if eth_price and eth_price > 0:
166
  prices['ethereum'] = eth_price
@@ -261,7 +261,7 @@ class DataManager:
261
  if not self.exchange:
262
  return []
263
 
264
- tickers = await asyncio.to_thread(self.exchange.fetch_tickers)
265
 
266
  volume_data = []
267
  processed = 0
@@ -390,7 +390,7 @@ class DataManager:
390
  async def _process_single_symbol(self, symbol: str) -> Dict[str, Any]:
391
  """معالجة رمز واحد لجلب بيانات الحجم"""
392
  try:
393
- ticker = await asyncio.to_thread(self.exchange.fetch_ticker, symbol)
394
  if not ticker:
395
  return None
396
 
@@ -448,7 +448,7 @@ class DataManager:
448
  async def _get_detailed_symbol_data(self, symbol: str) -> Dict[str, Any]:
449
  """جلب بيانات تفصيلية للرمز"""
450
  try:
451
- ticker = await asyncio.to_thread(self.exchange.fetch_ticker, symbol)
452
  if not ticker:
453
  return None
454
 
@@ -708,7 +708,7 @@ class DataManager:
708
 
709
  for attempt in range(max_retries):
710
  try:
711
- ohlcv_data = await asyncio.to_thread(self.exchange.fetch_ohlcv, symbol, timeframe, limit)
712
 
713
  if ohlcv_data and len(ohlcv_data) > 0:
714
  return ohlcv_data
@@ -728,8 +728,8 @@ class DataManager:
728
  print(f"❌ Exchange غير مهيأ لـ {symbol}")
729
  return None
730
 
731
- # ✅ الإصلاح: استخدام asyncio.to_thread لتشغيل fetch_ticker في thread منفصل
732
- ticker = await asyncio.to_thread(self.exchange.fetch_ticker, symbol)
733
 
734
  if not ticker:
735
  print(f"❌ لم يتم العثور على ticker لـ {symbol}")
 
45
  return
46
 
47
  print("🔄 جلب أحدث بيانات الأسواق من KuCoin...")
48
+ self.exchange.load_markets()
49
  self.market_cache = self.exchange.markets
50
  self.last_market_load = datetime.now()
51
  print(f"✅ تم تحميل {len(self.market_cache)} سوق من KuCoin")
 
155
  try:
156
  prices = {'bitcoin': None, 'ethereum': None}
157
 
158
+ btc_ticker = self.exchange.fetch_ticker('BTC/USDT')
159
  btc_price = float(btc_ticker.get('last', 0)) if btc_ticker.get('last') else None
160
  if btc_price and btc_price > 0:
161
  prices['bitcoin'] = btc_price
162
 
163
+ eth_ticker = self.exchange.fetch_ticker('ETH/USDT')
164
  eth_price = float(eth_ticker.get('last', 0)) if eth_ticker.get('last') else None
165
  if eth_price and eth_price > 0:
166
  prices['ethereum'] = eth_price
 
261
  if not self.exchange:
262
  return []
263
 
264
+ tickers = self.exchange.fetch_tickers()
265
 
266
  volume_data = []
267
  processed = 0
 
390
  async def _process_single_symbol(self, symbol: str) -> Dict[str, Any]:
391
  """معالجة رمز واحد لجلب بيانات الحجم"""
392
  try:
393
+ ticker = self.exchange.fetch_ticker(symbol)
394
  if not ticker:
395
  return None
396
 
 
448
  async def _get_detailed_symbol_data(self, symbol: str) -> Dict[str, Any]:
449
  """جلب بيانات تفصيلية للرمز"""
450
  try:
451
+ ticker = self.exchange.fetch_ticker(symbol)
452
  if not ticker:
453
  return None
454
 
 
708
 
709
  for attempt in range(max_retries):
710
  try:
711
+ ohlcv_data = self.exchange.fetch_ohlcv(symbol, timeframe, limit=limit)
712
 
713
  if ohlcv_data and len(ohlcv_data) > 0:
714
  return ohlcv_data
 
728
  print(f"❌ Exchange غير مهيأ لـ {symbol}")
729
  return None
730
 
731
+ # ✅ الإصلاح الرئيسي: إزالة asyncio.create_task واستخدام fetch_ticker مباشرة
732
+ ticker = self.exchange.fetch_ticker(symbol)
733
 
734
  if not ticker:
735
  print(f"❌ لم يتم العثور على ticker لـ {symbol}")