A comprehensive SaaS paper trading platform that uses sentiment analysis to generate trading recommendations and track portfolio performance. Built for traders, investors, and financial professionals who want to test strategies risk-free.
- Overview
- Features
- Architecture
- Quick Start
- Installation
- Usage
- API Documentation
- Configuration
- Development
- Testing
- Contributing
- Development Setup - Complete guide for local development
- Google OAuth Setup - Configure Google authentication
- Deployment Guide - Production deployment instructions
- Troubleshooting Guide - Common issues and solutions
- Deployment Checklist - Pre/post deployment verification
- SaaS Operations - Advanced operational procedures
- API Documentation - Complete API reference
- Database Schema - Database structure and models
- Configuration Guide - Environment variables and settings
- Claude AI Reference - Context and guidelines for AI assistance
The Trading Sentiment Analysis Platform is a full-stack application that combines real-time market data, news sentiment analysis, and automated trading strategies to help users make informed investment decisions through paper trading.
- Backend: FastAPI (Python), SQLAlchemy, PostgreSQL/SQLite
- Frontend: React, Tailwind CSS, Recharts
- Data Sources: Yahoo Finance API, News APIs, Alternative free sources
- Sentiment Analysis: VADER, TextBlob
- Scheduling: Python
schedulelibrary
- ๐ Paper Trading: Risk-free trading simulation with real market data
- ๐ผ Portfolio Tracking: Real-time portfolio value and performance metrics
- ๐ Historical Performance: Interactive charts showing portfolio evolution
- ๐ฏ Position Management: Track open/closed positions with detailed P&L
- ๐ฐ News Sentiment: Automated analysis of financial news and articles
- ๐ Multi-Source Data: Yahoo Finance, MarketWatch, Reuters, CNBC
- ๐ง Smart Recommendations: AI-powered trade suggestions based on sentiment
- ๐ Sentiment Scoring: Comprehensive sentiment metrics per stock
- ๐ Market Scanner: Discover trending stocks from news analysis
- ๐ Stock Watchlists: Track multiple securities with real-time updates
- ๐ Technical Indicators: Market cap, P/E ratios, dividend yields
- ๐จ Alert System: Notifications for significant sentiment changes
- โฐ Automated Data Collection: Scheduled market data updates
- ๐ค Strategy Execution: Automated trading based on sentiment signals
- ๐ Flexible Scheduling: Configurable collection intervals
- ๐ Background Processing: Non-blocking data updates
- ๐ Performance Metrics: Win rate, Sharpe ratio, max drawdown
- ๐ Interactive Charts: Real-time portfolio performance visualization
- ๐ Trade History: Detailed records of all trading activity
- ๐ฐ P&L Analysis: Comprehensive profit/loss tracking
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ React Frontend โโโโโโ FastAPI Backend โโโโโโ Database โ
โ (Port 3000) โ โ (Port 8000) โ โ (SQLite/PG) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโดโโโโโโโโโโ
โ โ
โโโโโโโโโผโโโโโโโโโ โโโโโโโโโผโโโโโโโโโ
โ Data Scheduler โ โ External APIs โ
โ (Background) โ โ (Yahoo, News) โ
โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
- Trading Service: Handles paper trades and portfolio calculations
- Sentiment Service: Analyzes news and generates sentiment scores
- Data Service: Collects and manages market data
- Recommendation Service: Generates AI-powered trading suggestions
- Market Scanner: Discovers trending stocks from news
- Scheduler Service: Manages automated data collection
- Python 3.9+
- Node.js 18+
- Docker (optional)
- Git
For first-time setup with Google OAuth and all features:
๐ Follow the Development Setup Guide for step-by-step instructions.
# Clone the repository
git clone https://github.com/yourusername/trading-platform.git
cd trading-platform
# Start backend
cd backend
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txt
python main.py
# Start frontend (new terminal)
cd frontend
npm install
npm start
# Visit http://localhost:3000Note: For Google OAuth login to work, you'll need to configure Google Cloud credentials. See Google OAuth Setup Guide.
- ๐ Issues? Check the Troubleshooting Guide
- ๐ Deploying? See the Deployment Guide
- ๐ฌ Questions? Review the Claude AI Reference for context
cd backend
# Create virtual environment
python -m venv trading_env
source trading_env/bin/activate # Windows: trading_env\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your settings
# Initialize database
python -c "from database import Base, engine; Base.metadata.create_all(bind=engine)"
# Start the API server
python main.pycd frontend
# Install dependencies
npm install
# Configure environment
cp .env.example .env.local
# Edit .env.local with your settings
# Start development server
npm start-
Start the Application
# Terminal 1: Backend cd backend && python main.py # Terminal 2: Frontend cd frontend && npm start
-
Access the Dashboard
- Open http://localhost:3000
- View portfolio performance and recent trades
- Monitor sentiment analysis results
-
Execute Trades
- Navigate to "Trading" section
- Enter stock symbol, quantity, and trade type
- Submit paper trade (uses real market prices)
-
Run Sentiment Analysis
# Manual analysis curl -X POST http://localhost:8000/api/analyze-sentiment -d '{"symbol": "AAPL"}' # Bulk analysis curl -X POST http://localhost:8000/api/analyze-bulk-sentiment \ -d '{"symbols": ["AAPL", "MSFT", "GOOGL"]}'
-
Automated Data Collection
# Run the scheduler for automated updates cd backend python scheduler.py
# Scan for trending stocks
curl -X POST http://localhost:8000/api/market-scan
# Auto-discover and analyze
curl -X POST http://localhost:8000/api/auto-discover
# Full discovery pipeline
curl -X POST http://localhost:8000/api/discovery-to-recommendations# Run sentiment-based trading strategy
curl -X POST http://localhost:8000/api/run-strategyGET /api/trades- List all tradesPOST /api/trades- Create new tradePOST /api/trades/{id}/close- Close existing tradeDELETE /api/trades/{id}- Delete trade
GET /api/performance- Portfolio metrics and P&LGET /api/portfolio-history- Historical portfolio values
GET /api/sentiment- All sentiment dataGET /api/sentiment/{symbol}- Symbol-specific sentimentPOST /api/analyze-sentiment- Trigger analysis
GET /api/stocks- Tracked stocksPOST /api/stocks- Add stock to trackingGET /api/market-data/{symbol}- Historical market data
For complete API documentation, see Backend API Documentation.
# Database
DATABASE_URL=sqlite:///trading.db
# Trading Settings
INITIAL_BALANCE=100000.0
MAX_POSITION_SIZE=0.05
# Market Hours
MARKET_OPEN_TIME=09:30
MARKET_CLOSE_TIME=16:00
# API Keys (Optional)
NEWS_API_KEY=your_news_api_key
ALPHA_VANTAGE_KEY=your_alpha_vantage_key
# CORS
CORS_ORIGINS=["http://localhost:3000"]REACT_APP_API_URL=http://localhost:8000The scheduler automatically runs:
- Market data collection at market open
- Hourly data updates during trading hours
- Daily sentiment analysis at 10:00 AM
- Strategy execution at 10:30 AM
- End-of-day collection at market close
cd backend
# Install development dependencies
pip install -r requirements-dev.txt
# Run with auto-reload
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Run tests
python -m pytest tests/
# Code formatting
black .
isort .cd frontend
# Install development dependencies
npm install
# Start with hot reload
npm start
# Run tests
npm test
# Build for production
npm run build# Reset database
rm backend/trading.db
python -c "from database import Base, engine; Base.metadata.create_all(bind=engine)"
# View database schema
sqlite3 backend/trading.db ".schema"cd backend
# Run all tests
python -m pytest
# Run with coverage
python -m pytest --cov=.
# Run specific test files
python test_workflow.py
python test_frontend_apis.pycd frontend
# Run tests
npm test
# Run with coverage
npm test -- --coverage# Test workflow script
cd backend
python test_workflow.py
# Test frontend APIs
python test_frontend_apis.pytrading-platform/
โโโ README.md
โโโ backend/
โ โโโ README.md
โ โโโ main.py # FastAPI application
โ โโโ scheduler.py # Background data scheduler
โ โโโ config.py # Configuration management
โ โโโ database.py # Database setup
โ โโโ models.py # SQLAlchemy models
โ โโโ schemas.py # Pydantic schemas
โ โโโ exceptions.py # Custom exceptions
โ โโโ services/ # Business logic
โ โ โโโ trading_service.py
โ โ โโโ sentiment_service.py
โ โ โโโ data_service.py
โ โ โโโ recommendation_service.py
โ โ โโโ market_scanner.py
โ โโโ docs/ # Backend documentation
โ โโโ tests/ # Test files
โ โโโ requirements.txt
โโโ frontend/
โ โโโ README.md
โ โโโ public/
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โโโ pages/ # Page components
โ โ โโโ services/ # API integration
โ โ โโโ App.js
โ โโโ package.json
โ โโโ tailwind.config.js
โโโ docs/ # Project documentation
The platform uses Google OAuth for secure user authentication:
-
Setup Google OAuth:
- Create a Google Cloud project
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add your domain to authorized origins
-
Configure Environment:
# Backend (.env) GOOGLE_CLIENT_ID=your_google_client_id_here.apps.googleusercontent.com JWT_SECRET=your-super-secret-jwt-key-change-this-in-production # Frontend (.env.local) REACT_APP_GOOGLE_CLIENT_ID=your_google_client_id_here.apps.googleusercontent.com
-
Features:
- Secure JWT-based session management
- Automatic token refresh
- Protected routes and API endpoints
- User profile integration
This project is licensed under the MIT License - see the LICENSE file for details.
- ๐ Documentation: Check the
/docsfolder and service-specific READMEs - ๐ Issues: Report technical issues or bugs
- ๐ง Contact: For business inquiries and support
- Real trading integration (Alpaca, Interactive Brokers)
- Advanced technical indicators
- Machine learning models for prediction
- Mobile application
- User authentication with Google OAuth
- Advanced portfolio analytics
- Options trading support
- Real-time WebSocket updates
- Subscription-based SaaS features