Skip to content

automatesolutions/Billions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ BILLIONS - ML-Powered Stock Forecasting Platform

BILLIONS Logo

Advanced LSTM-based stock market forecasting and outlier detection

Next.js FastAPI Python TypeScript Tests Coverage


πŸ“Š Project Status

Current Version: v2.0 Web App (Phases 1-5 Complete)
Progress: 71.9% | 5.75/8 phases complete
Status: βœ… MVP READY FOR DEPLOYMENT

Phase Completion

  • βœ… Phase 0: Foundation & Analysis (100%)
  • βœ… Phase 1: Infrastructure Setup (100%)
  • βœ… Phase 2: Testing Infrastructure (100%)
  • βœ… Phase 3: Authentication & User Management (100%)
  • βœ… Phase 4: ML Backend Migration (100%)
  • βœ… Phase 5: Frontend Development MVP (100%)
  • πŸ”„ Phase 6: Deployment & Monitoring (75%)
  • ⏳ Phase 7: Data Migration (0%)
  • ⏳ Phase 8: Launch (0%)

Latest Updates (2025)

  • βœ… System Architecture Documentation - Complete flowchart with file references
  • βœ… Interactive HTML Visualization - Visual architecture explorer
  • βœ… Enhanced API Documentation - 30+ endpoints documented
  • βœ… Communication Flow Diagrams - Frontend ↔ Backend flows
  • βœ… File Structure Mapping - Complete file organization guide

✨ Features

πŸ€– Machine Learning

  • LSTM Neural Networks - Multi-timeframe stock predictions
  • Outlier Detection - 3 strategies (scalp, swing, long-term)
  • Sentiment Analysis - Real-time news sentiment scoring
  • Technical Analysis - 20+ indicators and metrics

πŸ“ˆ Market Intelligence

  • Stock Forecasting - 30-day predictions with confidence bands
  • Outlier Visualization - Scatter plots for market anomalies
  • News Aggregation - Real-time market news and analysis
  • Performance Metrics - ROI, Sharpe ratio, volatility analysis

πŸ‘€ User Features

  • Google OAuth - Secure authentication
  • User Dashboards - Personalized stock tracking
  • Watchlists - Save favorite tickers
  • Alerts - Price and prediction notifications
  • Auto-refresh - Real-time data updates (5-min intervals)

🎨 User Interface

  • Dark Mode - CLI-inspired mysterious theme
  • Custom Charts - SVG-based prediction & scatter plots
  • Mobile Responsive - Works on all devices
  • Toast Notifications - Real-time user feedback

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Next.js Frontend                 β”‚
β”‚  - 8+ pages (login, dashboard, analyze)   β”‚
β”‚  - 30+ components                          β”‚
β”‚  - Custom SVG charts                       β”‚
β”‚  - Port: 3000                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β”‚ REST API (30+ endpoints)
                    β”‚ WebSocket (HFT trading)
                    β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          FastAPI Backend                   β”‚
β”‚  - ML predictions (LSTM)                   β”‚
β”‚  - Outlier detection                       β”‚
β”‚  - News & sentiment                        β”‚
β”‚  - User management                         β”‚
β”‚  - HFT trading engine                      β”‚
β”‚  - Portfolio management                    β”‚
β”‚  - Port: 8000                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      SQLite Database                       β”‚
β”‚  - User data                               β”‚
β”‚  - Predictions                             β”‚
β”‚  - Market data cache                       β”‚
β”‚  - Performance metrics                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“– For detailed architecture documentation with file references and communication flows, see:


πŸš€ Quick Start

Prerequisites

  • Python 3.12+
  • Node.js 20+
  • pnpm 9+
  • Google OAuth credentials

1. Clone Repository

git clone https://github.com/yourusername/billions.git
cd billions

2. Backend Setup

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r api/requirements.txt
pip install -r api/requirements-dev.txt

# Start backend
python -m uvicorn api.main:app --reload
# Backend runs at http://localhost:8000

3. Frontend Setup

cd web

# Install dependencies
pnpm install

# Setup environment
cp .env.example .env.local
# Edit .env.local with your Google OAuth credentials

# Start frontend
pnpm dev
# Frontend runs at http://localhost:3000

4. Setup Google OAuth

See GOOGLE_OAUTH_SETUP.md for detailed instructions.


πŸ§ͺ Testing

# Backend tests (pytest)
pytest                      # Run all backend tests
pytest --cov               # With coverage report

# Frontend tests (Vitest)
cd web
pnpm test                  # Run component tests
pnpm test:watch           # Watch mode

