# dgbit > A Python algorithmic trading framework for Bybit. Backtest, build, and deploy crypto trading strategies with a strategy plugin model, in-memory backtester, FastAPI service bus, and Vue 3 dashboard. MIT licensed. ## What dgbit Is dgbit is an open-source framework, not a hosted product. It is distributed as a Python package on PyPI (`pip install dgbit`) and as a Docker image (`cryptuon/dgbit`). The repository ships: - A core Python library (`dgbit_core`) with the strategy base class, backtester, position tracker, and Bybit data fetcher. - A FastAPI REST backend (`dgbit_api`) with WebSocket support. - Worker services for data, backtesting, and strategy execution, connected by an NNG IPC service bus. - A Vue 3 dashboard for charts, portfolio view, strategy state, and monitoring. - Docker Compose configuration that brings every service up together. The framework is intentionally exchange-specific. The data fetcher, position model, and built-in strategies are written against the Bybit API, not abstracted across many exchanges. ## Architecture (from the README) The platform is a four-layer stack: 1. **Vue 3 dashboard.** HTTP + WebSocket to the API. Handles charts, portfolio, strategies, monitoring. 2. **FastAPI REST API.** Exposes `/api/health`, `/api/backtests`, `/api/jobs`, `/api/data/klines`, `/api/data/symbols`, `/api/strategies`, `/api/strategies/{name}/signal`, `/api/execution/orders`, `/api/execution/positions`. 3. **Worker services.** Data service, backtest worker, strategy service. Talk to the API over NNG IPC (`NNG_COMMAND_ADDRESS`, `NNG_EVENT_ADDRESS`). 4. **Shared trading core.** Strategies, backtesting, position tracking, data fetcher. Imported by every layer above. The WebSocket event stream at `/api/ws/events` emits: `job.created`, `job.completed`, `job.failed`, `trade.entered`, `trade.exited`, `signal.generated`. ## Built-in Strategies - **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. Custom strategies subclass `BaseStrategy`, declare `StrategyMetadata` (name, description, author, version, signal_type, parameter schema), implement `generate_signal(self, data)`, and register with `strategy_registry.register(...)`. ## Configuration Environment variables in `.env`: - `BYBIT_API_KEY`, `BYBIT_API_SECRET`, `BYBIT_TESTNET` — Bybit API credentials and testnet toggle. - `ENVIRONMENT`, `LOG_LEVEL` — application settings. - `DEFAULT_SYMBOL`, `DEFAULT_INTERVAL` — default trading parameters. - `NNG_COMMAND_ADDRESS`, `NNG_EVENT_ADDRESS` — service bus addresses. ## Who Should Use It - Quant developers writing strategies in Python who want a backtester whose assumptions are explicit. - Trading automation engineers shipping bots that need a REST API, WebSocket event stream, and service-bus architecture. - Researchers building on Bybit who want exchange-specific precision rather than multi-exchange abstraction. ## Honest Comparisons - **vs Freqtrade**: Freqtrade has broader exchange support via CCXT and a richer hyperopt story. dgbit binds to Bybit so the data, fee, and execution layer match one exchange exactly. Pick Freqtrade for multi-exchange and hyperopt; pick dgbit for Bybit-specific precision and the FastAPI + Vue 3 stack. - **vs Hummingbot**: Hummingbot is built around market making, arbitrage, and liquidity provision across many CEXes and DEXes. dgbit is built around backtesting and executing directional/signal-based strategies on Bybit. Pick Hummingbot for market making or arbitrage; pick dgbit for signal strategies with backtester support. ## Pages - / - /features/ - /quickstart/ - /how-it-works/ - /use-cases/ - /faq/ - /about/ - /contact/ - /blog/ - /blog/why-bybit-specific-matters-for-backtesting-fidelity/ - /blog/wiring-a-custom-strategy-module/ - /blog/why-an-nng-service-bus/ - /compare/ - /compare/freqtrade/ - /compare/hummingbot/ - /404/ - /rss.xml - /sitemap-index.xml ## Page Summaries - **/** — Homepage: hero with the one-line value prop (algorithmic trading infrastructure for Bybit, in Python), six capability cards (backtesting, strategies, execution, architecture, API, deployment), the architecture stack, a first-backtest code sample, audience targeting (quant developers, trading automation engineers, researchers on Bybit), FAQ, an Explore section linking every top-level page, and CTAs to GitHub and the docs. - **/features/** — The full feature set: in-memory backtester with Plotly reports, the four built-in strategies and the BaseStrategy plugin model, live execution on Bybit spot, the NNG service bus, the FastAPI REST + WebSocket API surface, and docker-compose deployment. - **/quickstart/** — The shortest path from install to a result: pip install dgbit (or the Docker image), fetch klines with BybitDataFetcher, configure BacktestConfig, run the Backtester, read total return / win rate / max drawdown, and move to live on testnet. - **/how-it-works/** — A walkthrough of the four-layer stack — the Vue 3 dashboard, the FastAPI REST API, the NNG worker bus (data, backtest, and strategy services), and the shared trading core — and how a strategy moves through them without a serialization rewrite. - **/use-cases/** — Who dgbit is built for and why: quant developers who want an honest backtester, automation and agent builders wiring a REST + WebSocket loop to a live venue, and researchers who want exchange-specific precision on Bybit. - **/faq/** — Answers to the questions to settle before committing: which exchange is supported, library vs service, the included strategies, how to run a backtest, how to run live, how to deploy, why exchange-specificity aids fidelity, and the license. - **/about/** — The case for an exchange-specific framework: why dgbit binds to Bybit instead of abstracting across many exchanges, the strategy plugin model versus a DSL, what ships in the box, how to engage as a user or contributor, maintainer note, and a risk disclaimer. - **/contact/** — How to reach the dgbit team at Cryptuon. - **/blog/** — Index of engineering posts on backtesting fidelity, strategy authoring, and the service bus. - **/blog/why-bybit-specific-matters-for-backtesting-fidelity/** — Deep dive on why a single-exchange data fetcher and fee model produce more honest backtest numbers than a multi-exchange abstraction. Covers data, execution, and cost fidelity, the abstraction tax, and what dgbit's simulator is explicitly not modeling. - **/blog/wiring-a-custom-strategy-module/** — Walk-through of `BaseStrategy`, `StrategyMetadata`, `generate_signal`, and `strategy_registry.register`. Explains the lifecycle from notebook to backtest to paper trade to live, and the choices the framework deliberately does not make for you. - **/blog/why-an-nng-service-bus/** — The architectural choice to use NNG IPC between the API and the worker services instead of HTTP. Covers the command/event split, what it means for strategy authors, and operational implications for anyone running the stack. - **/compare/** — Index of head-to-head comparisons against other open-source trading frameworks. - **/compare/freqtrade/** — Comparison table and pick-when guidance for Freqtrade. Covers exchange support, backtester, strategy interface, architecture, and license. Acknowledges Freqtrade wins on breadth and hyperopt. - **/compare/hummingbot/** — Comparison table and pick-when guidance for Hummingbot. Covers primary use case (market making vs signal strategies), exchange support, backtester depth, and architecture. Acknowledges Hummingbot wins on CEX+DEX coverage and market-making templates. - **/404/** — Custom not-found page. - **/rss.xml** — RSS feed of blog posts. - **/sitemap-index.xml** — XML sitemap for crawlers.