dgbit Documentation¶
Algorithmic Trading Framework for Bybit
Backtest and execute crypto trading strategies against Bybit markets.
What is dgbit?¶
dgbit is an algorithmic trading framework that bundles a strategy framework, an in-memory backtester, a FastAPI service, an NNG-based service bus, and a Vue 3 dashboard. The shipped data fetcher and live trader integrate with Bybit via the pybit SDK. Bybit's spot category is the default; the underlying BybitAdapter also accepts linear (USDT-M perpetuals) and inverse categories.
The dgbit_data.adapters package additionally contains scaffolding for Binance, Coinbase, and OKX (via ccxt), but the runtime data fetcher (BybitDataFetcher) and RealtimeTrader are Bybit-only today.
-
Quick Start
Get up and running with dgbit in minutes
-
Trading Strategies
Learn how to use and create trading strategies
-
Backtesting
Test your strategies with historical data
-
Docker Deployment
Deploy dgbit with Docker in production
Key Features¶
Built-in Strategies¶
Four strategies register themselves with the global strategy_registry at import time:
wavelet_reversal(WaveletReversalStrategy) - delegates toPricePredictor, which uses a Daubechies wavelet decompositionma_crossover(MACrossoverStrategy) - SMA/EMA/WMA crossover, configurable viama_typersi(RSIStrategy) - RSI overbought/oversold thresholdingbollinger_bands(BollingerBandStrategy) - position of the close within the bands, no separate breakout mode
All four inherit from BaseStrategy and emit a signal in the [0.0, 1.0] range.
Backtesting¶
- In-memory simulation in
dgbit_core.backtesting.Backtester - Train/test split (
train_split, default0.7) - Metrics:
total_trades,win_rate,total_return,max_drawdown,profit_factor,avg_return,avg_duration,final_capital,wins,losses - Interactive Plotly HTML report via
Backtester.plot_results(...) - Configurable
transaction_fee(applied on both entry and exit); slippage is not modelled
Service Architecture¶
- FastAPI app exposing endpoints under
/api - NNG (
pynng) command/event/data sockets, addresses configured via env vars - Vue 3 dashboard in
dgbit-ui/ docker-compose.ymlwithapi,backtest-worker,ui, anddata-serviceservices
Installation¶
Quick Example¶
from dgbit_core.backtesting import Backtester, BacktestConfig
from dgbit_core.trading.strategy import WaveletReversalStrategy
from dgbit_core.data.data_fetcher import BybitDataFetcher
# BybitDataFetcher requires Bybit API credentials (use testnet=True for read-only public data)
fetcher = BybitDataFetcher(api_key="", api_secret="", testnet=True)
data = fetcher.get_kline_data("BTCUSDT", interval="15", limit=1000)
backtester = Backtester(config=BacktestConfig(initial_capital=10000.0))
backtester.strategy = WaveletReversalStrategy()
result = backtester.run(data)
print(f"Total Return: {result.metrics['total_return']:.2%}")
print(f"Win Rate: {result.metrics['win_rate']:.2%}")
Community¶
- GitHub Issues: Report bugs or request features
- Discussions: Ask questions and share ideas
License¶
dgbit is released under the MIT License.
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 before using real funds.