Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

254 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI-Powered Financial Trading Analysis Platform

A comprehensive, production-ready trading intelligence platform featuring real-time market analysis, portfolio management, ML-based pattern detection, sentiment analysis, and automated alerts.

Features

Core Capabilities

  • πŸ“Š Real-Time Market Analysis: Live stock quotes, charts, and technical indicators
  • πŸ€– AI-Powered Insights: Local LLM integration (Ollama) for intelligent chart analysis
  • πŸ“ˆ Pattern Recognition: Automated detection of chart patterns (Head & Shoulders, Double Tops/Bottoms, etc.)
  • 🧠 ML Pattern Detection: Machine learning-based prediction of future patterns
  • πŸ’Ή Portfolio Management: Track holdings, transactions, and performance metrics
  • πŸ“° News Integration: Real-time financial news with sentiment analysis
  • ⚑ Volatile Stocks Scanner: Track top movers, volume leaders, and high-momentum stocks (174+ symbols)
  • 🎯 Smart Alerts: Customizable price, volume, and technical indicator alerts
  • πŸ‘₯ Politician Trade Tracking: Monitor and copy trades from congressional filings
  • πŸ“Š Options Analysis: Advanced options Greeks and strategy analysis
  • ⏰ Trading Time Analyzer: Identify optimal trading hours based on performance
  • πŸ”— Correlation Analysis: Find correlated assets for diversification
  • πŸ“ Trade Journal: Document and analyze your trading decisions
  • πŸ—“οΈ Market Calendar: Track earnings, dividends, and economic events

Technical Features

  • Cryptocurrency Support: Monitor 24 major cryptos alongside stocks
  • Custom Watchlists: Create and manage multiple watchlists
  • Session Persistence: SQLite database with user authentication
  • Google OAuth: Secure login with Google accounts
  • Responsive UI: Modern, mobile-friendly interface
  • RESTful API: Comprehensive API for programmatic access
  • Production Ready: Docker + Kubernetes deployment configurations

Architecture

Backend Stack

  • Framework: Flask 3.0
  • Database: SQLAlchemy with SQLite (easily upgradable to PostgreSQL)
  • Data Sources: yfinance, Alpha Vantage, News API, Quandl
  • ML/AI: scikit-learn, statsmodels, Ollama (local LLM)
  • Authentication: Flask-Login, Authlib (Google OAuth)
  • Charting: Plotly, mplfinance, matplotlib
  • Production Server: Gunicorn with worker processes

Frontend Stack

  • HTML5/CSS3: Modern semantic markup
  • Vanilla JavaScript: No framework dependencies
  • Responsive Design: Mobile-first approach
  • Real-time Updates: AJAX for live data

Quick Start

Local Development

# Clone repository
git clone https://github.com/yourusername/trader-tools.git
cd trader-tools

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

# Install dependencies
pip install -r requirements.txt

# Set up environment variables
cp .env.template .env
# Edit .env with your API keys and settings

# Initialize database
python -c "from db_config import init_database; from flask import Flask; app = Flask(__name__); init_database(app)"

# Run application
python app.py

Access at http://localhost:5000

Docker

# Build image
docker build -t trader-tools .

# Run container
docker run -p 5000:5000 --env-file .env trader-tools

Production Kubernetes Deployment

πŸš€ No Docker? Start Here: NO_DOCKER_QUICKSTART.md - Deploy using GitHub Actions (easiest!)

πŸ“‹ For Production MicroK8s Cluster: See PRODUCTION.md for deploying to existing production MicroK8s cluster.

οΏ½πŸ“˜ Full Deployment Guide: See DEPLOYMENT.md for comprehensive deployment documentation.

⚑ Quick Reference: See QUICKSTART.md for command reference.

Deployment Methods:

  • Production MicroK8s + ArgoCD: GitOps deployment to existing cluster - PRODUCTION.md
  • Helm Chart: Recommended for production - helm/trader-tools
  • Kustomize: Lightweight overlay configuration - k8s/
  • Raw Manifests: Direct Kubernetes YAMLs - k8s/
  • ArgoCD GitOps: Automated sync and self-healing - argocd/

Quick examples:

Helm:

# Update image registry in values.yaml first
helm install trader-tools ./helm/trader-tools \
  --set image.repository=docker.io/yourusername/trader-tools \
  --set-string secrets.secretKey="your-secret" \
  --set-string secrets.googleClientId="your-client-id" \
  --set-string secrets.googleClientSecret="your-secret"

Production ArgoCD (for existing MicroK8s cluster):

