A web-based platform for backtesting stock trading strategies using historical and real-time market data. Built with Django, Django REST Framework, and Tailwind CSS.
- Upload datasets (CSV, JSON, XLSX) or use sample datasets (S&P 500, NASDAQ, etc.).
- Support for ML trading models (joblib, keras, pickle).
- Real-time data feed simlation and interactive performance charts with TradingView (previously Chart.js).
- Detailed trade history and key metrics.
- Python 3.9+
- Docker and Docker Compose
- Node.js (optional for frontend development)
-
Clone the repository:
git clone https://github.com/maxhe5919/backtesting.git cd backtesting -
Set up environment variables: Create
.envin the project root:echo "DJANGO_SECRET_KEY=$(python -c 'import secrets; print(secrets.token_urlsafe(50))')" > .env echo "DEBUG=True" >> .env echo "DB_NAME=your_db_name" >> .env echo "DB_USER==your_user_name" >> .env echo "DB_PASSWORD=your_secure_password" >> .env echo "DB_HOST=db" >> .env echo "DB_PORT=5432" >> .env
-
Install Python dependencies (optional, if not using Docker):
python -m venv .venv source .venv/bin/activate pip install -r backend/requirements.txt -
Build and run with Docker:
docker-compose build --no-cache docker-compose up
-
Run migrations:
docker-compose exec web python backend/manage.py makemigrations docker-compose exec web python backend/manage.py migrate
-
Create a superuser:
docker-compose exec web python backend/manage.py createsuperuser -
Access the application: Open
http://localhost:8000in your browser. The admin interface is athttp://localhost:8000/admin.
- Backend: Located in
backend/. Uses Django and Django REST Framework. - Frontend: Located in
frontend/. Uses Django templates, Tailwind CSS, and vanilla JavaScript with TradingView charts. - Static files: Run
python backend/manage.py collectstaticto collect static files. - Database: PostgreSQL runs in a Docker container. Data is persisted in the
postgres_datavolume.
- CSRF protection enabled.
- API authentication with token-based authentication.
- Sensitive data stored in
.env.
This page is designed using Canva AI.
This project is licensed under the MIT License. See the LICENSE file for details.
