Back to portfolio
Project

ATR-Based Rebalancing Bot

Trading bot connected to the Binance API to maintain a 50/50 BTC/USDT balance, with intelligent volatility management using ATR

Personal

Technologies used

PythonPythonBinance APIBinance APIAPI RESTAPI REST

Project details

About the Project

A personal project born from my passion for cryptocurrencies and automated trading systems. This bot, connected to the Binance API, maintains a balanced portfolio at 50% BTC / 50% USDT by reacting to price movements — buying on dips, selling on rises — while incorporating adaptive volatility management via the Average True Range (ATR).

Problem

A naive rebalancing strategy (systematically buying/selling as soon as a threshold is crossed) has several weaknesses:

  • Prolonged trending markets: the bot can exhaust itself buying during a continuous decline or selling during a sustained rise.
  • Sudden price spikes: a volatility surge can trigger unnecessary orders.
  • Market noise: small fluctuations generate transaction fees without meaningful gains.

Proposed Solution

Implementation of a dynamic sensitivity system based on ATR:

  • ATR calculation over a rolling window (e.g., 14 periods) to measure real market volatility.
  • Proportional action threshold: the bot only acts if the allocation deviation exceeds a multiple of the ATR (e.g., 1.5 × ATR).
  • Noise filtering: micro-movements below a minimum threshold (e.g., 0.5 × ATR) are ignored.
  • Protection against flash moves: temporary order suspension during extreme volatility (> 3 × average ATR).

Key Features

  • Secure connection to the Binance API (encrypted keys, IP whitelisting)
  • Conditional execution of market or limit orders based on liquidity
  • Detailed logging (trades, thresholds, portfolio state)
  • Simulation mode (backtesting on historical data)

Impact & Learnings

  • Robust performance in real-world conditions (tested over 6+ months)
  • Significant fee reduction thanks to intelligent filtering
  • Adaptability: the ATR parameter makes the strategy resilient to shifts in volatility regimes
  • Scalable foundation: ready to integrate other trading pairs, multi-asset strategies, or machine learning

This project combines quantitative finance, systems development, and risk management — an excellent illustration of intelligent automation applied to financial markets.

Experience:Personal