Stock Prediction Service
AI-Powered Real-time Stock Analysis
DEMO
AI/ML
REAL-TIME
AI-powered stock prediction system using real-time news sentiment analysis. Aggregates news from multiple sources (Reddit, NewsAPI, RSS feeds), analyzes sentiment with a local LLM (Ollama), and generates multi-timeframe predictions with confidence scores.
ð Quick Stats
80+
Supported Stocks
3
News Sources
12h
Cache Duration
30s
Avg Response
âĻ Key Features
- Real-time News Analysis - Aggregates from Reddit, NewsAPI, and RSS feeds (CNBC, MarketWatch, Reuters)
- Local AI Processing - Ollama LLM (Llama 3.2 3B) running on M2 Mac with Neural Engine
- Multi-timeframe Predictions - Short-term, mid-term, and long-term recommendations
- Interactive Charts - 30-day price history visualization with Chart.js
- Discussion Board - Community insights and discussions per stock ticker
- Real-time Chat - Stock-specific chat rooms using Socket.IO
- Activity Analytics - User behavior tracking and session analysis
- Force Update - Bypass cache to get fresh predictions on demand
ðŧ Tech Stack
| Component | Technology |
|---|---|
| Frontend | HTML5, CSS3, JavaScript (ES6+), jQuery, Chart.js, Socket.IO client |
| Backend | Flask, Python 3.12, Flask-SocketIO, Flask-CORS |
| AI/ML | Ollama (Llama 3.2 3B) / OpenAI GPT-3.5-turbo |
| Data Sources | Reddit API (praw), NewsAPI, RSS feeds (feedparser), yfinance |
| Storage | JSON (discussions), Pickle (cache), JSONL (activity logs) |
| Deployment | GitHub Pages (frontend) + ngrok tunnel (backend) |
| Hardware | MacBook Air M2 (24GB RAM, 10-core GPU) |
ðïļ System Architecture
Data Flow
GitHub Pages (Frontend)
â HTTPS
Ngrok Tunnel (carpedkm.jp.ngrok.io)
â localhost:5001
MacBook Air M2 (Flask Backend)
â
âââ News Aggregator
â âââ Reddit API (r/wallstreetbets, r/stocks, r/investing)
â âââ NewsAPI (global financial news)
â âââ RSS Feeds (CNBC, MarketWatch, Reuters)
â
âââ Sentiment Analyzer
â âââ Ollama LLM (Llama 3.2 3B)
â
âââ Price Data
â âââ yfinance (historical & real-time)
â
âââ Storage
âââ JSON (discussion board)
âââ Pickle (prediction cache)
âââ JSONL (activity logs)
ð API Endpoints
# Authentication
POST /api/login # User login
POST /api/logout # User logout
GET /api/check-auth # Check auth status
# Stock Data
GET /api/stocks # List supported stocks
GET /api/search-stock?q={query} # Search stock by name/ticker
GET /api/stock/{ticker}/predict # Get prediction (queued)
GET /api/stock/{ticker}/price # Get price data
GET /api/stock/{ticker}/news # Get recent news
# Market Overview
GET /api/market-overview # Get market indices
GET /api/trending # Get trending stocks
# Discussion Board
GET /api/discussions/{ticker} # Get posts
POST /api/discussions/{ticker} # Create post
GET /api/discussions/post/{post_id} # Get post with comments
POST /api/discussions/post/{post_id}/comment # Add comment
POST /api/discussions/post/{post_id}/like # Like post
DELETE /api/discussions/post/{post_id} # Delete post
# Analytics
POST /api/log-activity # Log user activity
# System
GET /api/health # Health check
GET /api/status # Server status
ð° News Sources
- r/wallstreetbets - High-volume retail trader discussions
- r/stocks - General stock market discussion
- r/investing - Long-term investment strategies
- r/StockMarket - Market news and analysis
NewsAPI
Global financial news aggregator with 100 requests/day limit on free tier.
RSS Feeds
- CNBC - Breaking financial news
- MarketWatch - Market data and analysis
- Reuters - Global business news
ðĪ AI Configuration
Installation
# Install Ollama
brew install ollama
# Start Ollama service
ollama serve
# Pull Llama 3.2 3B model
ollama pull llama3.2:3b
Model Performance
| Metric | Value |
|---|---|
| Model | Llama 3.2 3B |
| Memory Usage | ~2GB RAM |
| Speed | ~1-2s per news article on M2 |
| Hardware Acceleration | M2 Neural Engine (16-core, 15.8 TOPS) |
| Cost | Free (local processing) |
ðŧ Hardware Specifications
| Component | Specification |
|---|---|
| Model | MacBook Air M2 (2022) |
| CPU | Apple M2 (8-core: 4 performance + 4 efficiency) |
| GPU | 10-core GPU (integrated) |
| RAM | 24GB Unified Memory |
| Neural Engine | 16-core (15.8 trillion ops/sec) |
| Storage | 512GB SSD |
â ïļ Limitations
- Prediction Time: 30-60s due to sequential LLM inference for sentiment analysis
- Concurrent Users: 1-3 max (single MacBook server, no load balancing)
- Uptime: Requires MacBook to be powered on and ngrok tunnel active
- Rate Limits: NewsAPI 100 req/day (free tier), Reddit API 60 req/min
- Cache: 12-hour prediction cache, may show stale data during volatile markets
- Market Coverage: Limited to 80+ major stocks and Korean KOSPI stocks
ðŪ Future Enhancements
- Batch Processing: Parallel LLM inference for faster predictions
- Redis Caching: Distributed cache layer for better performance
- Cloud Deployment: 24/7 availability on AWS/GCP with autoscaling
- Expanded Coverage: Full S&P 500 and international markets
- Accuracy Tracking: Historical performance metrics and backtesting
- WebSocket Updates: Real-time prediction progress without polling
- Advanced Charts: Technical indicators (RSI, MACD, Bollinger Bands)
- Portfolio Tracking: User watchlists and personalized alerts