dgbit
Professional Algorithmic Trading Framework for Bybit
Build, backtest, and deploy crypto trading strategies with confidence
Documentation | Quick Start | Strategy Guide | Issues
Why dgbit?
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.
Key Features
| 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 |
Quick Start
Installation
# Install from PyPI
pip install dgbit
# Or with Docker
docker pull cryptuon/dgbit
Run Your First Backtest
from 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%}")
Start the API Server
# Using pip installation
dgbit-api
# Or with uvicorn directly
uvicorn dgbit_api.main:app --host 0.0.0.0 --port 8000
Docker Deployment
# 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
Architecture
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
Built-in Trading Strategies
| 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 |
Creating Custom Strategies
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)
API Reference
REST Endpoints
| 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 |
WebSocket Events
// 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.generated
Configuration
Create 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.ipc
Documentation
Comprehensive documentation is available at docs.cryptuon.com/dgbit:
- Installation Guide
- Quick Start Tutorial
- Strategy Development
- Backtesting Guide
- API Reference
- Docker Deployment
Development
# 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 --reload
Contributing
Contributions are welcome! Please read our Contributing Guide for details on:
- Code style and standards
- Pull request process
- Development setup
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
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
Metadata
Release files for dgbit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dgbit-0.1.0.tar.gz | 82.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dgbit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 196.1 kB
Release files / dgbit-0.1.0.tar.gz
| Download URL | dgbit-0.1.0.tar.gz |
|---|---|
| Size | 82.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e5627675be9ba176a057aa5da9232b3bd673d4209eb8c01b217200076d485f5
|
|
BLAKE2b-256 checksum How to use checksums |
f100dc961855413d6207fcee6f0bd4555c0cfd06bf0c4e2bec594b77e5d164ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / dgbit-0.1.0-py3-none-any.whl
| Download URL | dgbit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 113.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dcb74320b2ddb5a6d7d525de8b3a411d9474756ac15084ce75e96ec606f06742
|
|
BLAKE2b-256 checksum How to use checksums |
ec8bb55b958735d03e4ca897f9256a6abcb7779b45585a1a5f166c460ca97375
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|