PQAP Quality Checklist

Before Making Changes

  • [ ] Understand the current state (what exists, what works)
  • [ ] Identify all systems affected by the change
  • [ ] Verify infrastructure exists before configuring deployments to it

Before Committing

  • [ ] Run linter: ./venv/bin/ruff check . --fix && ./venv/bin/ruff format .
  • [ ] Run tests: PYTHONPATH=./src ./venv/bin/python -m pytest tests/ -v --tb=short
  • [ ] Verify no new warnings or errors introduced

Before Pushing

  • [ ] Review all changed files: git diff --stat
  • [ ] Ensure commit message accurately describes changes
  • [ ] Consider: "Will CI pass after this push?"

Before Deploying

  • [ ] Verify target environment exists and is accessible
  • [ ] Verify DNS resolves correctly
  • [ ] Verify secrets are configured in GitHub
  • [ ] Test locally with target environment config

After Pushing

  • [ ] Monitor CI pipeline: gh run list --limit 1
  • [ ] If CI fails, fix immediately before any other work
  • [ ] Verify deployment succeeded (if auto-deploy enabled)

Infrastructure Changes Checklist

Before configuring deployment to a new environment: - [ ] Server/instance exists and is running - [ ] DNS record exists and resolves - [ ] SSL certificate exists (if HTTPS) - [ ] SSH access is configured - [ ] Service user and directories exist - [ ] Required secrets are set in GitHub

Quick Reference Commands

# Lint and format
./venv/bin/ruff check . --fix && ./venv/bin/ruff format .

# Run all tests
PYTHONPATH=./src ./venv/bin/python -m pytest tests/ -v --tb=short

# Run unit tests only (faster)
PYTHONPATH=./src ./venv/bin/python -m pytest tests/unit/ -v --tb=short

# Check CI status
gh run list --limit 5

# View recent CI failure
gh run view --log-failed

Common Issues and Fixes

Issue Fix
E722 bare except Use except Exception: instead of except:
F841 unused variable Remove or prefix with _
E402 import not at top Add # noqa: E402 if intentional (e.g., after load_dotenv)
F401 unused import Remove or add to __all__ for re-exports

System Overview

Polymarket API

Market data source

Data Collector

Every 5 minutes

SQLite Database

Price history + trades

Strategy Engine

Signal generation

ML Model

XGBoost (72% acc)

Execution Engine

Paper trading

Dashboard

You are here!

Telegram

Alerts & updates

Trading Strategies

Each strategy looks for different market inefficiencies:

Dual Arbitrage Active

Finds when YES + NO prices don't add to 100%. Risk-free profit.

Mean Reversion Active

Buys when price drops too far from average, sells when it recovers.

Market Maker Active

Places bid/ask orders to capture the spread.

Time Arbitrage Active

Exploits predictable price patterns at certain hours.

ML Prediction Active

Uses machine learning to predict 6-hour price direction.

Value Betting Disabled

Finds underpriced outcomes based on implied probability.

Data Storage (Single Source of Truth)

All data lives on EC2. Local machines are for development only. The EC2 instance is the authoritative source for all market data, trades, and positions.
Database Purpose Location
market_history.db Price snapshots every 5 minutes (8.2 MB) EC2 (primary)
pqap_prod.db Trades, positions, P&L history EC2 (primary)
paper_trading_state.json Current portfolio state EC2 (primary)

Environment Architecture

EC2 (Production)

  • Runs 24/7
  • All databases live here
  • Executes all trades
  • Single source of truth

Local (Development)

  • For code changes only
  • Syncs code to EC2
  • No production data
  • Can be turned off

Environment Details

Component Details
Dashboard URL https://pqap.tailwindtech.ai
Server AWS EC2 (us-east-1)
SSL Let's Encrypt via Traefik
Mode Paper Trading (simulated)

How It Works (Simple Version)

1. Data Collection: Every 5 minutes, we fetch prices from Polymarket for 50 markets and save them to our database.

2. Analysis: Our strategies analyze this data looking for patterns - like prices that moved too far from normal, or markets where the math doesn't add up.

3. Signals: When a strategy finds an opportunity, it generates a "signal" - a recommendation to buy or sell.

4. Execution: The execution engine takes these signals and simulates trades (paper trading). Eventually, this will place real orders.

5. Monitoring: This dashboard shows you what's happening. Telegram sends alerts for important events.