# 1. Edit argocd/application.yaml with your Git repo and registry
# 2. Push code to Git
# 3. Create secrets on cluster
kubectl create secret generic trader-tools-secret \
  --from-literal=SECRET_KEY='your-secret' \
  --namespace trader-tools

# 4. Deploy
kubectl apply -f argocd/application.yaml

Configuration

Required Environment Variables

# Flask Configuration
SECRET_KEY=your-strong-random-secret-key
FLASK_ENV=production

# Google OAuth (Required for authentication)
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-google-client-secret

# Database
DATABASE_URL=sqlite:///instance/financial_analysis.db

# Optional API Keys (enhance functionality)
ALPHA_VANTAGE_API_KEY=your-alpha-vantage-key
NEWS_API_KEY=your-news-api-key
QUANDL_API_KEY=your-quandl-api-key

# LLM Configuration
OLLAMA_BASE_URL=http://localhost:11434

Getting API Keys

Project Structure

trader-tools/
β”œβ”€β”€ app.py                         # Main Flask application
β”œβ”€β”€ models.py                      # Database models
β”œβ”€β”€ config.py                      # Configuration management
β”œβ”€β”€ requirements.txt               # Python dependencies
β”œβ”€β”€ Dockerfile                     # Container image definition
β”œβ”€β”€ .dockerignore                  # Docker build exclusions
β”‚
β”œβ”€β”€ .github/                      # GitHub Actions CI/CD
β”‚   └── workflows/
β”‚       β”œβ”€β”€ build.yml             # Docker Hub build
β”‚       β”œβ”€β”€ build-ghcr.yml        # GitHub Container Registry build
β”‚       └── README.md
β”‚
β”œβ”€β”€ k8s/                          # Kubernetes manifests
β”‚   β”œβ”€β”€ namespace.yaml
β”‚   β”œβ”€β”€ deployment.yaml
β”‚   β”œβ”€β”€ service.yaml
β”‚   β”œβ”€β”€ ingress.yaml
β”‚   β”œβ”€β”€ configmap.yaml
β”‚   β”œβ”€β”€ secret.yaml.template
β”‚   β”œβ”€β”€ pvc.yaml
β”‚   β”œβ”€β”€ hpa.yaml
β”‚   └── kustomization.yaml
β”‚
β”œβ”€β”€ helm/                         # Helm chart
β”‚   └── trader-tools/
β”‚       β”œβ”€β”€ Chart.yaml
β”‚       β”œβ”€β”€ values.yaml
β”‚       └── templates/
β”‚
β”œβ”€β”€ argocd/                       # ArgoCD GitOps manifests
β”‚   β”œβ”€β”€ application.yaml          # Production app
β”‚   β”œβ”€β”€ application-dev.yaml      # Development app
β”‚   β”œβ”€β”€ application-kustomize.yaml
β”‚   └── README.md
β”‚
β”œβ”€β”€ static/                       # Frontend assets
β”‚   β”œβ”€β”€ styles.css
β”‚   β”œβ”€β”€ app.js
β”‚   β”œβ”€β”€ portfolio.js
β”‚   β”œβ”€β”€ volatile_stocks.js
β”‚   β”œβ”€β”€ copytrading.js
β”‚   └── ...
β”‚
β”œβ”€β”€ templates/                    # HTML templates
β”‚   β”œβ”€β”€ dashboard.html
β”‚   β”œβ”€β”€ portfolio.html
β”‚   └── ...
β”‚
β”œβ”€β”€ Core Modules
β”‚   β”œβ”€β”€ data_fetcher.py              # Market data retrieval
β”‚   β”œβ”€β”€ chart_generator.py           # Chart creation
β”‚   β”œβ”€β”€ pattern_recognizer.py        # Technical pattern detection
β”‚   β”œβ”€β”€ llm_analyzer.py              # LLM integration
β”‚   β”œβ”€β”€ ml_pattern_detector.py       # ML predictions
β”‚   β”œβ”€β”€ sentiment_analyzer.py        # News sentiment
β”‚   β”œβ”€β”€ options_analyzer.py          # Options Greeks
β”‚   β”œβ”€β”€ volatility_monitor.py        # Volatile stocks scanner
β”‚   β”œβ”€β”€ portfolio_analyzer.py        # Portfolio analytics
β”‚   β”œβ”€β”€ smart_alerts.py              # Alert engine
β”‚   β”œβ”€β”€ politician_trades.py         # Congressional trades
β”‚   └── ... 17 total modules
β”‚
└── Documentation
    β”œβ”€β”€ README.md                # This file
    β”œβ”€β”€ DEPLOYMENT.md            # Comprehensive deployment guide
    β”œβ”€β”€ PRODUCTION.md            # Production MicroK8s deployment
    β”œβ”€β”€ QUICKSTART.md            # Quick command reference
    β”œβ”€β”€ NO_DOCKER_QUICKSTART.md  # Deploy without Docker installed
    └── database_schema.sql      # Database schema

