Skip to content

Modular trading system for backtesting, live trading, and strategy development. Built with Python, integrates data feeds, broker APIs, and supports custom strategies with extensible architecture.

License

Notifications You must be signed in to change notification settings

NkvMax/trading-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trading System

An end-to-end ML pipeline for regime-aware cryptocurrency trading (ETH-USD): deterministic phase labeling (bull/sideways/bear), feature engineering (50+ indicators), XGBoost for bear regime, Optuna hyperparameter tuning, and VectorBT backtesting. Achieves Sharpe ~1.95, Total Return ~24% (2024–2025). Staged for deep learning with Temporal Fusion Transformer (TFT) on hourly data.

Python XGBoost Optuna VectorBT PyTorch TFT Hydra Pydantic Poetry Stars Forks License

Features

  • Regime-Aware ML: Deterministic phase labeling (bull/sideways/bear) using YAML-configured rules (slope, volatility, hysteresis). XGBoost model for bear regime (daily data), with TFT staged for hourly data.
  • Feature Engineering: 50+ technical indicators (MA, EMA, RSI, MACD, ATR, Bollinger Bands, ADX) via ta library.
  • Tuning & Backtesting: Optuna with time-aware walk-forward CV (60 trials), VectorBT with fees/slippage for realistic backtests.
  • Engineering: Reproducible CLI (tsroot.cli) with typer, Makefile for one-command pipeline (data → features → phases → ML → backtest), Poetry environments (core, tft), no look-ahead bias.

Results

  • Bear Regime (ETH-USD, 2024–2025 test): Sharpe Ratio ~1.95, Total Return ~24.29%, Max Drawdown ~20.17%, 5 trades.
  • Baseline (Buy & Hold): Sharpe ~1.06, Total Return ~3.25%, Max Drawdown ~59.12%.
  • Methodology: 3-day horizon classification/regression, thresholded signals with volatility gating.

Key Metrics

Metric Model Value Buy & Hold
Sharpe Ratio 1.95 1.06
Total Return 24.29% 3.25%
Max Drawdown 20.17% 59.12%
Trades 5 -

Installation & Quick Start

Show Instructions
  1. Clone and install dependencies:
git clone https://github.com/NkvMax/trading-system.git
cd trading-system
poetry install
  1. Configure pipeline in configs/ETH-USD.yaml (phase rules: base_window, thresholds).

  2. Run pipeline (bear regime, ETH-USD):

# Download raw data (yfinance)
make data
# Generate 50+ indicators
make features
# Label bull/sideways/bear
make phases
# Train XGBoost with Optuna
make train
# Run VectorBT backtest
make backtest
  1. For TFT (hourly data, GPU ≥16GB VRAM):
# Use -E tft for deep learning (GPU)
poetry install -E tft
make tft_train

Artifacts saved in data/, models/, logs/. Plots (equity curves, predictions) in logs/.

Methodology

Show Details
  • Phase Logic: YAML-defined rules (e.g., bull: ≥+2% slope in 7d, bear: ≤-2%, sideways: |slope|<0.02 + low volatility <0.015 ATR). Hysteresis prevents jitter. No look-ahead bias.
  • ML Pipeline: XGBoost for bear regime (daily data, 3-day horizon classification/regression). Optuna tuning (60 trials, walk-forward CV). TFT for hourly data (sequence modeling with covariates).
  • Backtesting: VectorBT with realistic fees/slippage, held-out test period (2024–2025). Thresholded signals with volatility gating.
  • Scope: ETH-USD only; extensible to other assets via configs.

Roadmap

Show Roadmap
  • Promote hourly TFT training (≥50k samples, GPU compute).
  • Expand to multiple assets via configs and Makefile guards.
  • Add reporting: per-phase equity curves, turnover analysis, drift monitoring.

Contributing

Pull requests welcome!

License

MIT

About

Modular trading system for backtesting, live trading, and strategy development. Built with Python, integrates data feeds, broker APIs, and supports custom strategies with extensible architecture.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published