TickAtlas
Tutorial 11 min read · March 28, 2026

Building a Crypto Trading Bot: Complete API Guide

Learn how to build a cryptocurrency trading bot that uses real-time technical indicators from the TickAtlas API to execute automated strategies on BTC, ETH, and more.

CG
By the TickAtlas team

Why Crypto Needs Automation

Cryptocurrency markets trade 24/7/365. No human can watch charts around the clock, but a bot can. Bitcoin can move 5% while you sleep, and without automation, you will miss every overnight opportunity and be exposed to every overnight crash.

The TickAtlas API provides real-time indicators for major crypto pairs including BTCUSD, ETHUSD, and XRPUSD, giving your bot the same data professional traders use to make decisions.

Architecture Overview

Data Layer

TickAtlas API provides OHLCV, RSI, MACD, Bollinger Bands, and 39 other indicators in real time.

Strategy Layer

Your Python code evaluates indicator values against your rules and generates buy/sell signals.

Execution Layer

Signals are forwarded to your crypto exchange API (Binance, Kraken, Coinbase) for order placement.

Monitoring Layer

Logging, Telegram alerts, and dashboard tracking keep you informed 24/7.

Step 1: Fetch Crypto Indicators

Start by fetching Bollinger Bands and RSI for BTCUSD. Bollinger Bands are particularly effective for crypto because of the asset class's high volatility.

python
import requests

API_KEY = "your_api_key_here"
BASE_URL = "https://tickatlas.com/v1"

def get_crypto_signals(symbol: str = "BTCUSD"):
    headers = {"X-API-Key": API_KEY}
    resp = requests.get(f"{BASE_URL}/indicators", params={
        "symbol": symbol,
        "timeframe": "H1",
        "indicators": "RSI_14,BBANDS_20"
    }, headers=headers)
    return resp.json()

data = get_crypto_signals("BTCUSD")
print(data)

Step 2: API Response Structure

The API returns structured JSON with each indicator's current values and interpretive signals:

json
// GET /v1/indicators?symbol=BTCUSD&timeframe=H1&indicators=RSI_14,BBANDS_20
{
  "success": true,
  "data": {
    "symbol": "BTCUSD",
    "timeframe": "H1",
    "indicators": {
      "RSI_14": {
        "value": 28.3,
        "signal": "oversold"
      },
      "BBANDS_20": {
        "upper": 67450.00,
        "middle": 66200.00,
        "lower": 64950.00,
        "bandwidth": 0.0377
      }
    },
    "price": {
      "close": 65100.00
    },
    "timestamp": "2026-03-28T10:00:00Z"
  }
}

Step 3: Bollinger Band Bounce Strategy

This strategy buys when price touches the lower Bollinger Band while RSI confirms oversold conditions. It is a mean-reversion approach that works well in ranging crypto markets.

class BollingerBounceStrategy:
    def __init__(self, rsi_threshold: float = 30):
        self.rsi_threshold = rsi_threshold

    def evaluate(self, price: float, indicators: dict) -> str:
        rsi = indicators["RSI_14"]["value"]
        bb_lower = indicators["BBANDS_20"]["lower"]
        bb_upper = indicators["BBANDS_20"]["upper"]
        bb_middle = indicators["BBANDS_20"]["middle"]

        # Buy: price near lower band + RSI oversold
        if price <= bb_lower * 1.005 and rsi < self.rsi_threshold:
            return "BUY"

        # Sell: price near upper band + RSI overbought
        if price >= bb_upper * 0.995 and rsi > (100 - self.rsi_threshold):
            return "SELL"

        # Exit long at middle band
        if price >= bb_middle and rsi > 50:
            return "CLOSE_LONG"

        return "HOLD"

Step 4: Multi-Pair Scanner

Scan multiple crypto pairs simultaneously to find the best opportunities. The API supports all major crypto instruments.

python
CRYPTO_PAIRS = ["BTCUSD", "ETHUSD", "XRPUSD", "SOLUSD", "ADAUSD"]

def scan_all_pairs():
    strategy = BollingerBounceStrategy()
    signals = []

    for pair in CRYPTO_PAIRS:
        data = get_crypto_signals(pair)
        if data["success"]:
            ind = data["data"]["indicators"]
            price = data["data"]["price"]["close"]
            signal = strategy.evaluate(price, ind)

            if signal != "HOLD":
                signals.append({
                    "pair": pair,
                    "signal": signal,
                    "rsi": ind["RSI_14"]["value"],
                    "price": price
                })

    return signals

# Run scan
opportunities = scan_all_pairs()
for opp in opportunities:
    print(f"{opp['pair']}: {opp['signal']} (RSI: {opp['rsi']:.1f})")

Step 5: Risk Management for Crypto

Crypto is more volatile than forex. Position sizes must be smaller, and stops wider. A 2% account risk per trade is aggressive in crypto — consider starting with 0.5%.

python
def crypto_position_size(account_usd: float,
                         risk_pct: float,
                         entry_price: float,
                         stop_price: float) -> float:
    """Calculate position size in base currency units."""
    risk_amount = account_usd * (risk_pct / 100)
    stop_distance = abs(entry_price - stop_price)
    units = risk_amount / stop_distance
    return round(units, 6)

# Example: $5,000 account, 1% risk, BTC entry at $65,100, stop at $63,800
size = crypto_position_size(5000, 1.0, 65100, 63800)
print(f"Position size: {size} BTC")  # ~0.038 BTC

Step 6: 24/7 Bot Loop

Unlike forex, crypto never closes. Your bot needs to handle weekends, holidays, and exchange maintenance windows gracefully.

python
import time
from datetime import datetime

def run_crypto_bot():
    strategy = BollingerBounceStrategy()
    check_interval = 300  # 5 minutes

    while True:
        try:
            for pair in CRYPTO_PAIRS:
                data = get_crypto_signals(pair)
                if not data.get("success"):
                    continue

                ind = data["data"]["indicators"]
                price = data["data"]["price"]["close"]
                signal = strategy.evaluate(price, ind)

                if signal in ("BUY", "SELL"):
                    print(f"[{datetime.utcnow()}] {signal} {pair} @ {price}")
                    # Forward to exchange API for execution

        except requests.exceptions.RequestException as e:
            print(f"API error: {e}. Retrying in 60s...")
            time.sleep(60)
            continue

        time.sleep(check_interval)

Crypto-Specific Considerations

Volatility Regime Detection

Use Bollinger Band bandwidth to detect whether the market is in a low-volatility squeeze or a high-volatility expansion phase. Different strategies work in each regime.

Exchange Rate Limits

Your exchange API has its own rate limits separate from TickAtlas's. Read our rate limiting guide to manage both.

Flash Crash Protection

Crypto flash crashes happen regularly. Always use stop-loss orders on the exchange side, never rely solely on bot-side monitoring.

Further Reading

Try this with live data

Every account gets $2.50 in free PAYG credits. No card required — paste your API key and run the code above against live broker data.