Real-Time Financial Intelligence Powered by Pathway Streaming Engine
AlphaStream is a production-grade AI trading system that solves the "stale knowledge" problem in financial analysis. It combines real-time news ingestion, SEC EDGAR filings, multi-agent reasoning, and live visualization to deliver instant, explainable trading recommendations.
Built for DataQuest 2026 hackathon using the Pathway streaming framework.
Traditional AI systems suffer from knowledge cutoffβthey can't react to breaking news or regulatory filings. AlphaStream demonstrates Live AI:
- Ingests news articles in real-time
- Updates recommendations in <2 seconds when new data arrives
- Incorporates SEC insider trading data
- Generates professional PDF reports
- Pathway Streaming Engine - Incremental processing, no batch jobs
- NewsAPI Integration - Live financial news polling
- SEC EDGAR Connector - Form 4 insider trading filings
| Agent | Function |
|---|---|
| Sentiment Agent | LLM-powered news sentiment analysis |
| Technical Agent | RSI, SMA calculations from yfinance |
| Risk Agent | Volatility-based position sizing |
| Insider Agent | SEC Form 4 transaction analysis |
| Chart Agent | 7-day price charts with 24h highlighting |
| Report Agent | PDF generation with charts & tables |
| Decision Agent | Final BUY/HOLD/SELL recommendation |
- Real-time sentiment heatmap
- Agent consensus radar chart
- Insider activity panel
- One-click PDF report generation
| Layer | Technology |
|---|---|
| Streaming Engine | Pathway |
| Backend | FastAPI, Python 3.11 |
| LLM | LangChain, OpenRouter (Claude/Gemma) |
| Market Data | yfinance, edgartools |
| PDF Reports | ReportLab, Matplotlib |
| Frontend | React 18, Vite, Tailwind CSS, Shadcn |
| State | Zustand |
We use Pathway's official LLM xpack (from llm-app templates) for maximum performance:
| Component | Pathway xpack Class |
|---|---|
| Adaptive RAG | pw.xpacks.llm.question_answering.AdaptiveRAGQuestionAnswerer |
| Document Store | pw.xpacks.llm.document_store.DocumentStore |
| LLM Chat | pw.xpacks.llm.llms.OpenAIChat |
| Embeddings | pw.xpacks.llm.embedders.OpenAIEmbedder |
| Splitter | pw.xpacks.llm.splitters.TokenCountSplitter |
| Vector Search | pw.indexing.UsearchKnnFactory |
| REST Server | pw.xpacks.llm.servers.QASummaryRestServer |
Adaptive RAG uses a geometric retrieval strategy - starting with 2 documents and expanding only when the LLM needs more context, saving tokens without sacrificing accuracy.
- Python 3.11+
- Node.js 18+
- API Keys: OpenRouter, NewsAPI
cd "AlphaStream"
# Install Python dependencies (using uv)
cd backend && uv sync && cd ..
# Install frontend dependencies
cd frontend && npm install && cd ..# Backend environment (required)
cd backend
cp .env.example .env
# Edit .env with your API keys:
# - OPENROUTER_API_KEY (required - LLM access)
# - NEWS_API_KEY (required - NewsAPI)
# - FINNHUB_API_KEY (optional - additional news)
# - ALPHAVANTAGE_API_KEY (optional - sentiment data)
# - MEDIASTACK_API_KEY (optional - global news)
cd ..Option A: Single Command (Recommended)
cd backend
./start.shThis starts both Adaptive RAG and the main backend in the correct order.
Option B: Separate Terminals (for debugging)
Terminal 1: Adaptive RAG Server
cd backend
uv run python -m src.pipeline.adaptive_rag_serverTerminal 2: Backend
cd backend
uv run uvicorn src.api.app:app --host 0.0.0.0 --port 8000Terminal 3: Frontend
cd frontend && npm run devAccess dashboard at http://localhost:5173
Terminal 3: Demo Script
python demo_pipeline.py --ticker AAPL --output demo_output.jsonThe demo script:
- Fetches initial recommendation
- Injects bearish breaking news
- Shows real-time sentiment change
- Saves detailed JSON proof to
demo_output.json
UI Visibility: The demo updates ARE visible in the dashboard! When the demo injects an article, the backend broadcasts via WebSocket, and the frontend updates automatically. Keep the dashboard open to see live changes.
| Method | Path | Description |
|---|---|---|
POST |
/recommend |
Get trading recommendation |
GET |
/health |
System health check |
GET |
/articles/{ticker} |
Get related articles |
GET |
/market/heatmap |
Live market sentiment data |
POST |
/ingest |
Inject test article |
| Method | Path | Description |
|---|---|---|
GET |
/insider/{ticker}?days=90 |
Insider trading activity (default: 90 days) |
GET |
/chart/{ticker} |
Price comparison chart |
POST |
/report/{ticker} |
Generate PDF report |
| Path | Description |
|---|---|
/ws/stream/{ticker} |
Real-time recommendation updates |
AlphaStream is built around Pathway, the world's fastest streaming engine. Our implementation demonstrates deep Pathway integration:
| Pathway Feature | Usage |
|---|---|
pw.Schema |
Type-safe schemas for articles, sentiment, alerts |
pw.Table |
Streaming tables for real-time market data |
pw.io.python.ConnectorSubject |
Custom news connector polling multiple APIs |
pw.io.subscribe |
Real-time callbacks on data changes |
pw.apply |
UDF transformations for ticker extraction |
pw.filter |
Alert generation on sentiment spikes |
pw.reducers |
Sentiment aggregation by ticker |
Our innovative multi-source news system fetches from 5 sources in parallel:
- NewsAPI - Breaking news headlines
- Finnhub - Company-specific financial news
- Alpha Vantage - Sentiment-tagged articles
- MediaStack - Global business news
- RSS Feeds - Free, unlimited fallback
No single point of failure - if one source is rate-limited, others continue.
News Sources β Pathway Connector β RAG Pipeline β Multi-Agent Reasoning β WebSocket β Dashboard
β β β β
Real-time pw.Table with Hybrid retrieval 7 specialized
polling auto-indexing + reranking AI agents
AlphaStream/
βββ backend/
β βββ src/
β β βββ agents/
β β β βββ sentiment_agent.py # LangChain sentiment analysis
β β β βββ technical_agent.py # RSI, SMA from yfinance
β β β βββ risk_agent.py # Volatility & position sizing
β β β βββ decision_agent.py # Final recommendation (LLM)
β β β βββ insider_agent.py # SEC Form 4 analysis
β β β βββ chart_agent.py # Matplotlib charts
β β β βββ report_agent.py # ReportLab PDF
β β βββ connectors/
β β β βββ news_connector.py # Pathway streaming connector
β β β βββ news_aggregator.py # "Herd of Knowledge" multi-source
β β β βββ rss_connector.py # Free RSS fallback
β β β βββ sec_connector.py # SEC EDGAR (edgartools)
β β β βββ polling.py # Generic polling utilities
β β βββ pipeline/
β β β βββ rag_core.py # RAG pipeline orchestration
β β β βββ rag_service.py # Unified RAG (adaptive + manual fallback)
β β β βββ adaptive_rag_server.py # Pathway xpacks.llm implementation
β β β βββ pathway_tables.py # Pathway-native tables & transforms
β β β βββ chunking.py # Adaptive document chunking
β β β βββ retrieval.py # Hybrid retrieval (dense + BM25 + RRF)
β β β βββ reranking.py # Cross-encoder reranking
β β βββ api/
β β β βββ app.py # FastAPI + Pathway integration
β β βββ config.py # Pydantic settings management
β βββ reports/ # Generated PDF reports
β βββ tests/ # pytest tests
β βββ .env.example # Environment template
β βββ pyproject.toml # Dependencies (uv)
βββ frontend/
β βββ src/
β βββ App.tsx # Main dashboard
β βββ store/appStore.ts # Zustand state management
β βββ components/trading/ # 12 UI components
βββ docs/
β βββ ARCHITECTURE.md
β βββ PROJECT_DOCUMENTATION.md
β βββ pipeline_architecture_*.png # Generated diagrams
β βββ herd_of_knowledge_*.png
βββ demo_pipeline.py # Automated demo script
βββ demo_live.py # Live demonstration
βββ docker-compose.yml
# Run all tests
cd backend
uv run pytest tests/ -v
# Test real-time dynamism
uv run python scripts/inject_article.py "Breaking News" "Content here"
# Watch recommendation change in <2sdocker-compose up --buildAccess at http://localhost:8000 (API) and http://localhost:5173 (Dashboard)
Run the complete demonstration with:
python demo_pipeline.pyThis script automatically:
- Starts the backend server
- Gets initial AAPL recommendation
- Injects a bearish article
- Shows recommendation change in <2 seconds
- Generates PDF report
- Start the system
- Search for "AAPL" β Note recommendation
- Inject bearish article:
curl -X POST http://localhost:8000/ingest \ -H "Content-Type: application/json" \ -d '{"title":"Apple Faces Lawsuit","content":"Major legal trouble..."}'
- Watch recommendation change via WebSocket
- Generate PDF report with updated analysis
MIT License. Built for DataQuest 2026 Hackathon.
- Pathway - Streaming engine powering real-time RAG
- OpenRouter - LLM API access
- edgartools - SEC EDGAR data access

