Migrate to yfinance and parallelize analysis
This commit is contained in:
+13
-7
@@ -17,6 +17,7 @@ import logging
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime, timezone
|
||||
from typing import Dict, List, Optional
|
||||
import concurrent.futures
|
||||
|
||||
import pandas as pd
|
||||
|
||||
@@ -124,13 +125,18 @@ class SignalAggregator:
|
||||
)
|
||||
self.data_provider.prefetch_batch(self.config.watch_pairs, all_timeframes)
|
||||
|
||||
for symbol in self.config.watch_pairs:
|
||||
try:
|
||||
report = self.analyze_pair(symbol, context)
|
||||
reports.append(report)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to analyze {symbol}: {e}")
|
||||
continue
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=min(32, len(self.config.watch_pairs) or 1)) as executor:
|
||||
future_to_symbol = {
|
||||
executor.submit(self.analyze_pair, symbol, context): symbol
|
||||
for symbol in self.config.watch_pairs
|
||||
}
|
||||
for future in concurrent.futures.as_completed(future_to_symbol):
|
||||
symbol = future_to_symbol[future]
|
||||
try:
|
||||
report = future.result()
|
||||
reports.append(report)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to analyze {symbol}: {e}")
|
||||
|
||||
# Sort by absolute score (strongest signals first)
|
||||
reports.sort(key=lambda r: abs(r.final_score), reverse=True)
|
||||
|
||||
Reference in New Issue
Block a user