Professional Algorithmic Trading Framework for Bybit
Build, backtest, and deploy crypto trading strategies with confidence
Documentation | Quick Start | Strategy Guide | Issues
dgbit is a production-ready algorithmic trading framework designed for cryptocurrency traders who want to:
- Backtest strategies with historical data before risking real capital
- Execute automated trades on Bybit spot markets with confidence
- Build custom strategies using a pluggable, extensible architecture
- Monitor positions through a modern web dashboard
- Deploy anywhere with Docker support
Whether you're a quantitative trader developing new strategies or a developer building trading automation, dgbit provides the infrastructure you need.
| Feature | Description |
|---|---|
| Multi-Strategy Support | Wavelet reversal, MA crossover, RSI, Bollinger Bands, and custom strategies |
| Comprehensive Backtesting | In-memory simulation with detailed metrics and interactive Plotly reports |
| Real-time Execution | Live trading on Bybit with position tracking and risk management |
| Service Bus Architecture | Scalable NNG-based messaging for high-frequency operations |
| REST API | Full-featured FastAPI backend with WebSocket support |
| Web Dashboard | Vue 3 frontend for monitoring and control |
| Docker Ready | One-command deployment with docker-compose |
# Install from PyPI
pip install dgbit
# Or with Docker
docker pull cryptuon/dgbitfrom dgbit_core.backtesting import Backtester, BacktestConfig
from dgbit_core.trading.strategy import WaveletReversalStrategy
from dgbit_core.data.data_fetcher import BybitDataFetcher
# Fetch historical data
fetcher = BybitDataFetcher()
data = fetcher.get_kline_data("BTCUSDT", interval="15", limit=1000)
# Configure and run backtest
config = BacktestConfig(
initial_capital=10000.0,
transaction_fee=0.001,
)
backtester = Backtester(config=config)
backtester.strategy = WaveletReversalStrategy(min_signal_threshold=0.75)
result = backtester.run(data)
# View results
print(f"Total Return: {result.metrics['total_return']:.2%}")
print(f"Win Rate: {result.metrics['win_rate']:.2%}")
print(f"Max Drawdown: {result.metrics['max_drawdown']:.2%}")# Using pip installation
dgbit-api
# Or with uvicorn directly
uvicorn dgbit_api.main:app --host 0.0.0.0 --port 8000# Clone the repository
git clone https://github.com/cryptuon/dgbit.git
cd dgbit
# Configure environment
cp dgbit-api/.env.example dgbit-api/.env
# Edit .env with your Bybit API credentials
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f api dgbit Platform
┌─────────────────────────────────────────────────────────────┐
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Vue 3 Dashboard │ │
│ │ Charts | Portfolio | Strategies | Monitoring │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ HTTP / WebSocket │
│ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ FastAPI REST API │ │
│ │ /backtests /jobs /data /strategies /execution │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │ │ │
│ │ NNG IPC │ NNG IPC │ NNG IPC │
│ ▼ ▼ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │
│ │ Data Service │ │ Backtest │ │ Strategy Service │ │
│ │ (Market Data)│ │ Worker │ │ (Signal Gen) │ │
│ └──────────────┘ └──────────────┘ └──────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Shared Trading Core │ │
│ │ Strategies | Backtesting | Position Tracking | Data │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
└───────────────────────────┼──────────────────────────────────┘
▼
Bybit Exchange API
| Strategy | Type | Description |
|---|---|---|
| Wavelet Reversal | Mean Reversion | Daubechies wavelet decomposition for trend reversal detection |
| MA Crossover | Trend Following | Classic moving average crossover signals |
| RSI | Momentum | Relative Strength Index overbought/oversold signals |
| Bollinger Bands | Volatility | Breakout detection using Bollinger Band boundaries |
from dgbit_core.trading.strategy import (
BaseStrategy,
StrategyMetadata,
SignalType,
strategy_registry
)
class MyMomentumStrategy(BaseStrategy):
"""Custom momentum-based trading strategy."""
metadata = StrategyMetadata(
name="my_momentum",
description="Custom momentum strategy with volume confirmation",
author="Your Name",
version="1.0.0",
signal_type=SignalType.MOMENTUM,
parameters={
"lookback_period": {"type": "int", "default": 14},
"volume_threshold": {"type": "float", "default": 1.5},
},
)
def generate_signal(self, data):
# Your strategy logic here
momentum = data['close'].pct_change(self.lookback_period).iloc[-1]
volume_ratio = data['volume'].iloc[-1] / data['volume'].mean()
if momentum > 0.02 and volume_ratio > self.volume_threshold:
return 0.8 # Strong buy signal
elif momentum < -0.02 and volume_ratio > self.volume_threshold:
return 0.2 # Strong sell signal
return 0.5 # Neutral
# Register your strategy
strategy_registry.register(MyMomentumStrategy)| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Service health and stats |
/api/backtests |
POST | Schedule a backtest job |
/api/jobs |
GET | List all jobs |
/api/jobs/{uuid} |
GET | Get job status and results |
/api/data/klines |
GET | Fetch OHLCV data |
/api/data/symbols |
GET | List available trading pairs |
/api/strategies |
GET | List available strategies |
/api/strategies/{name}/signal |
POST | Generate trading signal |
/api/execution/orders |
POST | Place an order |
/api/execution/positions |
GET | Get open positions |
// Connect to event stream
const ws = new WebSocket('ws://localhost:8000/api/ws/events');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Event:', data.type, data.payload);
};
// Event types: job.created, job.completed, job.failed,
// trade.entered, trade.exited, signal.generatedCreate a .env file with your settings:
# Bybit API (required for live trading)
BYBIT_API_KEY=your_api_key
BYBIT_API_SECRET=your_api_secret
BYBIT_TESTNET=true
# Application settings
ENVIRONMENT=development
LOG_LEVEL=INFO
# Default trading parameters
DEFAULT_SYMBOL=BTCUSDT
DEFAULT_INTERVAL=1
# Service bus addresses
NNG_COMMAND_ADDRESS=ipc:///tmp/dgbit_cmd.ipc
NNG_EVENT_ADDRESS=ipc:///tmp/dgbit_evt.ipcComprehensive documentation is available at docs.cryptuon.com/dgbit:
- Installation Guide
- Quick Start Tutorial
- Strategy Development
- Backtesting Guide
- API Reference
- Docker Deployment
# Clone repository
git clone https://github.com/cryptuon/dgbit.git
cd dgbit
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest dgbit-api/tests/
# Run linting
ruff check .
# Start development server
cd dgbit-api
uvicorn dgbit_api.main:app --reloadContributions are welcome! Please read our Contributing Guide for details on:
- Code style and standards
- Pull request process
- Development setup
This project is licensed under the MIT License - see the LICENSE file for details.
Trading cryptocurrencies involves significant risk. This software is provided for educational and research purposes only. Past performance does not guarantee future results. Always test strategies thoroughly with paper trading before using real funds. The authors are not responsible for any financial losses incurred while using this software.
Made with care by Cryptuon