21 lines
739 B
Python
21 lines
739 B
Python
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class SurgeDetector:
|
|
def __init__(self, multiplier: float = 3.0):
|
|
self.multiplier = multiplier
|
|
|
|
def detect(self, tickers: list[dict], avg_volumes: dict[str, float]) -> list[str]:
|
|
surged = []
|
|
for t in tickers:
|
|
symbol = t["symbol"]
|
|
if not symbol.endswith("USDT"):
|
|
continue
|
|
current_vol = float(t.get("quoteVolume", 0))
|
|
avg_vol = avg_volumes.get(symbol, 0)
|
|
if avg_vol > 0 and current_vol >= avg_vol * self.multiplier:
|
|
logger.info(f"Surge detected: {symbol} volume {current_vol:.0f} vs avg {avg_vol:.0f}")
|
|
surged.append(symbol)
|
|
return surged
|