API Endpoints

Market Data

  • POST /analyze - Analyze a stock symbol
  • GET /api/market/volatile-stocks - Top volatile stocks
  • GET /api/market/fastest-movers - Biggest % movers
  • GET /api/market/volume-leaders - Volume surge leaders
  • GET /api/market/momentum-stocks - High momentum picks

Portfolio Management

  • GET /api/portfolio - Get portfolio summary
  • POST /api/portfolio/transaction - Add transaction
  • GET /api/portfolio/performance - Performance metrics

Alerts & Monitoring

  • GET /api/alerts - List active alerts
  • POST /api/alerts - Create new alert
  • GET /api/alerts/suggestions - Get AI alert suggestions

Other Features

  • GET /api/watchlist - User watchlists
  • GET /api/politician-trades - Recent politician trades
  • GET /api/correlation - Asset correlation matrix
  • GET /api/journal - Trade journal entries

See DEPLOYMENT.md for complete API documentation.

Production Deployment

Prerequisites

  • Docker 20.10+
  • Kubernetes 1.24+
  • Helm 3.8+ (recommended)
  • Container registry access

Quick Deploy with Helm

# 1. Build and push image
docker build -t your-registry/trader-tools:latest .
docker push your-registry/trader-tools:latest

# 2. Install with Helm
helm install trader-tools ./helm/trader-tools \
  --set image.repository=your-registry/trader-tools \
  --set-string secrets.secretKey="$(python -c 'import secrets; print(secrets.token_hex(32))')" \
  --set-string secrets.googleClientId="your-client-id" \
  --set-string secrets.googleClientSecret="your-client-secret"

# 3. Get the URL
kubectl get ingress -n trader-tools

Features in Production

  • High Availability: 2-10 replicas with auto-scaling
  • Load Balancing: Kubernetes Service with session affinity
  • Persistent Storage: 10GB PVC for database
  • Health Checks: Liveness and readiness probes
  • SSL/TLS: Automatic certificates with cert-manager
  • Monitoring: Prometheus metrics and Grafana dashboards
  • Rolling Updates: Zero-downtime deployments
  • Resource Management: CPU/memory requests and limits

See DEPLOYMENT.md for comprehensive production deployment guide.

Development

Running Tests

pytest
pytest --cov=. --cov-report=html

Code Style

black .
flake8 .
mypy app.py

Local LLM Setup

# Install Ollama
curl https://ollama.ai/install.sh | sh

# PDatabase Schema

The platform uses SQLAlchemy ORM with the following models:

- **User**: User accounts and profiles
- **Watchlist**: Custom stock watchlists
- **Portfolio**: Portfolio holdings
- **Transaction**: Buy/sell transactions  
- **OptionsPosition**: Options contracts
- **Alert**: Price and technical alerts
- **MLPattern**: ML pattern predictions
- **MLPrediction**: Historical predictions
- **AnalysisHistory**: Chart analysis history

See [database_schema.sql](database_schema.sql) for complete schema
| BTC-USD | Bitcoin |

**πŸ’‘ Tip:** Use shortcuts like **SPX**, **DJI**, or **NASDAQ** - they're automatically mapped to the correct Yahoo Finance symbols!

**πŸ“š For more symbols:** See [SYMBOLS_GUIDE.md](SYMBOLS_GUIDE.md) for a complete list of stocks, indices, ETFs, and cryptocurrencies.

## πŸ”’ Privacy & Security

- **100% Local**: All AI processing happens on your machine
- **No Cloud Dependencies**: No data sent to external servers
- *Contributing

Contributions are welcome! Please:

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

Copyright Β© 2026 Your Company. All rights reserved.

## Support

- **Documentation**: [DEPLOYMENT.md](DEPLOYMENT.md)
- **Issues**: GitHub Issues
- **Email**: support@yourdomain.com

## Disclaimer

**This platform is for informational and educational purposes only. It is not financial advice. Always conduct your own research and consult with a qualified financial advisor before making investment decisions. Past performance does not guarantee future results. Trading involves risk of loss.**

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages