A full-stack web application for paper trading with real-time market data, advanced charting, and portfolio management features.
- Overview
- Features
- Tech Stack
- Quick Start
- Project Structure
- Installation
- Running the Application
- API Documentation
- Configuration
- Development
- Testing
- Deployment
- Troubleshooting
- Documentation
- Contributing
Trade Paper is a comprehensive paper trading platform that allows users to practice trading strategies with real-time market data without risking actual capital. The application features professional-grade charting, real-time market data from Yahoo Finance, stop-loss monitoring, and a responsive interface designed for desktop and mobile devices.
- π Professional Charts - Full-screen candlestick and line charts with Lightweight Charts & Recharts
- π― Stop Loss Monitoring - Real-time monitoring with Celery background tasks
- πΉ Live Market Data - Real-time data from Yahoo Finance API
- π Secure Authentication - JWT-based user authentication
- π± Responsive Design - Works seamlessly on mobile, tablet, and desktop
- β‘ Fast & Scalable - Built with modern async frameworks and task queues
-
Real-Time Charts
- Candlestick charts for technical analysis
- Line charts for historical trend analysis
- Full-screen display capability
- Professional styling with smooth animations
-
Market Data Integration
- Real-time ticker data from Yahoo Finance
- Historical price data
- Market indicators and technical analysis
- Multi-ticker support
-
Portfolio Management
- Track paper trades
- Stop-loss monitoring
- Position management
- Trade history
-
User Management
- Secure registration and login
- JWT token-based authentication
- User profiles
- Portfolio tracking
-
Responsive Design
- Mobile optimization (< 480px)
- Tablet support (480-768px)
- Desktop layout (> 768px)
- Large screen support (> 1024px)
- Celery worker for async task processing
- Celery Beat for scheduled tasks
- Real-time stop-loss monitoring
- Task queue management
- Flower dashboard for task monitoring
- Django admin interface
- Redis for caching and message brokering
- Comprehensive logging
- Framework: Django 5.2.4 + Django REST Framework
- API: FastAPI 0.115.0
- Authentication: JWT (djangorestframework-simplejwt)
- Task Queue: Celery 5.4.0 + Celery Beat
- Message Broker: Redis 6.2.0
- Real-Time: Channels 4.2.2 + Channels Redis
- Database: PostgreSQL / SQLite (development)
- Data Processing: Pandas 2.2.0
- Market Data: Yahoo Finance (via yfinance)
- Framework: React 18.2.0
- Build Tool: Vite 5.0.0
- Router: React Router v6
- HTTP Client: Axios
- Charting: Lightweight Charts 4.2.1 + Recharts 2.12.7
- Icons: Lucide React
- CSS: Custom CSS with responsive design
- Task Monitoring: Flower 2.0.1
- CORS: django-cors-headers
- Environment: python-decouple, python-dotenv
- WebSockets: Uvicorn with Websockets support
- Python: 3.9 or higher
- Node.js: 18 or higher
- Redis: Running locally or in Docker
- Git: For version control
# 1. Clone and navigate to project
git clone <repository-url>
cd trade_paper
# 2. Setup Python environment
python -m venv venv
venv\Scripts\activate # Windows
# or source venv/bin/activate # Linux/Mac
# 3. Install Python dependencies
pip install -r requirements.txt
# 4. Setup frontend
cd frontend
npm install
cd ..
# 5. Start Redis
# Docker: docker run -d -p 6379:6379 redis:latest
# Or native installation: redis-server
# 6. Run migrations
cd backend
python manage.py migrate
cd ..
# 7. Start all services (see Running the Application section)trade_paper/
βββ backend/ # Django + FastAPI backend
β βββ main/ # Main app with core logic
β β βββ models.py # Database models
β β βββ views.py # API views
β β βββ serializers.py # DRF serializers
β β βββ services/
β β β βββ market.py # Market data service
β β βββ tasks.py # Celery tasks
β β βββ urls.py # URL routing
β βββ accounts/ # User authentication
β β βββ models.py # User model
β β βββ views.py # Auth endpoints
β β βββ serializers.py # Auth serializers
β βββ tickers/ # Ticker data (FastAPI)
β β βββ app.py # FastAPI app
β β βββ data/ # Data files
β βββ trade_paper/ # Project settings
β β βββ settings.py # Django settings
β β βββ urls.py # Main URL config
β β βββ wsgi.py # WSGI config
β β βββ asgi.py # ASGI config (WebSockets)
β β βββ celery.py # Celery configuration
β βββ manage.py # Django management
β βββ main.py # FastAPI entry point
β βββ db.sqlite3 # Development database
β
βββ frontend/ # React + Vite frontend
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ api/ # API client
β β βββ context/ # React context
β β βββ hooks/ # Custom hooks
β β βββ services/ # Services
β β βββ styles/ # Global styles
β β βββ App.jsx # Main component
β β βββ main.jsx # Entry point
β βββ public/ # Static assets
β βββ package.json # NPM dependencies
β βββ vite.config.js # Vite configuration
β βββ index.html # HTML template
β
βββ _MD/ # Documentation
β βββ QUICK_START.md # Quick setup guide
β βββ DELIVERY_SUMMARY.md # Project delivery summary
β βββ CHART_ENHANCEMENT_GUIDE.md # Chart features
β βββ STOP_LOSS_IMPLEMENTATION.md # Stop loss logic
β βββ TICKER_DETAIL_IMPLEMENTATION.md # Ticker details
β βββ ... # More documentation
β
βββ requirements.txt # Python dependencies
βββ package.json # Root package config
βββ README.md # This file
βββ pyvenv.cfg # Virtual env config
# 1. Navigate to project root
cd trade_paper
# 2. Create virtual environment
python -m venv venv
venv\Scripts\activate
# 3. Install Python dependencies
pip install -r requirements.txt
# 4. Create .env file (optional)
# Add environment variables as needed
echo DEBUG=True > backend/.env
# 5. Setup database
cd backend
python manage.py migrate
python manage.py createsuperuser # Create admin user
cd ..# 1. Navigate to frontend
cd frontend
# 2. Install dependencies
npm install
# 3. Create .env file if needed
# Add API endpoint configuration
# 4. Build for production (optional)
npm run build
# 5. Return to root
cd ..Option 1: Docker (Recommended)
docker run -d --name trade-paper-redis -p 6379:6379 redis:latestOption 2: Windows Native
# Download from https://github.com/microsoftarchive/redis/releases
# Install and run
"C:\Program Files\Redis\redis-server.exe"Option 3: WSL
wsl redis-serverTerminal 1: Redis Server
# Docker
docker start trade-paper-redis
# OR native/WSL
redis-serverTerminal 2: Django API Server
cd backend
python manage.py runserver
# Runs on http://localhost:8000Terminal 3: Celery Worker
cd backend
celery -A trade_paper worker -l infoTerminal 4: Celery Beat (Scheduler)
cd backend
celery -A trade_paper beat -l infoTerminal 5: React Frontend
cd frontend
npm run dev
# Runs on http://localhost:5173Terminal 6 (Optional): Flower Monitoring
cd backend
flower -A trade_paper --port=5555
# Dashboard at http://localhost:5555| Service | URL | Purpose |
|---|---|---|
| Frontend | http://localhost:5173 | React application |
| Django API | http://localhost:8000 | REST API |
| Admin Panel | http://localhost:8000/admin | Django admin |
| Flower Dashboard | http://localhost:5555 | Task monitoring |
| Redis | localhost:6379 | Message broker |
# Test Redis
redis-cli ping
# Output: PONG
# Test Django API
curl http://localhost:8000/api/health
# Should return success
# Check Celery
curl http://localhost:5555 # Opens Flower dashboard
# Check Frontend
# Open http://localhost:5173 in browserUser Registration
POST /api/accounts/register/
Content-Type: application/json
{
"username": "string",
"email": "string",
"password": "string"
}
User Login
POST /api/accounts/login/
{
"username": "string",
"password": "string"
}
Response:
{
"access": "token",
"refresh": "token"
}
Get Ticker Information
GET /api/main/ticker/<symbol>/
Get Historical Data
GET /api/main/ticker/<symbol>/history/?period=1mo
Get Real-Time Prices
GET /api/main/ticker/<symbol>/price/
Get User Portfolio
GET /api/main/portfolio/
Create Trade
POST /api/main/trades/
{
"symbol": "AAPL",
"quantity": 10,
"price": 150.50,
"trade_type": "BUY"
}
Set Stop Loss
POST /api/main/trades/<id>/set-stop-loss/
{
"stop_price": 140.00
}
Located at backend/trade_paper/settings.py
Key Settings:
DEBUG- Set to False in productionALLOWED_HOSTS- Configure for your domainDATABASES- Database configurationCELERY_BROKER_URL- Redis URL (default: redis://localhost:6379)CORS_ALLOWED_ORIGINS- Frontend URL for CORS
Create backend/.env:
DEBUG=False
SECRET_KEY=your-secret-key
DATABASE_URL=postgresql://user:password@localhost/tradepaper
REDIS_URL=redis://localhost:6379
ALLOWED_HOSTS=localhost,127.0.0.1,yourdomain.comCreate frontend/.env:
VITE_API_URL=http://localhost:8000/api
VITE_WS_URL=ws://localhost:8000The project follows:
- Backend: PEP 8 (Python)
- Frontend: ESLint configuration (JavaScript/React)
# Backend tests
cd backend
python manage.py test
# Frontend tests
cd frontend
npm test-
Backend API:
- Create model in
main/models.py - Create serializer in
main/serializers.py - Add endpoint in
main/views.py - Register URL in
main/urls.py
- Create model in
-
Frontend:
- Create component in
frontend/src/components/ - Add page in
frontend/src/pages/ - Register route in
App.jsx
- Create component in
-
Database Migrations:
cd backend python manage.py makemigrations python manage.py migrate
Django Debugging:
# In views.py
import logging
logger = logging.getLogger(__name__)
logger.debug("Debug message")Celery Task Debugging:
# Run worker with debug logging
celery -A trade_paper worker -l debugReact Debugging:
- Use React DevTools browser extension
- Check browser console for errors
- Use
console.log()or debugger breakpoints
Charts:
- Candlestick chart displays correctly
- Line chart displays correctly
- Full-screen mode works
- Charts responsive on mobile
- Chart switching works smoothly
Authentication:
- User registration works
- Login/logout functions
- JWT tokens refreshed correctly
- Protected routes require authentication
Market Data:
- Real-time prices update
- Historical data loads
- Multiple tickers work
- Data refreshes periodically
Stop Loss:
- Stop loss can be set
- Alerts trigger at threshold
- Monitoring works continuously
# 1. Set production environment
export DEBUG=False
export SECRET_KEY=<generate-strong-key>
# 2. Collect static files
cd backend
python manage.py collectstatic --noinput
# 3. Run migrations
python manage.py migrate --noinput
# 4. Build frontend
cd ../frontend
npm run build
# 5. Run with production server
cd ../backend
gunicorn trade_paper.wsgi:application --workers 4- Heroku: Use Procfile and buildpacks
- AWS: EC2 with RDS, ElastiCache for Redis
- Docker: Containerize with Docker Compose
- PythonAnywhere: Simple Python hosting
- Digital Ocean: App Platform or Droplet
Issue: "Connection refused" to Redis
Solution: Ensure Redis is running
docker ps # Check if Redis container is running
redis-cli ping # Test Redis connection
Issue: Celery tasks not processing
Solution:
1. Verify Redis is running
2. Check Celery worker logs
3. Verify CELERY_BROKER_URL in settings
Issue: CORS errors in frontend
Solution:
1. Add frontend URL to CORS_ALLOWED_ORIGINS
2. Check browser console for specific error
3. Verify API_URL in frontend .env
Issue: Database migrations fail
Solution:
cd backend
python manage.py migrate --run-syncdb # Recreate all tables
Issue: Frontend won't connect to API
Solution:
1. Verify Django server is running (http://localhost:8000)
2. Check VITE_API_URL in frontend/.env
3. Test API endpoint: curl http://localhost:8000/api/
- Check the
_MD/folder for detailed documentation - Review Django/React documentation
- Check Celery/Redis logs
- Use Flower dashboard to monitor tasks
Comprehensive documentation is available in the _MD/ folder:
- QUICK_START.md - Get up and running in 5 minutes
- DELIVERY_SUMMARY.md - Project overview and features
- CHART_ENHANCEMENT_GUIDE.md - Charting details
- STOP_LOSS_IMPLEMENTATION.md - Stop loss logic
- TICKER_DETAIL_IMPLEMENTATION.md - Market data
- VERIFICATION_CHECKLIST.md - QA checklist
- INDEX.md - Documentation index
- Fork or clone the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes with clear commit messages
- Test your changes:
npm test(frontend) /python manage.py test(backend) - Push to branch:
git push origin feature/your-feature - Create a Pull Request with description
[BACKEND/FRONTEND] Feature: Brief description
- Details of change
- Details of change
Fixes #issue-number
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or suggestions:
- π§ Email: support@tradepaper.app
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Docs: See
_MD/folder
Built with:
- Django & Django REST Framework
- React & Vite
- Lightweight Charts & Recharts
- Yahoo Finance API
- Redis & Celery
- PostgreSQL
Last Updated: May 31, 2026
Status: Production Ready β
Version: 1.0.0