In-memory backtester with Plotly reports
BacktestConfig sets initial capital and transaction fees. The Backtester runs against historical OHLCV from Bybit and returns total return, win rate, and max drawdown alongside interactive reports.
v0.x · pip install dgbit · MIT
dgbit gives you a backtester, a strategy base class, a service-bus execution layer, and a REST + WebSocket surface — tuned for Bybit spot. What you test is what you run, and everything the dashboard does is also an API call, so a person, a cron job, or an autonomous agent can drive the same loop.
pip install dgbit
# or
docker pull cryptuon/dgbit // capabilities
BacktestConfig sets initial capital and transaction fees. The Backtester runs against historical OHLCV from Bybit and returns total return, win rate, and max drawdown alongside interactive reports.
Wavelet Reversal (Daubechies decomposition), MA Crossover, RSI, and Bollinger Bands ship in the box. Custom strategies subclass BaseStrategy and register via strategy_registry.
Position tracking and risk management plug into the same strategy interface used for backtests. Live keys are configured via BYBIT_API_KEY / BYBIT_API_SECRET, with a BYBIT_TESTNET flag for staging.
Data, backtest, and strategy services talk to the API over an NNG message bus. A FastAPI backend exposes /backtests, /jobs, /strategies, /execution. A Vue 3 frontend handles monitoring.
Schedule a backtest, request a signal, place an order, and subscribe to job.created, job.completed, job.failed, trade.entered, trade.exited, and signal.generated events at ws://localhost:8000/api/ws/events. The same surface the dashboard uses, open to a scheduler or an autonomous agent.
Clone, copy .env.example to .env, fill in API credentials, run docker-compose up -d. In-process NNG bus and SQLite persistence mean no broker to rent — a single small VPS is the cheapest path to a running instance.
// architecture
The README diagrams the platform as a four-layer stack. Each layer has one responsibility, and the message bus between them is NNG IPC, not HTTP — so a backtest worker can lift a strategy module straight into the live engine without a serialization rewrite. The REST API and WebSocket stream on top mean the whole loop is drivable by an operator that isn't a human.
Full architecture walkthrough →01 / dashboard
Charts, portfolio view, strategy state, and monitoring. Talks to the API over HTTP and WebSocket.
02 / api
/backtests, /jobs, /data, /strategies, /execution. Async, with a WebSocket event stream at /api/ws/events.
03 / workers
Data service, backtest worker, and strategy service exchange messages over an NNG transport (ipc:///tmp/dgbit_cmd.ipc by default).
04 / core
Strategies, backtesting, position tracking, and the Bybit data fetcher. Imported equally by workers, API, and your own scripts.
// first backtest
pip install to a result object in eight linesFetch klines from Bybit, wire up the wavelet reversal strategy, and run the backtester. The result carries the metrics you actually need for an honest go/no-go decision: total return, win rate, and max drawdown.
BybitDataFetcher talks directly to the source.transaction_fee=0.001 is the default; tune per pair.min_signal_threshold=0.75 filters the wavelet signal.from dgbit_core.backtesting import Backtester, BacktestConfig
from dgbit_core.trading.strategy import WaveletReversalStrategy
from dgbit_core.data.data_fetcher import BybitDataFetcher
fetcher = BybitDataFetcher()
data = fetcher.get_kline_data("BTCUSDT", interval="15", limit=1000)
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)
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%}") // who it's for
dgbit is for quantitative traders developing new strategies, developers building trading automation, and teams putting an agent in the loop. It is the operable substrate underneath a strategy — not the strategy, and not a "buy this dip" button. No return claims live here.
You already write strategies in Python and want a backtester that does not hide the assumptions behind it — and a live path that behaves the same.
You are wiring a scheduler or an autonomous agent to a live venue and need a REST + WebSocket surface, position tracking, and risk controls already in place.
You want the data fetcher, position tracking, and risk handling already wired to one exchange instead of abstracted across ten.
// faq
Bybit spot. The data fetcher, execution layer, and built-in strategies are all built around the Bybit API. dgbit is intentionally exchange-specific so the abstractions can be precise rather than lowest-common-denominator.
Both. The Python package is importable for backtests and strategy authoring. The framework also ships a FastAPI server (dgbit-api), an NNG service bus across data/backtest/strategy workers, and a Vue 3 dashboard. You can run as much or as little of that stack as you need.
Four built-in strategies: Wavelet Reversal (Daubechies wavelet decomposition for mean reversion), MA Crossover (trend following), RSI (momentum), and Bollinger Bands (volatility breakout). Custom strategies subclass BaseStrategy and register with strategy_registry.
Install with pip install dgbit, fetch klines with BybitDataFetcher.get_kline_data, configure with BacktestConfig (initial capital, transaction fee), and call Backtester(config).run(data). The result object exposes total_return, win_rate, and max_drawdown.
Yes. Set BYBIT_API_KEY and BYBIT_API_SECRET in .env. Use BYBIT_TESTNET=true to stage against Bybit testnet before flipping to production. The execution endpoint /api/execution/orders places orders; /api/execution/positions returns open positions.
Docker-compose up -d after copying dgbit-api/.env.example to .env. All services come up together. Logs stream from the api container with docker-compose logs -f api.
// explore
Every part of the project, one link away — the feature set, the quickstart, the architecture, comparisons, and the engineering blog.
The backtester, the four built-in strategies, live execution, the NNG service bus, and the FastAPI + WebSocket API — feature by feature.
Read more → Quickstartpip install, fetch klines, run a backtest, read the metrics, and go live on testnet — the shortest path end to end.
Read more → How it worksDashboard, REST API, NNG worker bus, and shared trading core — and how a strategy moves through them without a rewrite.
Read more → Use casesQuant developers, automation and agent builders, and researchers who want exchange-specific precision on Bybit.
Read more → CompareHow dgbit stacks up against Freqtrade and Hummingbot on exchange scope, backtester, architecture, and license.
Read more → BlogNotes on backtesting fidelity, wiring a custom strategy module, and why the workers talk over an NNG service bus.
Read more → FAQExchange support, library vs service, live trading, deployment, and how exchange-specificity aids fidelity.
Read more → AboutWhy dgbit binds to Bybit instead of abstracting across ten exchanges — the design choices and the maintainers.
Read more →Read the docs, clone the repo, run the first backtest, and decide whether the abstractions fit how you think about markets.