Bybit Futures
by @sunnyztj
Complete Bybit USDT perpetual futures trading system with risk management, paper trading, and live execution. Use when building a crypto futures trading bot,...
clawhub install bybit-futuresπ About This Skill
name: bybit-futures description: Complete Bybit USDT perpetual futures trading system with risk management, paper trading, and live execution. Use when building a crypto futures trading bot, connecting to Bybit API, implementing stop-loss/take-profit, managing leverage and position sizing, paper trading strategies, backtesting, or deploying a WebSocket-based real-time trading system. Supports EMA crossover, RSI, and custom strategy templates.
Bybit Futures Trading System
Complete trading infrastructure for Bybit USDT perpetual futures contracts.
Quick Start
1. Install dependencies: pip install ccxt websockets numpy requests
2. Copy scripts/config_template.py β config.py, fill in API keys
3. Run paper trading: python scripts/paper_trading_ws.py
4. When validated, switch to live: python scripts/live_trading.py
Architecture
config.py β API keys + risk parameters
risk_manager.py β Position sizing, daily loss limits, max positions
paper_trading_ws.py β WebSocket real-time paper trading
live_trading.py β Live execution (same logic, real orders)
backtest.py β Historical backtesting engine
Risk Management
All trades enforced by risk_manager.py:
Included Strategies
EMA Crossover (ETH)
RSI Mean Reversion (SOL, HYPE, PEPE)
Custom Strategy Template
Seereferences/custom_strategy.md for adding your own signals.WebSocket Real-Time Engine
The paper/live trading engine uses Bybit's WebSocket v5 API:
Deployment
Recommended: systemd service on a VPS.
# Create service file
sudo tee /etc/systemd/system/paper-trading.service << 'EOF'
[Unit]
Description=Paper Trading Bot (WebSocket)
After=network.target[Service]
Type=simple
WorkingDirectory=/root/trading
ExecStart=/usr/bin/python3 paper_trading_ws.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable --now paper-trading
Telegram Notifications
Built-in Telegram push for all events:
Set TG_BOT_TOKEN and TG_CHAT_ID in config.
Files
scripts/config_template.py β Configuration templatescripts/risk_manager.py β Risk management enginescripts/paper_trading_ws.py β WebSocket paper trading botscripts/live_trading.py β Live trading botscripts/backtest.py β Backtesting enginereferences/custom_strategy.md β Guide for adding custom strategiesreferences/bybit_api_notes.md β Bybit API gotchas and tipsπ‘ Examples
1. Install dependencies: pip install ccxt websockets numpy requests
2. Copy scripts/config_template.py β config.py, fill in API keys
3. Run paper trading: python scripts/paper_trading_ws.py
4. When validated, switch to live: python scripts/live_trading.py