AI-Assisted Swing Trading Watchlist & Alert Engine
An automated, event-driven market monitoring engine that evaluates dynamic stock watchlists using multi-timeframe technical indicators and grounded LLM sentiment analysis to dispatch deduplicated, evidence-backed alerts via Telegram and real-time SSE streams.
Problem Statement
Retail swing traders tracking dozens of equities struggle with cognitive fatigue, noisy price alerts, and disjointed analytical workflows. Traditional monitoring tools trigger brittle threshold alerts (e.g., crossing a static price or RSI level) without contextual awareness of broader market trends, multi-timeframe confirmation, or qualitative catalysts like high-impact earnings and regulatory announcements. Conversely, naive LLM integrations hallucinate market sentiment, breach external API rate ceilings, and spam users with redundant notifications during prolonged consolidations. Traders need an autonomous, resilient engine that continuously fuses quantitative technical indicators with grounded news sentiment, applying strict deduplication and stateful diffing to emit actionable, evidence-backed signals only when market conditions materially shift.
System Architecture & Data Flow
The system adopts an asynchronous, queue-driven architecture powered by BullMQ and Redis, isolating market data ingestion, parallel signal computation, and alert distribution behind strict concurrency controls and circuit breakers.
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ DYNAMIC SCHEDULER │
│ MongoDB (WatchlistItem) ──▶ dynamicScheduler.ts ──▶ BullMQ Repeatable Jobs (analyze-*)│
└────────────────────────────────────────┬───────────────────────────────────────────────┘
│ Enqueues per-ticker tasks
▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ REDIS / BULLMQ QUEUE LAYER │
│ Queue: 'ticker-analysis' (Concurrency: 3) │
│ [Job: analyze-AAPL] [Job: analyze-NVDA] [Job: analyze-MSFT] │
└────────────────────────────────────────┬───────────────────────────────────────────────┘
│ Worker processes job (Market-Hours Guarded)
▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ MARKET DATA INGESTION ENGINE │
│ FinnhubProvider ──▶ RateLimiter (Token-Bucket: 55 req/min, Serialized Mutex Lock) │
│ Promise.all() Parallel Fetch: Quotes, Daily & 30m Candles, News, Earnings, Insider │
└────────────────────────────────────────┬───────────────────────────────────────────────┘
│ Raw Market & News Data
┌────────────────────┴────────────────────┐
▼ ▼
┌──────────────────────────────────────┐ ┌──────────────────────────────────────────────┐
│ TECHNICAL INDICATORS ENGINE │ │ LLM SENTIMENT ANALYZER │
│ • RSI (14) & Split-Window Divergence│ │ • Ollama (llama3.1) / Gemini / Groq / OpenAI│
│ • EMA 20 / 50 Crossover Detection │ │ • Multi-Provider Circuit Breaker (3 fails) │
│ • MACD (12, 26, 9) Histogram Trend │ │ • Prompt Grounding: Strict Zod JSON Schema │
│ • Volume Spike (>1.5x 20-day SMA) │ │ • Materiality: High (1.4x), Med, Low (0.6x) │
│ • 52W High/Low & Rel. Strength SPY │ │ • Graceful Fallback to Neutral Signal │
└───────────────────┬──────────────────┘ └──────────────────────┬───────────────────────┘
│ TASignal │ NewsSignal
└────────────────────┬───────────────────────┘
▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ SIGNAL BLENDING & SCORING (score.ts) │
│ • Composite Score (-1.0 to +1.0) = (TA × 0.55 + News × NewsWeight) / TotalWeight │
│ • Multi-timeframe confirmation: Daily & 30m agree (×1.20 conf) / conflict (×0.80 conf) │
│ • Deterministic Rating: Strong Buy, Buy, Hold, Sell, Strong Sell │
│ • 48h Earnings Risk Override: Prepends warning reason & elevates news materiality │
└────────────────────────────────────────┬───────────────────────────────────────────────┘
▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ DIFFING & DEDUPLICATION (diff.ts) │
│ Evaluates Current vs. Previous Snapshot (MongoDB): │
│ • Rating Transitions (e.g., Hold ➔ Buy) │
│ • Material News Announcements | Sentiment Swings (|Δ| > 0.35) │
│ • RSI Boundary Crossings (30 / 70) | Golden / Death EMA Crosses │
└────────────────────────────────────────┬───────────────────────────────────────────────┘
│ Alert-worthy event detected
▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ ALERT LOGIC & IDEMPOTENCY GUARD (AlertLog) │
│ • Checks AlertLog: Rejects duplicate ratings within a 4-hour quiet window │
│ • Verifies Confidence >= MIN_ALERT_CONFIDENCE threshold │
└───────────────────┬─────────────────────────────────────────┬──────────────────────────┘
│ Verified Alert │ Every Analysis Cycle
▼ ▼
┌──────────────────────────────────────┐ ┌──────────────────────────────────────────────┐
│ TELEGRAM ALERT DISPATCHER │ │ REAL-TIME STREAMING & STORAGE │
│ • Telegram Bot API Webhook Dispatch │ │ • Server-Sent Events (SSE) Broadcast │
│ • HTML-Formatted Payload: │ │ • Persist Cycle Document (Snapshot Schema) │
│ - Rating Emojis & Confidence % │ │ • Automated Paper Trading & P&L Updates │
│ - Human-Readable Evidence Bullets │ │ • Signal Accuracy Tracker (24h resolution) │
│ - Dynamic Reason & Disclaimer │ │ • Web Push (VAPID) User Notifications │
└──────────────────────────────────────┘ └──────────────────────────────────────────────┘Core Features & Capabilities
Technical Challenges & Engineering Solutions
AlertLog enforces a 4-hour quiet period on identical rating signals.Impact & Verification Status
Stack