# E2E tests (Playwright)
cd web
pnpm test:e2e             # Run E2E tests
pnpm test:e2e:ui          # Interactive UI mode

Test Statistics:

  • 89 total tests βœ…
  • Backend: 57 pytest tests (85% coverage)
  • Frontend: 20 component tests
  • E2E: 12 Playwright tests

πŸ“š Documentation

Document Description
PLAN.md Complete project roadmap (602 lines)
SYSTEM_ARCHITECTURE_FLOWCHART.md NEW - Complete system architecture with file references
SYSTEM_ARCHITECTURE_FLOWCHART.html NEW - Interactive HTML flowchart visualization
CHANGELOG.md Version history and changes
FAQ.md Frequently asked questions
CONTRIBUTING.md Contribution guidelines
API_TESTING_RESULTS.md API endpoint testing results

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 15.5.4 (App Router)
  • Language: TypeScript 5.9
  • Styling: Tailwind CSS v4
  • Components: shadcn/ui
  • Auth: NextAuth.js
  • Testing: Vitest + Playwright

Backend

  • Framework: FastAPI 0.118
  • Language: Python 3.12
  • ORM: SQLAlchemy 2.0
  • ML: PyTorch 2.4, TensorFlow 2.19
  • Testing: pytest 8.4
  • Coverage: 85%

Infrastructure

  • Database: SQLite (MVP), PostgreSQL (future)
  • CI/CD: GitHub Actions
  • Frontend Deploy: Vercel (configured)
  • Backend Deploy: Railway/Render (configured)
  • Monitoring: Sentry (ready to integrate)

🌐 API Endpoints

Predictions (/api/v1/predictions)

  • GET /api/v1/predictions/{ticker} - Get ML predictions
  • GET /api/v1/predictions/info/{ticker} - Get ticker info
  • GET /api/v1/predictions/search - Search tickers

Market Data (/api/v1/market)

  • GET /api/v1/market/outliers/{strategy} - Get outlier stocks
  • GET /api/v1/market/performance/{strategy} - Get performance metrics
  • GET /api/v1/{ticker}/historical - Historical price data

Outliers (/api/v1/outliers)

  • GET /api/v1/outliers/{strategy} - Get outlier data
  • GET /api/v1/outliers/strategies - List available strategies
  • POST /api/v1/outliers/{strategy}/refresh - Refresh outlier cache

News (/api/v1/news)

  • GET /api/v1/news/{ticker} - Get ticker news with sentiment
  • GET /api/v1/nasdaq-news/latest - Latest NASDAQ news
  • GET /api/v1/nasdaq-news/urgent - Urgent news alerts

Trading (/api/v1/trading)

  • GET /api/v1/trading/status - Trading account status
  • POST /api/v1/trading/execute - Execute trade
  • GET /api/v1/trading/positions - Current positions
  • POST /api/v1/trading/quote/{symbol} - Real-time quote
  • GET /api/v1/trading/orders - Order history

HFT (/api/v1/hft)

  • GET /api/v1/hft/status - HFT engine status
  • POST /api/v1/hft/start - Start HFT engine
  • POST /api/v1/hft/stop - Stop HFT engine
  • POST /api/v1/hft/orders - Submit HFT order
  • GET /api/v1/hft/performance - Performance metrics

Portfolio (/api/v1/portfolio)

  • POST /api/v1/portfolio/calculate-metrics - Calculate portfolio metrics
  • GET /api/v1/portfolio/risk-analysis/{ticker} - Risk analysis
  • POST /api/v1/portfolio/calculate-allocation - Optimal allocation

Valuation (/api/v1/valuation)

  • GET /api/v1/valuation/{ticker} - Stock valuation
  • GET /api/v1/valuation/{ticker}/fair-value - Black-Scholes fair value

Users (/api/v1/users)

  • POST /api/v1/users/ - Create user
  • GET /api/v1/users/{user_id} - Get user profile
  • PUT /api/v1/users/{user_id}/preferences - Update preferences
  • GET /api/v1/users/{user_id}/watchlist - Get watchlist
  • POST /api/v1/users/{user_id}/watchlist - Add to watchlist

Behavioral (/api/v1/behavioral)

  • POST /api/v1/behavioral/rationale - Add trade rationale
  • GET /api/v1/behavioral/insights - Behavioral insights
  • GET /api/v1/behavioral/performance-analysis - Performance analysis

Capitulation (/api/v1/capitulation)

  • GET /api/v1/capitulation/screen - Screen for capitulation
  • GET /api/v1/capitulation/analyze/{symbol} - Analyze stock

