Production-grade XAU/USD day-trading research and backtesting system with Supabase data storage.
This system implements a liquidity sweep trading strategy for gold (XAU/USD) with:
- Historical data ingestion from CSV and APIs
- Feature engineering (market structure, liquidity pools, indicators)
- Signal generation (liquidity sweep detection)
- Robust backtesting engine with walk-forward validation
- Comprehensive analytics and metrics
- Paper trading pipeline for forward testing
data_ingestion/ → CSV import, API fetchers, data validation
feature_engineering/ → Indicators, market structure, liquidity detection
signal_generation/ → Strategy rules, entry/exit logic
backtesting/ → Event-driven backtest engine, order simulation
analytics/ → Metrics calculation, robustness tests, reports
live_trading/ → Paper trading loop, state management
orchestration/ → Scheduled jobs, daily pipeline
migrations/ → SQL schema files
tests/ → Unit and integration tests
- Python 3.9+
- Supabase account (free tier: https://supabase.com)
- API keys (optional):
- Polygon.io (for historical XAU/USD data)
- OANDA (for live candles)
# Clone or navigate to project directory
cd "Gold Quant"
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install --upgrade pip
pip install -r requirements.txt
# Note: If ta-lib fails, install TA-Lib C library first:
# macOS: brew install ta-lib
# Ubuntu: sudo apt-get install ta-lib
# Windows: Download from https://github.com/mrjbq7/ta-lib# Copy example environment file
cp .env.example .env
# Edit .env with your credentials
nano .env # or use any text editorRequired settings:
SUPABASE_URL: Your Supabase project URLSUPABASE_KEY: Your Supabase anon/public key
Optional (for API data):
POLYGON_API_KEY: For historical data backfillOANDA_API_KEY&OANDA_ACCOUNT_ID: For live candles
# Create Supabase schema (run SQL migration)
# Navigate to your Supabase project → SQL Editor
# Copy and paste the contents of migrations/001_initial_schema.sql
# Click "Run"Verify tables created:
SELECT table_name FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY table_name;You should see: api_metadata, backtest_runs, features, liquidity_pools, market_structure, metrics, raw_candles, signals, trades, experiments.
python config.pyExpected output:
Configuration Test
==================================================
Supabase URL: https://xxxxx.supabase.co...
Symbol: XAUUSD
Timeframe: 1m
Strategy Version: sweep_v1
Swing Lookback: 3
RR Target: 2.0
==================================================
# Place your CSV file in the project root
# Expected columns: timestamp, open, high, low, close, volume (optional)
python -m data_ingestion.csv_importer --file historical_xauusd_1m.csvpython -m data_ingestion.data_validatorpython -m backtesting.engine --start-date 2024-01-01 --end-date 2024-12-31python -m analytics.dashboard --run-id <backtest_run_id>python -m live_trading.paper_trader- Step 1: Environment setup
- Step 2: Supabase schema
- Step 3: CSV import pipeline
- Step 4: Data validation
- Step 5: API backfill
- Step 6: Feature engineering (indicators)
- Step 7: Market structure detection
- Step 8: Liquidity pool detection
- Step 9: Liquidity sweep detection
- Step 10: Signal generation (V1)
- Step 11: Backtesting engine
- Step 12: Metrics calculation
- Step 13: Walk-forward validation
- Step 14: Parameter sensitivity
- Step 15: Monte Carlo testing
- Step 16: Regime robustness
- Step 17: Analytics dashboard
- Step 18: Paper trading
- Step 19: Experiment logging
- Step 20: Cron job setup
- Swing high/low detection (3-bar lookback)
- Wick-through + close-back sweep detection
- Fixed 2.0R risk-reward
- Session filters (London/NY only)
- Target: Sharpe > 0.8, Win Rate 45-55%
- Market structure shift confirmation (BOS/CHoCH)
- Fair value gap retest entries
- Dynamic stop loss
- Partial take profit (50% at 1.5R, 50% at 3R)
- Volume profile filtering
- Specific killzone timing (London 08:00-09:00, NY 13:30-14:30)
- Trend alignment (200 EMA filter)
- News avoidance (high-impact USD events)
- raw_candles: OHLCV data with source tracking
- features: Computed indicators (ATR, EMA, session type, etc.)
- market_structure: Swing highs/lows, BOS, CHoCH events
- liquidity_pools: Detected liquidity levels and sweep status
- signals: Entry/exit signals with SL/TP levels
- trades: Executed trades with PnL, MAE/MFE
- backtest_runs: Backtest configurations and summary metrics
- metrics: Performance metrics (overall + daily breakdown)
- experiments: Parameter sweep results and robustness tests
- api_metadata: API sync state and rate limit tracking
This is a solo research project. Future: Add contribution guidelines if opening to collaborators.
Private/Proprietary (Update if making open source)
Vaughan Fawcett - [Your contact info]