← Back

Bybit Trading Bot

Automated crypto futures trading bot for Bybit exchange.

Quick Start

# 1. Setup
chmod +x setup.sh && ./setup.sh

# 2. Configure
nano .env   # Add your API keys + Telegram bot token

# 3. Run
pm2 start ecosystem.config.js
# or manually:
source venv/bin/activate && python src/main.py

Get API Keys

  1. Bybit API: bybit.com → Account → API Management → Create New Key

    • Permissions: Read-Write, Derivatives (Trade)
    • IP whitelist recommended for production
  2. Telegram Bot: Message @BotFather → /newbot → copy token

    • Get your Chat ID: message @userinfobot

Architecture

src/
├── main.py              # Entry point
├── config.py            # All settings from .env
├── exchange/
│   ├── client.py        # Bybit API wrapper (orders, positions, market data)
│   ├── order_manager.py # TP/SL placement and management
│   └── symbols.py       # Instrument info cache
├── core/
│   ├── position.py      # Position tracking
│   ├── risk.py          # Risk management (sizing, limits)
│   └── trade_log.py     # JSON trade journal
├── strategies/
│   ├── base.py          # Strategy interface (ABC)
│   └── (your strategies here)
├── bot/
│   ├── telegram_bot.py  # Alerts + commands
│   └── formatters.py    # Message templates
└── utils/
    ├── logger.py        # Logging with Vancouver timestamps
    └── time_utils.py    # Timezone helpers

Adding a Strategy

  1. Create src/strategies/my_strategy.py
  2. Subclass BaseStrategy from src/strategies/base.py
  3. Implement: scan(), on_signal(), check_position(), get_config()
  4. Register in src/main.py

Telegram Commands

Configuration (.env)

See .env.example for all available settings.

📜 Git History

dd32dfdchore: initial commit — version control setup5 weeks ago
Show last diff
Loading...