Skip to main content

Python ctypes binding for the Orderflow C API

Project description

Python Binding (ctypes)

Python wrapper over the stable Orderflow C ABI (of_ffi_c).

Capability Overview

  • Engine lifecycle control (start, stop, context manager support)
  • Subscription and callback streaming
  • Adapter polling and external event ingest
  • Snapshot access (book, analytics, signal, metrics)
  • Data-quality supervision for external feeds

Prerequisites

Build native runtime from repository root:

cargo build -p of_ffi_c

Install Python package locally (editable):

python -m pip install -e bindings/python

Native Library Resolution

Resolution order:

  1. library_path= argument passed to Engine(...)
  2. ORDERFLOW_LIBRARY_PATH environment variable
  3. default debug target path (target/debug/libof_ffi_c.*)
export ORDERFLOW_LIBRARY_PATH=/absolute/path/to/libof_ffi_c.so

Minimal Usage

from orderflow import DataQualityFlags, Engine, EngineConfig, Symbol, StreamKind

with Engine(EngineConfig(instance_id="py-client")) as eng:
    sym = Symbol("CME", "ESM6", depth_levels=10)
    eng.subscribe(sym, StreamKind.ANALYTICS)
    eng.poll_once(DataQualityFlags.NONE)
    print(eng.analytics_snapshot(sym))

External Ingest Example

from orderflow import (
    BookAction, DataQualityFlags, Engine, EngineConfig, ExternalFeedPolicy,
    Side, Symbol, StreamKind
)

sym = Symbol("CME", "ESM6", depth_levels=10)
with Engine(EngineConfig(instance_id="ingest")) as eng:
    eng.subscribe(sym, StreamKind.HEALTH, callback=lambda ev: print("health", ev))
    eng.configure_external_feed(ExternalFeedPolicy(stale_after_ms=2_000, enforce_sequence=True))
    eng.ingest_book(sym, side=Side.BID, level=0, price=504900, size=20, action=BookAction.UPSERT)
    eng.ingest_trade(sym, price=505000, size=7, aggressor_side=Side.ASK)
    eng.poll_once(DataQualityFlags.NONE)
    print(eng.signal_snapshot(sym))

Runtime Notes

  • config_path may point to runtime TOML consumed by Rust engine config loader.
  • Optional callback on subscribe(...) is supported; callbacks fire during polling and ingest.
  • StreamKind.HEALTH emits transition-only events with health sequence and quality flags.
  • reset_symbol_session(symbol) clears per-session analytics/profile context.
  • configure_external_feed(...), set_external_reconnecting(...), and external_health_tick() provide sequence/stale/reconnect supervision.

Included Examples

  • bindings/python/examples/basic.py
  • bindings/python/examples/health_example.py
  • bindings/python/examples/external_ingest.py

Project details


Download files

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

Source Distribution

orderflow_gregorian09-0.1.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

orderflow_gregorian09-0.1.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file orderflow_gregorian09-0.1.2.tar.gz.

File metadata

  • Download URL: orderflow_gregorian09-0.1.2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for orderflow_gregorian09-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4be27242d4b9ffe9012948b36c1e5552aeea51f08e2f315dd8e25a8fc72a0604
MD5 8f6a55f3d03f9aa6a34a61a174accf16
BLAKE2b-256 b616731592e79daac4b66922e14aff66a948b1adbc22f827b08a65b6e8cbd805

See more details on using hashes here.

File details

Details for the file orderflow_gregorian09-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for orderflow_gregorian09-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1704917af053c7518359a24a948ad39e8b970dedac331780b0b18ac581da3669
MD5 ed6c9177394eb104090de59b4f7b265b
BLAKE2b-256 3ab8674a4243fb9f39943b343ebcbb24ba7cd2a114d31b30d8dd3caef87e7fe1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page