Skip to main content

OpenPit (Pre-trade Integrity Toolkit) for Python

Verify Release Python versions PyPI License

openpit is an embeddable pre-trade risk SDK for integrating policy-driven risk checks into trading systems from Python.

For an overview and links to all resources, see the project website openpit.dev. For the Python API guide and reference, see openpit.readthedocs.io. For full project documentation, see the repository README. For conceptual and architectural pages, see the project wiki.

Versioning Policy (Pre‑1.0)

Before the 1.0 release OpenPit follows a relaxed Semantic Versioning:

  • PATCH releases carry bug fixes and small internal corrections.
  • MINOR releases 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.

Getting Started

Visit the PyPI package.

Examples

Runnable end-to-end examples live in examples/python/:

Install

For normal end-user installation, use the published PyPI package:

pip install openpit
POSIX (Linux, macOS, etc)

Install Rust and Python 3.10+. Just is optional but recommended.

If you need local development/debugging, clone this repository and build from source with Maturin:

With Just:

just python-develop-debug

Local release build:

just python-develop-release

Manual:

python3 -m venv .venv
.venv/bin/python -m pip install -r ./requirements.txt
.venv/bin/python -m maturin develop --manifest-path bindings/python/Cargo.toml
.venv/bin/python -m maturin develop --release --manifest-path bindings/python/Cargo.toml
Windows

Install rustup, target x86_64-pc-windows-msvc, and Python 3.10+. Just is optional but recommended.

With Just:

rustup target add x86_64-pc-windows-msvc
just python-develop-debug
just python-develop-release

Manual:

rustup target add x86_64-pc-windows-msvc
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r .\requirements.txt
.\.venv\Scripts\python.exe -m maturin develop `
  --manifest-path bindings/python/Cargo.toml `
  --target x86_64-pc-windows-msvc
.\.venv\Scripts\python.exe -m maturin develop `
  --release `
  --manifest-path bindings/python/Cargo.toml `
  --target x86_64-pc-windows-msvc

Quick Start

import openpit
from openpit.param import AccountId, Price, Quantity, Side, TradeAmount, Volume
from openpit.pretrade.policies import (
    OrderSizeBrokerBarrier,
    OrderSizeLimit,
    build_order_size_limit,
)

# Build the engine once, at start-up: one broker-wide fat-finger cap.
engine = (
    openpit.Engine.builder()
    .no_sync()
    .builtin(
        build_order_size_limit().broker_barrier(
            OrderSizeBrokerBarrier(
                limit=OrderSizeLimit(
                    max_quantity=Quantity("500"),
                    max_notional=Volume("1000000"),
                ),
            ),
        ),
    )
    .build()
)

order = openpit.Order(
    operation=openpit.OrderOperation(
        instrument=openpit.Instrument("AAPL", "USD"),
        account_id=AccountId.from_int(99224416),
        side=Side.BUY,
        trade_amount=TradeAmount.quantity("1000"),
        price=Price("185"),
    ),
)

result = engine.execute_pre_trade(order=order)
if result.ok:
    # Send the order to the venue, then commit or roll the reservation back.
    result.reservation.commit()
else:
    for reject in result.rejects:
        # OrderSizeLimitPolicy [OrderQtyExceedsLimit]: order quantity exceeded
        print(f"{reject.policy} [{reject.code}]: {reject.reason}")

The explicit two-stage flow, drop copy, and post-trade reports are described on the Pre-trade Pipeline page.

What Is Inside

Local Testing

POSIX (Linux, macOS, etc)

Recommended local flow:

With Just:

just test-python-debug
just test-python-unit-debug
just test-python-integration-debug

Manual:

python3 -m venv .venv
.venv/bin/python -m pip install -r ./requirements.txt
.venv/bin/python -m maturin develop --manifest-path bindings/python/Cargo.toml
.venv/bin/python -m pytest bindings/python/tests

Run only unit tests:

.venv/bin/python -m maturin develop --manifest-path bindings/python/Cargo.toml
.venv/bin/python -m pytest bindings/python/tests/unit

Run only integration test:

.venv/bin/python -m maturin develop --manifest-path bindings/python/Cargo.toml
.venv/bin/python -m pytest bindings/python/tests/integration
Windows

Optional: Just.

With Just:

just test-python-debug
just test-python-unit-debug
just test-python-integration-debug

Manual:

python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r .\requirements.txt
.\.venv\Scripts\python.exe -m maturin develop `
  --manifest-path bindings/python/Cargo.toml `
  --target x86_64-pc-windows-msvc
.\.venv\Scripts\python.exe -m pytest bindings/python/tests
.\.venv\Scripts\python.exe -m pytest bindings/python/tests/unit
.\.venv\Scripts\python.exe -m pytest bindings/python/tests/integration

For full build/test command matrix (manual and just), see the repository README.

Metadata

Release files for openpit 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openpit 0.9.0
File Size Uploaded
openpit-0.9.0.tar.gz 723.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for openpit 0.9.0
File
openpit-0.9.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
openpit-0.9.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
openpit-0.9.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
openpit-0.9.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
openpit-0.9.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
openpit-0.9.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 6.9 MB

Release files / openpit-0.9.0.tar.gz

Download URL openpit-0.9.0.tar.gz
Size 723.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8832179263024dbda2062c193248c0f5cda9d787496005bf96b7f2844fe83dce
BLAKE2b-256 checksum
How to use checksums
ada97160b23b5201f14bbe0095adb490fcca8d65c5e8b2ff562ae5aec2b5eecf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / openpit-0.9.0-cp310-abi3-win_amd64.whl

Download URL openpit-0.9.0-cp310-abi3-win_amd64.whl
Size 996.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
63fde51db490821ec0d792df1c96b417a5a6dc1aafb306b7349a88764c5e414d
BLAKE2b-256 checksum
How to use checksums
ee91825c2d90d06181dfa193b5788e0044214a84b5bd1816e2d1f342abe48588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / openpit-0.9.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL openpit-0.9.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
dc961592360fbd865feefda11dc0ab272806b9275f5e70879facff028d303b07
BLAKE2b-256 checksum
How to use checksums
d2cf9b1cc25baa9862147503fcd7aef80d5cd4f1482b964c50e28033dec99211
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / openpit-0.9.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL openpit-0.9.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
9fb0ae5369a3add673115178769d3e9ff9b46052b3e84d73dcc5ddd59fdd2036
BLAKE2b-256 checksum
How to use checksums
0b792a8ac568c1b63a6da4c8a1d316927f8486d1f8866e4669d55e3cf848bdb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / openpit-0.9.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL openpit-0.9.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.0 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
2207e18391114b66fa818857f9ee0f5abd8f4e03b1e049f8f33d08bb48216ea3
BLAKE2b-256 checksum
How to use checksums
c66998c943b2863a1a2989b9f281d790423581e5046239d955c7a2a7b20470da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / openpit-0.9.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL openpit-0.9.0-cp310-abi3-macosx_11_0_arm64.whl
Size 954.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
586183cb84ce9da9b1fc20ce20440c87225e8522eb27a8cfd135d80f4a614e84
BLAKE2b-256 checksum
How to use checksums
8b9a49738e758cebb326530717c64deadb6100908f61256fc192182ba486a882
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / openpit-0.9.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL openpit-0.9.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
86ab31f169ba28ddc735a12ddcf046528047f1b7e9b84a70ec3386278a4ba87e
BLAKE2b-256 checksum
How to use checksums
fefcbd43d64f0e5126d75175ad6b88381a1d4625d908d6ad43bcf863eea79c0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release history Release notifications | RSS feed

This release

0.9.0 This release

7 release files

0.8.3

7 release files

0.8.2

7 release files

0.8.1

7 release files

0.8.0

7 release files

0.7.0

7 release files

0.6.0

7 release files

0.5.0

7 release files

0.4.0

7 release files

0.3.0

7 release files

0.2.0

7 release files

0.1.3

7 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page