OpenPit is a workspace for embeddable pre-trade risk components. Before an order reaches a venue, it passes through a deterministic risk pipeline that can reject the request, reserve state, and later absorb post-trade outcomes back into the same control system.
- The engine is configured once during platform initialization.
- Each order first goes through lightweight start-stage checks. This stage makes fast decisions and runs controls that must observe every request, including rejected ones.
- If the order passes the start stage, the caller receives a deferred request object. The heavier pre-trade stage has not run yet.
- When the deferred request is executed, the engine runs the main-stage
risk policies and collects all registered mutations. If any policy
rejects, the collected state is rolled back. If the stage succeeds, the
caller receives a reservation. The shortcut
engine.execute_pre_trade(order)composes the two stages into one call when manual request handling is not needed. - The reservation must be finalized explicitly:
commitkeeps the reserved state,rollbackcancels it. Dropping the reservation without finalization rolls it back automatically. - Post-trade reports are fed back into the engine so policies that depend on realized outcomes can update their state.
The current implementation focuses on the pre-trade pipeline, a small set of built-in controls, and an API for building project-specific strategy and risk policies. Built-ins:
- P&L kill switch
- sliding-window rate limit
- per-settlement order size limits
Custom policies that maintain state across calls can use the built-in Storage abstraction. Synchronization is selected once at engine construction and applied transparently, with no overhead in single-threaded embeddings.
The engine is intentionally in-memory and deterministic, designed to be embedded into a larger trading system rather than replace one. For custom policy APIs:
Before the 1.0 release OpenPit follows a relaxed Semantic Versioning:
PATCHreleases carry bug fixes and small internal corrections.MINORreleases may introduce new features and may also change the public interface.
Breaking API changes can appear in minor releases before 1.0. Pick version
constraints that tolerate API evolution during the pre-stable phase.
- openpit.dev - project website with an overview and links to all documentation.
- Go SDK README - integrate OpenPit from Go.
- Python SDK README - the
openpitPython package. openpitcrate README - Rust interface with a runnable example.- C SDK README - C ABI for environments that integrate through C.
- examples/ - end-to-end runnable scenarios.
- Wiki - conceptual pages and architecture notes.
- Rust toolchain
- Python
>=3.10if you build or test Python bindings maturinandpytestif you build or test Python bindings- Go
1.22if you build or test Go bindings
python3 -m venv .venv
source .venv/bin/activate
pip install -r ./requirements.txtWith Just:
just buildManual:
cargo build --workspaceWith Just:
just python-develop
just python-develop-releaseManual:
maturin develop --manifest-path bindings/python/Cargo.toml
maturin develop --release --manifest-path bindings/python/Cargo.tomlThe recommended Python test flow is to run maturin develop before
pytest. This runs against the current checkout (including a dirty
worktree).
The Go SDK consumes the native runtime through CGo. Build the FFI library first:
cargo build -p openpit-ffi --release --lockedGo tests then expect the path to that library through
OPENPIT_RUNTIME_LIBRARY_PATH. The variable is needed only for local
development inside the pit repository - consumers installing the SDK with
go get do not need to set it.
With Just:
# All tests:
just test-all
# Rust:
just test-rust
# Python:
just test-python
just test-python-unit
just test-python-integration
# Go:
just test-go
just test-go-raceManual:
# All tests:
cargo test --workspace
maturin develop --manifest-path bindings/python/Cargo.toml
python -m pytest bindings/python/tests
# Rust:
cargo test --workspace
# Python
maturin develop --manifest-path bindings/python/Cargo.toml
python -m pytest bindings/python/tests
python -m pytest bindings/python/tests/unit
python -m pytest bindings/python/tests/integration
# Go:
cargo build -p openpit-ffi --release --locked
cd bindings/go
# Linux:
export OPENPIT_RUNTIME_LIBRARY_PATH="$(pwd)/../../target/release/libopenpit_ffi.so"
# macOS: use libopenpit_ffi.dylib instead.
go test ./...
go test -race ./...