πŸ“– See SYSTEM_ARCHITECTURE_FLOWCHART.md for detailed endpoint documentation with file references.


πŸ“ Project Structure

Billions/
β”œβ”€β”€ web/                     # Next.js Frontend
β”‚   β”œβ”€β”€ app/                # Pages (App Router)
β”‚   β”‚   β”œβ”€β”€ login/         # Authentication
β”‚   β”‚   β”œβ”€β”€ dashboard/     # User dashboard
β”‚   β”‚   β”œβ”€β”€ analyze/       # Stock analysis
β”‚   β”‚   └── outliers/      # Outlier detection
β”‚   β”œβ”€β”€ components/        # UI components
β”‚   β”‚   β”œβ”€β”€ charts/        # Custom SVG charts
β”‚   β”‚   β”œβ”€β”€ ui/            # shadcn/ui components
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ hooks/             # Custom React hooks
β”‚   β”œβ”€β”€ lib/               # API client & utilities
β”‚   β”œβ”€β”€ __tests__/         # Component tests (20)
β”‚   └── e2e/               # E2E tests (12)
β”‚
β”œβ”€β”€ api/                   # FastAPI Backend
β”‚   β”œβ”€β”€ routers/           # API routes
β”‚   β”‚   β”œβ”€β”€ predictions.py
β”‚   β”‚   β”œβ”€β”€ outliers.py
β”‚   β”‚   β”œβ”€β”€ news.py
β”‚   β”‚   └── users.py
β”‚   β”œβ”€β”€ services/          # Business logic
β”‚   β”œβ”€β”€ tests/             # Backend tests (57)
β”‚   └── main.py            # FastAPI app
β”‚
β”œβ”€β”€ db/                    # Database
β”‚   β”œβ”€β”€ models.py          # SQLAlchemy models
β”‚   └── models_auth.py     # User models
β”‚
β”œβ”€β”€ funda/                 # ML Models (legacy)
β”‚   β”œβ”€β”€ SPS.py             # News & sentiment
β”‚   β”œβ”€β”€ train_lstm_model.py
β”‚   └── outlier_engine.py
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/         # CI/CD
β”‚       β”œβ”€β”€ test.yml       # Test pipeline
β”‚       β”œβ”€β”€ lint.yml       # Linting
β”‚       └── deploy.yml     # Deployment
β”‚
β”œβ”€β”€ vercel.json            # Vercel config
β”œβ”€β”€ railway.json           # Railway config
β”œβ”€β”€ render.yaml            # Render config
└── docker-compose.yml     # Dev environment

🎯 Key Statistics

  • Files Created: 200+ files
  • Lines of Code: 10,000+ lines
  • Documentation: 8,000+ lines
  • API Endpoints: 30+ endpoints
  • Frontend Pages: 8+ pages
  • Components: 30+ components
  • Backend Routers: 13 routers
  • Backend Services: 12 services
  • Tests: 89 tests passing
  • Test Coverage: 85% (backend)
  • Architecture Docs: Complete flowchart with file references

πŸš€ Deployment

The application is ready to deploy! Configuration files are in place for:

  1. Frontend (Vercel) - vercel.json configured
  2. Backend (Railway or Render) - railway.json / render.yaml configured
  3. CI/CD (GitHub Actions) - Automated testing & deployment

To deploy, follow the step-by-step guide in DEPLOYMENT_GUIDE.md.


πŸ”’ Security

  • Google OAuth - Secure authentication via NextAuth.js
  • JWT Sessions - Stateless authentication
  • CORS Protection - Configured for production
  • Environment Variables - Secrets management
  • Rate Limiting - API throttling (future)
  • SQL Injection Protection - SQLAlchemy parameterized queries

🀝 Contributing

See CONTRIBUTING.md for development guidelines.


πŸ“„ License

See LICENSE for details.


πŸ“ž Support

For questions or issues:

  1. Check the FAQ.md
  2. Review DEVELOPMENT.md
  3. Open a GitHub issue

πŸŽ‰ Acknowledgments

Built with modern best practices:

  • Test-Driven Development (TDD)
  • Continuous Integration/Deployment (CI/CD)
  • Comprehensive documentation
  • Clean architecture

BILLIONS - Machine Learning for Trading Intelligence

Made with ❀️ and β˜•

Website | Docs | API Docs

About

BILLIONS is a sophisticated machine learning platform designed for stock market prediction and outlier detection. It combines advanced LSTM neural networks, comprehensive technical analysis, and real-time data processing to provide actionable trading insights across multiple timeframes.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors