Real-time AI-Powered Trading Signals for S&P 500 Momentum Strategies
๐ Confluent AI Partner Catalyst Hackathon 2025
MomentumFlow AI is a real-time momentum trading scanner that leverages Confluent Kafka streaming to deliver institutional-grade market analysis. Built for the S&P 500, it combines proven momentum trading strategies with live data streaming and AI-powered pattern recognition.
- ๐ Stock Scanner โ Scans 534 S&P 500 stocks against 5 momentum criteria
- ๐ Trend Indicator โ EMA-based trend detection (Bullish/Bearish/Neutral)
- ๐ฉ Bull Flag Detection โ Automated pattern recognition with adjustable thresholds
- ๐ฐ Live News Feed โ Google News streaming with sentiment analysis
- ๐งฎ Risk Calculator โ Position sizing with scaling protocols
- ๐ก Trade Ideas โ Auto-generated setups based on score + patterns
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Yahoo Finance โ โ Confluent Kafka โ โ R Shiny โ
โ Google News โโโโโโถโ (Cloud - Zurich) โโโโโโถโ Dashboard โ
โโโโโโโโโโโโโโโโโโโโ โ โ โโโโโโโโโโโโโโโโโโโโ
โ โข stock_prices โ
Python Producers โ โข stock_news โ REST API Consumer
โโโโโโโโโโโโโโโโโโโโโโโ
| Topic | Content | Update Frequency |
|---|---|---|
stock_prices |
OHLCV + Momentum Scores | ~2 min cycle |
stock_news |
Headlines + Sentiment | ~5 min cycle |
MomentumFlowAI/
โโโ app_dark_theme.R # Main Shiny application
โโโ kafka_producer.py # Stock price streaming producer
โโโ kafka_news_producer.py # News streaming producer
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ docs/
โโโ MomentumFlowAI_Hackathon_Submission.pdf
- R 4.x with RStudio
- Python 3.x
- Confluent Cloud account (free tier works)
git clone https://github.com/Tianning-lab/MomentumFlowAI.git
cd MomentumFlowAIinstall.packages(c(
"shiny", "shinydashboard", "quantmod", "tidyverse",
"plotly", "DT", "TTR", "lubridate", "scales",
"PerformanceAnalytics", "httr", "jsonlite", "base64enc", "xml2"
))pip install confluent-kafka yfinance pandas numpy feedparser requests- Create a Confluent Cloud account at confluent.cloud
- Create a cluster (Basic tier is fine)
- Create topics:
stock_pricesandstock_news - Generate API keys
Update credentials in both Python files:
KAFKA_CONFIG = {
'bootstrap.servers': 'YOUR_BOOTSTRAP_SERVER',
'sasl.username': 'YOUR_API_KEY',
'sasl.password': 'YOUR_API_SECRET',
...
}Terminal 1 โ Stock Prices:
python kafka_producer.pyTerminal 2 โ News:
python kafka_news_producer.pyIn RStudio, open app_dark_theme.R and click Run App.
| # | Criterion | Threshold | Rationale |
|---|---|---|---|
| 1 | Price Range | $5 - $500 | Covers most S&P 500 stocks |
| 2 | Daily Change | โฅ 0.5% | Meaningful price movement |
| 3 | Relative Volume | โฅ 1.0x average | Confirms participation |
| 4 | Momentum | Price > Open | Intraday buying pressure |
| 5 | Volatility | Range โฅ 0.5% | Sufficient profit opportunity |
Thresholds adapted for large-cap stocks:
| Parameter | S&P 500 | Penny Stocks |
|---|---|---|
| Pole Return | โฅ 1.5% | โฅ 3% |
| Flag Range | < 7% | < 5% |
| Volume | Decreasing | Decreasing |
| Layer | Technology |
|---|---|
| Streaming | Confluent Cloud (Apache Kafka) |
| Producers | Python, confluent-kafka, feedparser |
| Data Sources | Yahoo Finance, Google News RSS |
| Frontend | R Shiny, shinydashboard |
| Visualization | Plotly, DT |
| Analysis | quantmod, TTR, PerformanceAnalytics |
- Q1 2026: Options flow analysis via Kafka Streams
- Q2 2026: Claude AI integration for natural language queries
- Q3 2026: Multi-asset support (crypto, forex)
- Q4 2026: Mobile app with push notifications
Tianning Ning
Founder & CEO, New Way Capital Advisory Limited
- ๐ GitHub: @Tianning-lab
- ๐ง Email: tnk@newwaycapital.com
- ๐ Geneva, Switzerland
This project is licensed under the MIT License - see the LICENSE file for details.
- Confluent for the amazing Kafka platform
- Yahoo Finance for market data
- Google News for news feeds
ยฉ 2025 New Way Capital Advisory Limited
Made with โค๏ธ in Geneva, Switzerland
MomentumFlow AI is live at nwc-advisory.com/app โ part of the New Way Capital Advisory analytics platform.
- Portfolio Analyser โ Institutional portfolio analysis
- Risk API โ 7-signal market risk scoring
- Property Comps โ Comparable sales across 11 markets
- Portfolio X-Ray โ Free fund look-through analysis



