PQAP Roadmap & Strategy Document

Generated: 2024-12-24

Current State Summary

Metric Value
Total Value ~$97
Return -3.3%
Starting Capital $100
Total Trades 13,500+
Open Positions 7
Active Strategies 5

1. Will P&L Turn Around?

Root Cause Analysis

The -3.3% loss is primarily from value_bet_v1 (now disabled): - value_bet_v1: -$73.50 (bought but never sold - no exit logic) - market_maker_v1: -$10.25 (small loss, normal for market making) - mean_reversion_v1: +$8.42 (PROFITABLE)

Turnaround Trajectory

Yes, P&L should turn around. Here's why:

  1. Bleeding stopped: value_bet is disabled, no more one-way trades
  2. Profitable strategy active: mean_reversion is net positive (+$8.42)
  3. time_arb deployed: Based on +49% backtest returns, should accelerate recovery
  4. Position value: $72 in positions that can be sold for profit

Expected Timeline

Phase Timeframe Expected P&L
Stabilization Days 1-3 -3% to -1%
Recovery Days 4-7 -1% to +2%
Growth Week 2+ +2% to +10%

Key Risks

  • Market conditions change
  • Strategies generate correlated losses
  • Insufficient trading volume

2. ML Developer Tasks

If you have ML developers available, here are high-value projects:

Priority 1: Price Movement Prediction (2-3 weeks)

Goal: Predict short-term price direction (1-6 hours ahead)

Data Available: - 10,350 price snapshots across 121 markets - Hourly price patterns by market - Volume data

Approach:

Features:
- Price momentum (1h, 6h, 24h returns)
- Volume changes
- Hour of day
- Day of week
- Market category
- Price level (extreme vs uncertain)

Target:
- Binary: Will price be higher/lower in 6h?
- Regression: Expected return in next 6h

Models to try:
- XGBoost (start here)
- LSTM for sequence patterns
- Random Forest for interpretability

Deliverable: Model that predicts direction with >55% accuracy

Priority 2: Optimal Entry/Exit Timing (2 weeks)

Goal: Learn when to enter and exit positions

Approach: - Reinforcement learning agent - State: current position, price history, time of day - Actions: buy, sell, hold - Reward: realized P&L

Deliverable: RL agent that outperforms fixed rules

Priority 3: Market Similarity Clustering (1 week)

Goal: Group similar markets for cross-market signals

Approach: - Embed markets using price behavior - Cluster similar markets - When one market moves, predict others will follow

Deliverable: Market clustering model + cross-market signal generator

Priority 4: Anomaly Detection Enhancement (1-2 weeks)

Goal: Improve current Isolation Forest with better features

Current: Simple price/volume features Enhanced: - Add market sentiment from question text - Add correlation with related markets - Add time-series anomaly detection


3. Additional Data Sources for Edge

High Value (Should Implement)

Source Edge Potential Difficulty
Twitter/X sentiment High Medium
News headlines High Medium
Polymarket API orderbook High Low
Related market prices Medium Low
Google Trends Medium Low

Implementation Priority

  1. Orderbook depth data (immediate)
  2. Already have API access
  3. Shows supply/demand imbalance
  4. Can detect large orders before they move price

  5. Cross-market correlations (this week)

  6. Bitcoin markets correlate with crypto regulation markets
  7. Political markets correlate with each other
  8. Sports outcomes cascade

  9. News/Twitter sentiment (next week)

  10. Use free APIs or scraping
  11. Correlate headlines with price moves
  12. Build sentiment-based signals

  13. Historical resolution data (longer term)

  14. Get resolved market outcomes
  15. Train models on what actually happened
  16. Currently missing this critical data

4. Paper Trading vs Real Trading Separation

Architecture Design

