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.0.tar.gz (664.2 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.0-cp310-abi3-win_amd64.whl (966.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

openpit-0.8.0-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.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

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

openpit-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (994.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

openpit-0.8.0-cp310-abi3-macosx_11_0_arm64.whl (924.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

openpit-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl (991.8 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: openpit-0.8.0.tar.gz
  • Upload date:
  • Size: 664.2 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.0.tar.gz
Algorithm Hash digest
SHA256 512d98d34e0d2ec8e2466520c7166bc71b310aa08cd3ad7e0ea14ffa78922bd5
MD5 ad94c3f7916b04246ee4cab9bc8935d7
BLAKE2b-256 37795581f3b8be587b07af3f8fd4cb960e14bac90ad44957d6ba65479a34680f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openpit-0.8.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 966.8 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.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1a65ff4db3844b702f8bf0a31a9ad7b9683e0deb02d52c3f92ae59bb9b814ac3
MD5 9231cb4c2be4f5debb9400d6747076c0
BLAKE2b-256 22546f0ba339dbffa23c4cb73def0933c24a849af9add24cd09f14042db2f13d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openpit-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 687ac4e3d606a8f6353b6ac83a5ec0a90312056c4a833f00a36880fd07d76017
MD5 89c45e56522927e18bcd1158558db42f
BLAKE2b-256 8dc94f2913ddc218685c2532e7fc85910d4c08733f9903acfcceb725ac79728d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openpit-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1a91850aa7a3d82e6c5584fa20d4deeea383d18321eaa65b6a18eeecd65b145
MD5 9b07b8068c7ec3b0be78820aafd19f1b
BLAKE2b-256 966566c139136e1fea7806facfd529e92a048240249c94e4e0055e00106eff2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openpit-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1da971a56eaf79ca5a8c3e89c9921e739549e837d7fcc9aca8c03719259fcf75
MD5 64475f8a9214b50996b13384b0dd1b11
BLAKE2b-256 6746599531a52b07d343a555c22a038d6bac0334502e34e8ffbf42418ebe7417

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openpit-0.8.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cf5ba9cfe294080b50ae7f26a5d03e9fb7035f3fc73e5a2cb9857657ff303bba
MD5 c3872b92c95edf4f519d6787f6a901c2
BLAKE2b-256 22c3d7ca6ffe335d88de40fbe738f869fc0ee531062de69878a44eeeaaf48997

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openpit-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4505b61d0869749aa205a0982fb6858273ce1e1315e53c1a99a6a916af129bba
MD5 9288cb4ed42036613a67ad82553e269e
BLAKE2b-256 b6751a32228f44fe237d1b1f547ee1eae8a206af2e5b1ba09fb7b0e8e3835508

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.8.0 This release

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