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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openpit-0.8.1.tar.gz (686.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

openpit-0.8.1-cp310-abi3-win_amd64.whl (977.9 kB view details)

Uploaded CPython 3.10+Windows x86-64

openpit-0.8.1-cp310-abi3-musllinux_1_2_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

openpit-0.8.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

openpit-0.8.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

openpit-0.8.1-cp310-abi3-macosx_11_0_arm64.whl (938.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

openpit-0.8.1-cp310-abi3-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file openpit-0.8.1.tar.gz.

File metadata

  • Download URL: openpit-0.8.1.tar.gz
  • Upload date:
  • Size: 686.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.21

File hashes

Hashes for openpit-0.8.1.tar.gz
Algorithm Hash digest
SHA256 f16e06597383978b659449a7ccd7779c9680cb12c1d1584852981ac57e089b01
MD5 d758fd3a64c4123000c69bdd2f36515b
BLAKE2b-256 61a111c1ffdc3abb7f0ba92d6ab2976e9e7bd46425b96a72a5abc729849df326

See more details on using hashes here.

File details

Details for the file openpit-0.8.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: openpit-0.8.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 977.9 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.11

File hashes

Hashes for openpit-0.8.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 70d012ce73997360b4fa101a35702113d78b6870a1c7af0e23965065bdccbfd2
MD5 c34ca8c25d3033f9ab9b0a4d8a435048
BLAKE2b-256 a7e6a89b622032c9d6c51db67b5d0ededce69c25127d1392a61d6368a7e6f261

See more details on using hashes here.

File details

Details for the file openpit-0.8.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for openpit-0.8.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b66795c5faebba90668152ebc40423cd4bca8127e7e5ff3eb47243716b37359e
MD5 04ab80c967ab5358b24d76e22f208707
BLAKE2b-256 bec305ab3dabca1435b1e230f6f4a1b8e83769641abe340e446b7dbc7d4976b7

See more details on using hashes here.

File details

Details for the file openpit-0.8.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for openpit-0.8.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a8b7229fbdd0c42fe3d2456e5ec792c86913cddc142fe70c38c1cc9159b7ba4
MD5 81bf6a7d27ff8ddd2fb07b04387b85d5
BLAKE2b-256 0b8bf72f430508e3a9954af857e490af979226a2bc0441d26b1e1be8e5f3049c

See more details on using hashes here.

File details

Details for the file openpit-0.8.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for openpit-0.8.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d6f95e55b075e3a56f751be480302fe67a2715b5a1213fe6a141f9156e943c3f
MD5 c2df75770520a02ac95aae05e61494ce
BLAKE2b-256 63022e63807de437ff8191a2e57477c46ab4a4154764aa7bc5c8649ec05c0c36

See more details on using hashes here.

File details

Details for the file openpit-0.8.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for openpit-0.8.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92eab856b136a6b056ca8356eed0a41324baaa7c4dbe524684d1490df4475a29
MD5 5e88eaf82ee89dfc30f608a9c4354a2d
BLAKE2b-256 98fdc90ccbc79fe993d01150326c71081ec3f61c6a3bb2cb03d19d3cfc2e63e7

See more details on using hashes here.

File details

Details for the file openpit-0.8.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for openpit-0.8.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bcf5c44c28e1e405690a047a0ddef5e76623a58f1ee3b3305700ac9e03f69746
MD5 c964f3d6959acd451486e45a87a9820b
BLAKE2b-256 9824adf1cacd6f533176655cf6bf0d55643f57f11341c12f01bd5d6719b190a6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.8.1 This release

7 files

0.8.0

7 files

0.7.0

7 files

0.6.0

7 files

0.5.0

7 files

0.4.0

7 files

0.3.0

7 files

0.2.0

7 files

0.1.3

7 files

0.1.0

2 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