┌─────────────────────────────────────────────────────────┐
│                    PQAP Main Process                     │
├─────────────────────────────────────────────────────────┤
│                                                          │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐ │
│  │  Strategy   │───▶│   Signal    │───▶│  Execution  │ │
│  │   Engine    │    │   Router    │    │   Router    │ │
│  └─────────────┘    └─────────────┘    └──────┬──────┘ │
│                                               │         │
│                     ┌─────────────────────────┼─────┐   │
│                     │                         │     │   │
│              ┌──────▼──────┐          ┌──────▼─────┐│   │
│              │    Paper    │          │    Real    ││   │
│              │   Trading   │          │  Trading   ││   │
│              │   Engine    │          │   Engine   ││   │
│              └─────────────┘          └────────────┘│   │
│                                                      │   │
└─────────────────────────────────────────────────────────┘

Configuration

# configs/prod.yaml
trading_mode: "real"  # or "paper" or "both"

real_trading:
  enabled: true
  max_capital: 500  # USD
  strategies:
    - mean_reversion_v1  # Only proven strategies
  require_confirmation: true  # For large trades

paper_trading:
  enabled: true
  parallel: true  # Run alongside real
  strategies:
    - time_arb_v1  # Test new strategies
    - experimental_v1

Safety Features

  1. Separate wallets: Paper uses simulated balance, real uses actual USDC
  2. Strategy whitelisting: Only approved strategies can trade real money
  3. Position limits: Real trading has stricter limits
  4. Kill switch: Separate kill switches for paper and real
  5. Audit trail: All real trades logged with full context

Implementation Steps

  1. Add TradingMode enum (PAPER, REAL, BOTH)
  2. Create ExecutionRouter to direct signals
  3. Add RealTradingEngine with Polymarket API integration
  4. Add configuration validation
  5. Add real-time P&L tracking for real trades

5. Criteria for Going Live

Minimum Requirements (All Must Pass)

Criterion Target Current
Paper trading profitable >0% over 7 days -3.3% (recovering)
Win rate >50% ~52% (mean_reversion)
Max drawdown <10% -3.3%
Strategies tested 2+ profitable 1 confirmed
System stability 48h+ without crash Stable
API integration tested Successful test trade Not tested

Phased Rollout Plan

Phase 1: API Validation (Day 1) - Add private key to environment - Test with $1 trade (buy and immediately sell) - Verify order execution, fills, settlement - Confirm fee handling

Phase 2: Limited Live ($10 capital, Week 1) - Enable only mean_reversion_v1 (proven profitable) - Max $2 per trade - Run parallel with paper trading - Compare real vs paper performance

Phase 3: Expanded Live ($50 capital, Week 2) - Add time_arb_v1 if paper shows profit - Max $5 per trade - Enable basic market making

Phase 4: Full Live ($500+ capital, Week 3+) - All profitable strategies - Full position sizing - Automated 24/7 operation

Go/No-Go Checklist

Before each phase: - [ ] Previous phase profitable - [ ] No critical bugs in last 48h - [ ] Sufficient capital available - [ ] Risk limits configured - [ ] Telegram alerts working - [ ] Manual kill switch tested


6. Speeding Up Development

Parallel Workstreams

Stream Owner Timeline
ML Price Prediction ML Dev 1 2 weeks
Sentiment Integration ML Dev 2 1 week
Real Trading Engine Claude 2-3 days
Additional Data Sources Claude Ongoing
Strategy Optimization Claude Ongoing

Quick Wins (This Week)

  1. Enable orderbook depth signals - 1 day
  2. Add cross-market correlation - 1 day
  3. Implement real trading engine - 2 days
  4. Test API with small trade - 1 hour (needs private key)

Infrastructure Improvements

  1. Faster data collection: Currently every 5 min, could be every 1 min
  2. More markets tracked: Currently 50, could be 200+
  3. Better logging: Add trade attribution, strategy performance
  4. Alerting: More granular Telegram alerts

Next Steps (Immediate)

  1. Continue monitoring current strategies
  2. Wait for time_arb to generate first signals (next buy hour)
  3. Prepare real trading engine implementation
  4. Document ML developer onboarding

This document will be updated as we make progress.

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_staging.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.