โ† ะะฐะทะฐะด

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.