Thanks for your interest. This guide covers setup, style, testing, and the PR process.
git clone https://github.com/akmal523/quant
cd quant
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]" --extra-index-url https://download.pytorch.org/whl/cpu
pre-commit install- Linter/formatter: ruff (replaces flake8,
isort, black). Line length 100. Rules
E, F, I, N, W, UP,quantis first-party. Config lives inpyproject.toml. - Types: pyright in
basicmode (pyrightconfig.json). Fix type errors before pushing. - Formatting is mandatory: run
pre-commit run --all-filesbefore committing. - Ruff scope (release gate): zero new findings on changed files, plus all
repo-wide
F(correctness) codes fixed. LegacyE/I/Nfindings are deferred to a tracked issue with a per-module ratchet.
The product doctrine (P1-P14, F1, D1) is binding and recorded in
CONTEXT.md. Two rules bite most often:
- P14 — one copy home. Every user-facing string lives in
quant/ui/copy.pyand is guarded bytests/test_ui_copy.py. Change copy there, never inline; no internal identifiers (run ids, paths, column names, enum values) in UI text. - D1 — recorded-source tests. A feature whose data comes from a live source must have a test that runs the production default path against a checked-in fixture, with the source stubbed at the boundary (never our own functions).
Document the why before the what. Use structural tags:
Intent:why the module/function existsInvariants:conditions that must always holdState Transition:initial -> trigger -> new stateDependencies:external logic relied upon
Keep them terse.
pytest -n auto # full suite + coverage floor- Tests are hermetic: an ephemeral DuckDB is provided by
tests/conftest.py. Never read/write livedata/oroutputs/; build fixtures withtmp_path/tempfile. - Seed all randomness (
np.random.default_rng). - Use the tracer bullet approach: one failing test -> minimal fix -> repeat.
- Coverage floor is a ratchet in
.coveragerc. Never lower it; raise it when coverage improves. - See
tests/README.mdfor the golden-file process.
Conventional Commits are required (drives changelog + versioning):
feat: add regime-conditional leverage cap
fix: cast volume to float before split adjustment
docs: expand CONTEXT glossary
test: isolate portfolio CSV fixtures
chore: bump ruff to 0.6
- Branch from
main. - Keep the diff focused; atomic changes only.
- CI must be green (tests, coverage gate, golden drift gate).
- Update
CHANGELOG.mdunder[Unreleased]when behavior changes. - Do not regenerate golden files in a PR; intentional changes regenerate on
main.
By participating you agree to the Code of Conduct.