Skip to content

vaughanf1/GoldQuant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gold Quant - XAU/USD Day Trading System

Production-grade XAU/USD day-trading research and backtesting system with Supabase data storage.

System Overview

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

Architecture

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

Setup Instructions

1. Prerequisites

  • Python 3.9+
  • Supabase account (free tier: https://supabase.com)
  • API keys (optional):
    • Polygon.io (for historical XAU/USD data)
    • OANDA (for live candles)

2. Installation

# 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

3. Configuration

# Copy example environment file
cp .env.example .env

# Edit .env with your credentials
nano .env  # or use any text editor

Required settings:

  • SUPABASE_URL: Your Supabase project URL
  • SUPABASE_KEY: Your Supabase anon/public key

Optional (for API data):

  • POLYGON_API_KEY: For historical data backfill
  • OANDA_API_KEY & OANDA_ACCOUNT_ID: For live candles

4. Database Setup

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

5. Test Configuration

python config.py

Expected output:

Configuration Test
==================================================
Supabase URL: https://xxxxx.supabase.co...
Symbol: XAUUSD
Timeframe: 1m
Strategy Version: sweep_v1
Swing Lookback: 3
RR Target: 2.0
==================================================

Usage

Import Historical Data

# 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.csv

Run Data Validation

python -m data_ingestion.data_validator

Run Backtest

python -m backtesting.engine --start-date 2024-01-01 --end-date 2024-12-31

Generate Analytics Report

python -m analytics.dashboard --run-id <backtest_run_id>

Start Paper Trading

python -m live_trading.paper_trader

Development Roadmap

  • 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

Strategy Versions

V1: Simple Liquidity Sweep

  • 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%

V2: Advanced (Future)

  • 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

V3: Killzone Optimized (Future)

  • Specific killzone timing (London 08:00-09:00, NY 13:30-14:30)
  • Trend alignment (200 EMA filter)
  • News avoidance (high-impact USD events)

Project Structure Details

Supabase Tables

  • 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

Contributing

This is a solo research project. Future: Add contribution guidelines if opening to collaborators.

License

Private/Proprietary (Update if making open source)

Contact

Vaughan Fawcett - [Your contact info]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages