Skip to content

AlexanderWilliams1/CatBoostCryptoTrader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CatBoost Crypto Trader πŸ€–πŸ“ˆ

Crypto trading bot based on CatBoost with ATR and the SMC for TP/SL.

A sophisticated crypto trading bot framework designed for simulation and paper trading (with Testnet support planned). It implements a hybrid strategy, using a CatBoost machine learning model to predict future price direction, which then gates entry signals generated by a set of Smart Money Concepts (SMC) indicators and structure analysis.

✨ Features

  • Hybrid Strategy: Combines the predictive power of a CatBoost classification/regression model with the structural and order flow insights from Smart Money Concepts (SMC) (Swings, Order Blocks, FVGs).
  • Real-time Data: Fetches real-time OHLCV data using the robust ccxt library, supporting major exchanges like Binance.
  • Comprehensive Indicators: Calculates essential technical indicators including RSI, ADX, ATR, VWAP, and Taker Ratio, with Z-Score normalization for ML feature stability.
  • Robust Risk Management: Features an ATR-based stop-loss (ART Stop), automatic breakeven move, and trailing stop based on volatility and profit.
  • Persistence & Logging: Uses SQLite for trade and state logging (TradeDB) and Python's standard logging for runtime transparency.
  • Configurable: Easy configuration via a paper_trade_config.json file for symbol, timeframe, indicators, and risk parameters.
  • Modes: Supports SIMULATE mode for backtesting/paper trading and a TESTNET mode for live-testing with zero financial risk.

πŸš€ Getting Started

Prerequisites

  1. Python 3.8+
  2. Required Libraries:
    pip install ccxt pandas numpy catboost

Installation

  1. Clone the repository:
    git clone https://github.com/AlexanderWilliams1
    cd CatBoostCryptoTrader
  2. The script will automatically create a default configuration file, paper_trade_config.json, on the first run.

Configuration

The bot uses paper_trade_config.json for all settings.

Key Parameters to Adjust:

Parameter Default Description
"exchange" "binance" The target CCXT exchange ID.
"symbol" "BTC/USDT" The trading pair.
"timeframe" "1h" OHLCV data interval (e.g., '1h', '4h', '1d').
"mode" "SIMULATE" Set to SIMULATE for paper trading or TESTNET for test environment (requires API keys).
"atr_mult_stop" 2.0 ATR multiplier for initial stop-loss calculation.
"breakeven_at_pct" 0.05 Move stop to entry price when position is X% in profit.
"min_return_threshold" 0.0001 Minimum predicted return to activate SMC-based entry checks.
"lookback" 100 Lookback window for training the CatBoost model.

Running the Bot

Run the main script:

python MainBot.py

The bot will continuously fetch data, retrain its model periodically, compute SMC signals, and execute simulated trades based on the combined strategy. Trade history is saved to an SQLite database.

🧠 Strategy Logic: ML + SMC

The core strategy operates in a three-stage pipeline:

  1. Data & Indicators: Fetch OHLCV, calculate technical indicators (RSI, ADX, ATR, VWAP, Taker Ratio) and apply Z-Score normalization.
  2. Machine Learning Gating:
    • A CatBoost Classifier/Regressor model is trained (and periodically retrained) on historical data, using the normalized indicators as features.
    • It predicts the probability of a significant price move (class 1) or the future relative return (regression).
    • This prediction must exceed the min_return_threshold to enable a trade entry.
  3. SMC Execution:
    • If the ML prediction is favorable, the bot looks for Smart Money Concepts signals:
      • Order Blocks: Checks if the current price is interacting with a recent Order Block.
      • Market Structure: Verifies the current trend bias (HH/HL or LH/LL) against the predicted direction.
    • An entry is executed only if both the ML prediction and an SMC condition are met.
  4. Risk Management: After entry, the position is protected by an ART Stop (ATR-based with swing structure). The stop-loss is managed dynamically:
    • It moves to breakeven once a profit target (breakeven_at_pct) is hit.
    • It utilizes an ATR-based trailing stop to lock in further profits.

πŸ› οΈ Components

Component Purpose
SMCTrader class The main trading engine, responsible for the trading loop and state management.
ccxt helpers Handles connection, data fetching, and sandbox mode for the exchange.
compute_prediction_series Calculates all technical indicators and runs the CatBoost inference.
detect_swings, compute_structure Detects swing highs/lows and derives market structure bias (SMC).
detect_order_blocks, detect_fvg Detects key SMC zones for potential entry/reaction.
TradeDB SQLite wrapper for persistent storage of trades and bot state.

About

Crypto trading bot based on CatBoost with ATR and the SMC for TP/SL.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages