Skip to content

Implements pairs-trading strategy backtesting for specified stocks

License

Notifications You must be signed in to change notification settings

Jimlibo/pairs-trading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pairs-trading 🚀

Small project that implements a pairs-trading backtester with a FastAPI backend and a Vite + React frontend.

Contents

  • backend/ — FastAPI app, models (Kalman filter, backtester, metrics), and tests. 🐍
  • frontend/ — Vite + React UI (Tailwind CSS) served by Nginx in Docker. ⚛️
  • infra/docker-compose.yml to run the full stack locally.

Quick start (Docker Compose) 🐳

This repository includes a small Docker Compose setup that builds and runs the backend and frontend containers.

Requirements: Docker and docker-compose installed on your machine.

From the repository root:

cd infra
docker-compose up --build
  • Backend will be available at http://localhost:8000 (API path /api/v1).
  • Frontend will be served at http://localhost:3000 and proxies API calls to the backend.

Stop the stack with:

docker-compose down

Development (local)

Backend 🐍

  • Create and activate a Python virtual environment and install the backend requirements:
python -m venv .venv
source .venv/bin/activate
pip install -r backend/requirements.txt
  • Run the FastAPI app (from backend/):
uvicorn app.main:app --reload --port 8000

Frontend ⚛️

  • Install dependencies and run the dev server (from frontend/web):
cd frontend/web
npm install
npm run dev
  • When running the frontend dev server, set VITE_API_BASE to point to the backend (for example http://localhost:8000/api/v1) if needed.

Running tests ✅

  • Backend tests live in backend/app/tests. Run them with pytest from the repo root (or inside the backend venv):
pytest backend/app/tests -q

License 📄

See LICENSE.