Adapters that connect DTrader V3 to strategy frameworks such as RQAlpha.
Project description
DTrader V3 Adapter
v3-adapter is the integration layer between DTrader V3 and popular strategy
frameworks. It packages framework-specific adapters so strategy projects can use
DTrader historical market data, real-time quotes, and trading APIs through the framework API they already know.
Current adapter status
| Framework | Package / module | Status | What works now | Known gaps |
|---|---|---|---|---|
| RQAlpha | rqalpha_mod_dtrader |
Usable prototype | Daily A-share bars, quote snapshots, RQAlpha mod loading, simulated backtests, guarded paper/live broker bridge | Trading calendar is weekday-only, no futures/options, no tick history, no real exchange holidays, limited live event source |
| Backtrader | backtrader_dtrader |
Prototype | DTrader daily K-lines as Backtrader PandasData, Cerebro smoke tests, guarded broker bridge |
No dedicated live event loop, no full Store notification lifecycle, simulated accounting remains Backtrader-side |
| vn.py / VeighNa | vnpy_dtrader |
Prototype | DTrader K-lines as vn.py BarData, quote snapshots as TickData, guarded Gateway buy/sell/cancel bridge |
No streaming loop, no full order reconciliation, no CTA engine integration test yet |
| JoinQuant-style | joinquant_dtrader |
Prototype | Local initialize/handle_data runtime, history/get_price/current_data APIs, simulated portfolio, guarded order bridge |
Not a full JoinQuant clone; no factor/finance/query APIs, simple instant-fill backtest model |
| Zipline Reloaded | zipline_dtrader |
Prototype | DTrader daily K-lines as Zipline bundle frames, asset metadata, ingest function, csvdir export, fake-writer tests | No minute writer/live broker bridge yet; full exchange calendar/corporate actions need production validation |
| backtesting.py | backtesting_dtrader |
Prototype | DTrader daily K-lines as backtesting.py OHLCV DataFrame, fake Backtest smoke, guarded signal bridge | Single-asset history-first adapter; no full live broker/order reconciliation |
| vectorbt | vectorbt_dtrader |
Prototype | DTrader OHLCV DataFrame/panel loaders, vectorbt Portfolio.from_signals helper, guarded signal bridge |
Research/data-first adapter; no full live trading engine/order reconciliation |
| NautilusTrader | nautilus_dtrader |
Prototype | Nautilus-style instrument IDs, DTrader K-lines as staged bar records/catalog CSV, quote snapshot client, guarded execution bridge | Not yet native Nautilus DataClient/ExecutionClient or ParquetDataCatalog writer |
| QuantConnect LEAN | lean_dtrader |
Prototype | LEAN-style symbols, DTrader K-lines as TradeBar/custom-data CSV rows, quote snapshot provider, guarded Brokerage-shaped bridge | Not yet native LEAN IDataProvider/IBrokerage plugin or live deployment package |
| Other frameworks | TBD | Planned | Article directories and adapter taxonomy exist | Adapter shape not implemented yet |
Layout
src/rqalpha_mod_dtrader/ # RQAlpha mod: data source, broker, event source, price board
src/backtrader_dtrader/ # Backtrader data feed, store, guarded broker bridge
src/vnpy_dtrader/ # vn.py Datafeed and guarded Gateway bridge
src/joinquant_dtrader/ # JoinQuant-style local runtime and guarded order bridge
src/zipline_dtrader/ # Zipline Reloaded bundle/csvdir data adapter
src/backtesting_dtrader/ # backtesting.py OHLCV loader and signal bridge
src/vectorbt_dtrader/ # vectorbt OHLCV/panel loaders and signal bridge
src/nautilus_dtrader/ # Nautilus-style data catalog staging and guarded execution bridge
src/lean_dtrader/ # LEAN custom data staging and guarded brokerage bridge
configs/ # Runnable RQAlpha configs per example
examples/rqalpha/ # RQAlpha strategy examples
examples/backtrader/ # Backtrader strategy examples
examples/vnpy/ # vn.py datafeed/gateway examples
examples/joinquant/ # JoinQuant-style local strategy examples
examples/zipline/ # Zipline csvdir, bundle registration, and strategy examples
examples/backtesting/ # backtesting.py strategy and signal bridge examples
examples/vectorbt/ # vectorbt research and signal bridge examples
examples/nautilus/ # Nautilus catalog/quote/execution boundary examples
examples/lean/ # LEAN custom-data/quote/brokerage boundary examples
docs/rqalpha/ # Detailed RQAlpha adapter docs
docs/backtrader/ # Backtrader adapter docs
docs/vnpy/ # vn.py adapter docs
docs/joinquant/ # JoinQuant-style adapter docs
docs/zipline/ # Zipline adapter docs
docs/backtesting/ # backtesting.py adapter docs
docs/vectorbt/ # vectorbt adapter docs
docs/nautilus/ # NautilusTrader adapter docs
docs/lean/ # QuantConnect LEAN adapter docs
docs/adapter-quality-gate.md # Required tests before raising adapter maturity
scripts/mock_dtrader_server.py # Local fake DTrader endpoint for smoke tests
tests/ # Unit/regression tests for adapter behavior
Install as a library
Install the adapter library:
pip install dtrader-v3-adapter
After installation, strategy projects can import the framework module they need, for example rqalpha_mod_dtrader, backtrader_dtrader, zipline_dtrader, backtesting_dtrader, vectorbt_dtrader, nautilus_dtrader, or lean_dtrader.
Optional framework extras:
pip install "dtrader-v3-adapter[backtesting]"
pip install "dtrader-v3-adapter[vectorbt]"
pip install "dtrader-v3-adapter[nautilus]"
pip install "dtrader-v3-adapter[lean]"
pip install "dtrader-v3-adapter[zipline]"
Source setup
Use Python 3.10-3.12. RQAlpha currently runs here with Python 3.11.
uv sync
If you want to run without uv run, activate the venv first:
source .venv/bin/activate
Run against a real DTrader service
Installed package usage:
export DTRADER_BASE_URL="https://your-dtrader-endpoint"
export DTRADER_AUTH="your-auth-token"
rqalpha run --config backtest.yml
Source checkout usage:
PYTHONPATH=src uv run rqalpha run --config configs/backtest.yml
Run without a real DTrader service
Start the mock endpoint in one terminal:
PYTHONPATH=src uv run python scripts/mock_dtrader_server.py
Run an example in another terminal:
DTRADER_BASE_URL=http://127.0.0.1:18080 \
DTRADER_AUTH=dev \
PYTHONPATH=src \
uv run rqalpha run --config configs/backtest_buy_and_hold.yml
Available JoinQuant-style examples
| Example | Purpose |
|---|---|
examples/joinquant/run_backtest.py |
Run a local JoinQuant-style moving-average backtest with DTrader historical K-lines |
examples/joinquant/order_guard.py |
Guarded order path; real trading off unless both switches are enabled |
Available Zipline Reloaded examples
| Example | Purpose |
|---|---|
examples/zipline/write_csvdir.py |
Export DTrader historical K-lines into Zipline csvdir-style daily CSV files |
examples/zipline/register_bundle.py |
Register a custom dtrader-a-share bundle for zipline ingest |
examples/zipline/ma_strategy.py |
Zipline moving-average strategy using data.history and simulated orders |
Available backtesting.py examples
| Example | Purpose |
|---|---|
examples/backtesting/backtest_ma.py |
Moving-average backtesting.py run using DTrader historical K-lines |
examples/backtesting/signal_bridge.py |
Guarded signal handoff example; real trading off unless both switches are enabled |
Available vectorbt examples
| Example | Purpose |
|---|---|
examples/vectorbt/ma_parameter_scan.py |
Vectorized moving-average signal backtest using DTrader historical K-lines |
examples/vectorbt/multi_symbol_close.py |
Load multiple DTrader symbols into a close-price matrix |
examples/vectorbt/signal_bridge.py |
Guarded vectorbt signal handoff; real trading off unless both switches are enabled |
Available NautilusTrader examples
| Example | Purpose |
|---|---|
examples/nautilus/write_catalog_csv.py |
Write DTrader historical K-lines into Nautilus-style staged catalog CSV files |
examples/nautilus/quote_snapshot.py |
Map one DTrader quote snapshot into a Nautilus-style quote tick |
examples/nautilus/execution_guard.py |
Guarded execution-client-shaped order handoff; real trading off unless both switches are enabled |
Available QuantConnect LEAN examples
| Example | Purpose |
|---|---|
examples/lean/write_custom_data_csv.py |
Write DTrader historical K-lines into LEAN Custom Data CSV files |
examples/lean/quote_snapshot.py |
Map one DTrader quote snapshot into a LEAN QuoteBar-shaped record |
examples/lean/brokerage_guard.py |
Guarded Brokerage-shaped order handoff; real trading off unless both switches are enabled |
examples/lean/custom_data_algorithm.py |
Shape reference for a LEAN Custom Data strategy project |
Available vn.py examples
| Example | Purpose |
|---|---|
examples/vnpy/query_history.py |
Query DTrader historical K-lines as vn.py-style BarData |
examples/vnpy/gateway_order_guard.py |
Guarded Gateway quote/order path; real trading off unless both switches are enabled |
Available Backtrader examples
| Example | Purpose |
|---|---|
examples/backtrader/backtest_ma.py |
Moving-average Cerebro backtest using DTrader historical K-lines |
examples/backtrader/paper_order_guard.py |
Guarded paper/live order path; real trading off unless both switches are enabled |
Available RQAlpha examples
| Config | Strategy | Purpose |
|---|---|---|
configs/backtest.yml |
examples/rqalpha/backtest_ma.py |
Moving-average crossover using DTrader historical K-lines |
configs/backtest_buy_and_hold.yml |
examples/rqalpha/backtest_buy_and_hold.py |
Minimal one-shot target position example |
configs/backtest_multi_asset_rotation.yml |
examples/rqalpha/backtest_multi_asset_rotation.py |
Multi-symbol momentum rotation with history_bars |
configs/backtest_stop_loss_take_profit.yml |
examples/rqalpha/backtest_stop_loss_take_profit.py |
Position entry plus stop-loss/take-profit exit |
configs/paper.yml |
examples/rqalpha/paper_quote_threshold.py |
Paper/live quote threshold order example; real trading off by default |
configs/paper_order_guard.yml |
examples/rqalpha/paper_order_guard.py |
Paper/live guarded one-order example; real trading off by default |
Read-only real endpoint validation
Use this before enabling any paper/live order path:
export DTRADER_BASE_URL="https://your-dtrader-endpoint"
export DTRADER_AUTH="your-osk-or-auth-token"
export DTRADER_VALIDATE_SYMBOLS="600519,000001"
PYTHONPATH=src .venv/bin/python scripts/validate_dtrader_readonly.py \
--output .cache/dtrader-readonly-validation/report.json
This checks quote, kline, account, positions, and orders query APIs. It does not call buy, sell, or cancel endpoints.
Real trading safety
Paper/live configs default to:
enable_trading: false
paper_fill: true
Real DTrader buy / sell calls require both:
mod:
dtrader:
enable_trading: true
and:
export DTRADER_ENABLE_TRADING=1
Keep this two-switch guard. Do not enable real trading while validating examples.
Verification
PYTHONPATH=src uv run python -m unittest discover -s tests
PYTHONPATH=src uv run python -m unittest tests/test_backtrader_adapter.py -v
PYTHONPATH=src uv run python -m unittest tests/test_vnpy_adapter.py -v
PYTHONPATH=src uv run python -m unittest tests/test_joinquant_adapter.py -v
PYTHONPATH=src uv run python -m unittest tests/test_zipline_adapter.py -v
PYTHONPATH=src uv run python -m unittest tests/test_backtesting_adapter.py -v
PYTHONPATH=src uv run python -m unittest tests/test_vectorbt_adapter.py -v
PYTHONPATH=src uv run python -m unittest tests/test_nautilus_adapter.py -v
PYTHONPATH=src uv run python -m unittest tests/test_lean_adapter.py -v
PYTHONPATH=src uv run python -m unittest tests/test_readonly_validation.py -v
PYTHONPATH=src uv run python -m compileall src examples tests scripts
uv build
For a smoke run with the local mock server:
PYTHONPATH=src uv run python scripts/mock_dtrader_server.py
# second terminal
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run rqalpha run --config configs/backtest.yml
# Backtrader smoke example
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run python examples/backtrader/backtest_ma.py
# vn.py datafeed smoke example
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run python examples/vnpy/query_history.py
# JoinQuant-style smoke example
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run python examples/joinquant/run_backtest.py
# Zipline csvdir export smoke example
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run python examples/zipline/write_csvdir.py
# backtesting.py smoke example
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run python examples/backtesting/backtest_ma.py
# vectorbt multi-symbol data smoke example
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run python examples/vectorbt/multi_symbol_close.py
# Nautilus staged catalog smoke example
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run python examples/nautilus/write_catalog_csv.py
# LEAN custom-data CSV smoke example
DTRADER_BASE_URL=http://127.0.0.1:18080 DTRADER_AUTH=dev PYTHONPATH=src uv run python examples/lean/write_custom_data_csv.py
Promotional article library
Framework integration and promotion articles live in the article repository:
https://github.com/DTrader-store/v3-articles
The adapter repository keeps runnable integration code; v3-articles keeps publishable narratives, tutorials, and series outlines.
More docs
docs/adapter-quality-gate.md— testing and maturity gate for every framework adapterdocs/backtrader/adapter-status.md— Backtrader adapter status and limitationsdocs/vnpy/adapter-status.md— vn.py adapter status and limitationsdocs/joinquant/adapter-status.md— JoinQuant-style adapter status and limitationsdocs/zipline/adapter-status.md— Zipline Reloaded adapter status and limitationsdocs/backtesting/adapter-status.md— backtesting.py adapter status and limitationsdocs/vectorbt/adapter-status.md— vectorbt adapter status and limitationsdocs/nautilus/adapter-status.md— NautilusTrader adapter status and limitationsdocs/lean/adapter-status.md— QuantConnect LEAN adapter status and limitationsdocs/rqalpha/getting-started.md— setup and first rundocs/rqalpha/adapter-status.md— what is actually integrated and what is notdocs/rqalpha/examples.md— example-by-example walkthroughdocs/rqalpha/readonly-validation.md— safe real-endpoint validation without tradingdocs/adapter-roadmap.md— how future framework adapters should be added
License note
RQAlpha source and docs contain commercial-use restrictions. Check licensing before using this adapter in a commercial hosted product.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dtrader_v3_adapter-0.1.0.tar.gz.
File metadata
- Download URL: dtrader_v3_adapter-0.1.0.tar.gz
- Upload date:
- Size: 228.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad9fe0fbe912acccc17783898cbc2c8178c15885599984df703d96ac1279620a
|
|
| MD5 |
5f0a0b0536a42c404258a399c025bbda
|
|
| BLAKE2b-256 |
b8c5947b4e24e25ecf65e409c54c13a284ac9fd63f3eb0e39ae4114c54712e1e
|
File details
Details for the file dtrader_v3_adapter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dtrader_v3_adapter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 64.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd80d45f8f147bafb53de6882b9d004474ce78da886f3073ada2a13ba0c2e7ef
|
|
| MD5 |
69ca345225bc287540eebda02c7b3b13
|
|
| BLAKE2b-256 |
16dc44ba450a293eeca2ac761ec64f11b092499d190cbc64d4c6d7a56e200cee
|