Skip to content

debpramanik/ICT-SMC-BOT

Repository files navigation

ICT/SMC Trading Bot for Binance

An automated cryptocurrency trading bot that implements Inner Circle Trader (ICT) and Smart Money Concepts (SMC) strategies on Binance. Built with Lumibot and the SmartMoneyConcepts library.

Overview

This bot uses institutional trading concepts to identify high-probability trading opportunities in cryptocurrency markets. It detects key market structures like Order Blocks, Fair Value Gaps, and Break of Structure patterns to make informed trading decisions.

Features

  • Smart Money Concepts Integration

    • Order Blocks (OB) detection
    • Fair Value Gaps (FVG) identification
    • Break of Structure (BOS) and Change of Character (CHoCH) signals
    • Swing High/Low detection
    • Discount/Premium zone analysis
  • Advanced Risk Management

    • Configurable position sizing
    • Maximum concurrent positions limit
    • Risk:Reward ratio enforcement
    • Daily loss limits
    • Stop-loss and take-profit management
  • Multiple Trading Modes

    • Backtesting with historical data
    • Paper trading (simulated)
    • Live trading on Binance
  • Robust Architecture

    • YAML-based configuration system
    • Comprehensive logging and error handling
    • API error recovery with retry mechanism
    • Performance tracking and metrics

Strategy Logic

Long Entry Conditions

The bot enters long positions when ALL of the following conditions are met:

  1. Price is in the discount zone (below 50% of recent range)
  2. Bullish Order Block is present
  3. Fair Value Gap detected (optional)
  4. Bullish Break of Structure confirmed (optional)

Exit Conditions

  • Price reaches premium zone (above 50%)
  • Stop loss hit (below order block low)
  • Take profit based on risk:reward ratio

Requirements

  • Python 3.8+
  • Binance account with API credentials
  • Required Python packages (see requirements.txt)

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd "ICT SMC BOT"
  2. Install dependencies

    pip install -r requirements.txt
  3. Set up environment variables

    • Copy .env.example to .env
    • Add your Binance API credentials to .env
    cp .env.example .env
    # Edit .env with your credentials
  4. Configure your strategy

    • Edit config_backtest.yaml for backtesting
    • Create config_paper.yaml for paper trading
    • Create config_live.yaml for live trading

Configuration

Environment Variables (.env)

BINANCE_API_KEY=your_api_key_here
BINANCE_API_SECRET=your_api_secret_here

Trading Configuration (config_*.yaml)

Key configuration sections:

  • binance: API settings and rate limits
  • trading: Symbol, timeframe, lookback period
  • risk_management: Position sizing, stop loss, take profit
  • smc_indicators: Enable/disable specific SMC indicators
  • logging: Log level and output settings

See config_backtest.yaml for detailed configuration options.

Usage

Backtesting

Run historical backtests to evaluate strategy performance:

from lumibot.backtesting import YahooDataBacktesting
from datetime import datetime
from ict_strategy_template import ICTStrategy

ICTStrategy.backtest(
    YahooDataBacktesting,
    backtesting_start=datetime(2024, 1, 1),
    backtesting_end=datetime(2024, 12, 31),
    budget=10000,
    benchmark_asset="SPY"
)

Paper Trading

Test your strategy with simulated trading:

from lumibot.brokers import Ccxt
from lumibot.traders import Trader
from config import load_config
from ict_strategy_template import ICTStrategy

# Load paper trading config
config = load_config(mode='paper')
broker_config = config.binance.get_broker_config()

# Initialize broker and strategy
broker = Ccxt(broker_config)
strategy = ICTStrategy(broker=broker)

# Run paper trading
trader = Trader()
trader.add_strategy(strategy)
trader.run_all()

Live Trading

WARNING: Live trading involves real money. Use at your own risk!

  1. Ensure you have sufficient funds in your Binance account
  2. Test thoroughly in paper trading mode first
  3. Start with small position sizes
  4. Monitor the bot closely during initial live runs
# In ict_strategy_template.py, change mode to 'live'
config = load_config(mode='live')

# Then run the bot
python ict_strategy_template.py

Project Structure

ICT SMC BOT/
├── ict_strategy_template.py   # Main strategy implementation
├── config.py                   # Configuration management
├── config_backtest.yaml        # Backtest configuration
├── logger.py                   # Logging utilities
├── error_recovery.py           # Error handling and retry logic
├── data_mapper.py              # Data format conversion
├── requirements.txt            # Python dependencies
├── .env                        # Environment variables (not in git)
├── .env.example                # Environment template
├── logs/                       # Log files directory
└── README.md                   # This file

Risk Disclaimer

IMPORTANT: This bot is provided for educational purposes only.

  • Cryptocurrency trading carries substantial risk
  • Past performance does not guarantee future results
  • Never trade with money you cannot afford to lose
  • Always test thoroughly in paper trading mode first
  • The authors are not responsible for any financial losses

Monitoring and Logs

The bot creates detailed logs in the logs/ directory:

  • Trade execution logs
  • Signal generation logs
  • Performance metrics
  • Error and exception logs

Monitor these logs regularly to ensure the bot is operating as expected.

Troubleshooting

Common Issues

API Connection Errors

  • Verify your API credentials in .env
  • Check if your IP is whitelisted on Binance
  • Ensure API has necessary permissions (read + trade)

Insufficient Data Errors

  • Increase lookback_period in config
  • Check if the trading pair has enough historical data

Order Execution Failures

  • Verify you have sufficient balance
  • Check position size calculations
  • Review Binance API rate limits

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Test your changes thoroughly
  4. Submit a pull request

Resources

License

This project is provided as-is for educational purposes. Use at your own risk.

Support

For issues and questions:

  • Open an issue on GitHub
  • Review existing documentation
  • Check logs for detailed error messages

Remember: Always practice proper risk management and never invest more than you can afford to lose.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors