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.

Contact: info@openpit.dev.

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

Both install the binding into target/python, an environment of its own; run Python from it: target/python/bin/python.

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

Both install the binding into target\python; run Python from it: .\target\python\Scripts\python.exe.

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.reviews:
    # Leave unsent. On approval, rerun with OrderReview(confirmed=True).
    # Add already_held=True only if Spot Funds kept its own hold in the
    # committed review.
    result.reservation.commit()
elif 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.12.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.12.0
File Size Uploaded Provenance Actions
openpit-0.12.0.tar.gz 906.9 kB Without provenance Details for openpit-0.12.0.tar.gz

Built distributions (wheels)

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

Total release size: 7.6 MB

Release files / openpit-0.12.0.tar.gz

Download URL openpit-0.12.0.tar.gz
Size 906.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6dd00e2a3a306dc611f020999736a6d861fc2d3954e71b8ff9c5eeb539c8bc35
BLAKE2b-256 checksum
How to use checksums
5f52fe628a9597e7f1a944531344bdb4c2399090cbcc72a596686bcee15fa1f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

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

Download URL openpit-0.12.0-cp310-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
441d2fd13bf8b33573eaecb263a8d1a2e9c0fbcedfc66c599a62112382322546
BLAKE2b-256 checksum
How to use checksums
dbf0e84496bfcdf55cab0ccbc62c921c838c07c6459407519a57f1394fa8b039
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.12.0-cp310-abi3-musllinux_1_2_x86_64.whl

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

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

Download URL openpit-0.12.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
29a2b80d3a147b0175f0d626cd4bad023edaaa8a117a021e2bba809365d8523a
BLAKE2b-256 checksum
How to use checksums
32256952a4f8a6997e0013130f1bd56b28a9781799fb4a19e42b8cc66871f9e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

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

Download URL openpit-0.12.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
4f1b604f92fcadb2b0cad726de9a0888926e2e4a1aba0cc058235664b9f53ccb
BLAKE2b-256 checksum
How to use checksums
9463facf1326ef8b7ea1a7a755a9191f65be5fcbed55fa0b1cd7718f9850cfe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

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

Download URL openpit-0.12.0-cp310-abi3-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
800545903962c1eb18bc01234bc6cbb630202c945e48ec7d6f8628eb89917c79
BLAKE2b-256 checksum
How to use checksums
adccb6d6b3184d2faf558e90324b11bf1033b42aa85fef3ca2defe11c32643d5
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.12.0-cp310-abi3-macosx_10_12_x86_64.whl

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

Security for openpit 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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