Thanks for helping make QuantBT faster, clearer, and easier to trust.
QuantBT is a research-first backtesting package, but changes must still be reviewable and reproducible. The most valuable contributions are precise bug reports, parity tests, execution-model improvements, documentation, examples, and small well-tested engine changes.
- Use
devfor all active work. - Do not commit directly to
main. - Open pull requests into
dev. mainis reserved for protected, reviewed releases.- Keep pull requests focused. Avoid mixing engine logic, docs, notebooks, and formatting-only changes in one PR.
Clone the repository and work from the QuantBT root:
git clone https://github.com/BobbyAxerol/quantbt.git
cd quantbt
git checkout devInstall the core development dependencies:
python -m pip install -U pip
python -m pip install numpy pandas numba matplotlib seaborn pytestOptional Nautilus validation support:
python -m pip install nautilus-traderWhen working inside the broader research workspace, use the parent environment
and set PYTHONPATH so imports resolve consistently:
PYTHONPATH=/path/to/pool_alpha pytest quantbt/tests- Create a feature branch from
dev.
git checkout dev
git pull
git checkout -b feature/clear-short-name- Make the smallest coherent change.
- Add or update tests for behavior changes.
- Update docs or examples when the public API, sizing semantics, margin model, or fill policy changes.
- Run the relevant test set.
- Open a pull request into
dev.
Use the smallest test set that proves the change, then expand when touching shared engine behavior.
pytest tests/test_endpoint.py
pytest tests/test_phase2_native_vectorized.py
pytest tests/test_phase3_native_event.py
pytest tests/test_phase5_nautilus_adapter.pyOn memory-constrained hosts, use the isolated release runner. It starts a new pytest process after each bounded shard so Numba/pandas imports from an earlier group cannot accumulate into the next one:
poetry run python tools/run_test_shards.py --profile release --max-files-per-shard 8For changes to causal walk-forward behavior, also run the deterministic certification tool. It writes its JSON outside the repository by default:
poetry run python tools/audit_phase50_wfo_causal.pyFor changes to accounting, sizing, margin, liquidation, fees, funding, or Nautilus parity, include at least one deterministic test with a small synthetic dataset. Real-data tests are useful for smoke checks, but they should not be the only proof.
For product, Rust boundary, registry, or public-API changes, run the generated contract gates before opening a PR:
make test-contractssrc/quantbt is the authoritative Python tree. The root mirror is transitional
and generated from src; after a source edit, synchronize it with:
python tools/sync_source_mirror.py --src-to-root
python tools/sync_source_mirror.py --checkDo not hand-edit generated product artifacts. Update the source registry, run the generators, and commit source plus generated output together.
Please make assumptions explicit. A good engine change should document:
- signal contract: raw weight, target unit, target notional, structural ladder, or explicit order intent;
- execution timing: close fill, next-bar fill, high/low limit touch, or event-driven order fill;
- cost model: fee convention, slippage, funding, borrow, spread, and turnover;
- account model: cash, equity, initial margin, buying power, leverage, maintenance margin, and liquidation;
- position model: one-way/netting, long-short, pyramiding, portfolio netting, or market-neutral constraints.
If two engines intentionally differ, add a parity note or test that explains why.
- Prefer clear, small functions over clever abstractions.
- Keep vectorized/Numba kernels deterministic and allocation-light.
- Avoid hidden global state in engines and adapters.
- Keep public endpoint behavior stable unless the PR is explicitly a breaking change.
- Add comments only where they clarify non-obvious domain logic.
Before opening a PR, confirm:
- The PR targets
dev. - The change is scoped to one topic.
- Tests were run and the command is included in the PR.
- New behavior is documented.
- Engine assumptions are explicit.
- No unrelated dirty files are included.
Use concise imperative commit messages:
fix: align nautilus pct equity sizing
feat: add dca ladder limit fill audit
docs: explain margin buying power
test: cover portfolio netting modes
When reporting that two backtests differ, include:
- data range, timeframe, symbol, and row count;
- endpoint/backend used;
- sizing mode and
use_pyramiding; - initial capital, leverage, margin settings;
- fee, slippage, funding configuration;
- expected vs actual metrics;
- first timestamp where equity, position, fill, or cash diverges.
This makes the difference debuggable instead of mysterious.