Skip to main content

Python ctypes binding for the Orderflow C API

Project description

Orderflow Python Binding (orderflow-gregorian09)

PyPI version Python versions CI License

Production-oriented Python wrapper over the stable Orderflow C ABI (of_ffi_c) for orderflow analytics, signal generation, and health-aware ingestion pipelines.

System View

Orderflow architecture

What You Get

  • Runtime lifecycle control (start, stop, context-manager with Engine(...))
  • Symbol stream subscriptions with optional callback listeners
  • Poll-based processing plus push-style external ingest (ingest_trade, ingest_book)
  • Snapshot retrieval (book, analytics, signal, metrics)
  • External feed supervision (stale, sequence, reconnect) via health APIs

Install

pip install orderflow-gregorian09

The Python wheel wraps the C ABI; it expects a compatible libof_ffi_c shared library at runtime.

Native Library Resolution

Lookup order:

  1. Explicit library_path= argument on Engine(...)
  2. ORDERFLOW_LIBRARY_PATH environment variable
  3. Local debug build default (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("analytics", eng.analytics_snapshot(sym))
    print("metrics", eng.metrics_json())

External Feed Ingest Workflow

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

sym = Symbol("CME", "ESM6", depth_levels=10)

with Engine(EngineConfig(instance_id="ext-feed")) 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("signal", eng.signal_snapshot(sym))

API Surface

  • Engine: lifecycle, subscribe/unsubscribe, poll, ingest, snapshots
  • EngineConfig: runtime, persistence, audit, and retention settings
  • Symbol: venue + symbol + depth descriptor
  • ExternalFeedPolicy: stale and sequence policy for external data
  • constants: StreamKind, Side, BookAction, DataQualityFlags

Operations Notes

  • subscribe(..., callback=None) is supported for polling-only flows.
  • StreamKind.HEALTH emits transition-oriented health payloads.
  • reset_symbol_session(symbol) clears per-session analytics/profile state.
  • external_health_tick() re-evaluates stale/degraded status without ingest.

Learn More

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.4.tar.gz (10.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.4-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: orderflow_gregorian09-0.1.4.tar.gz
  • Upload date:
  • Size: 10.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.4.tar.gz
Algorithm Hash digest
SHA256 3d35edd47c4d7c639cd6c50b79de8e09ddd18c154330eaedaa333571760cc60d
MD5 e611eff1c3f90f3892fe76c2bcb49d09
BLAKE2b-256 f6799a1debac72c7f11c7677e0791771c45f3e068b08071b24a402c66fbd3cf6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for orderflow_gregorian09-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 abab16a9bd09abbacfe2e1d7f139079bfbde1c15662e5355b8c50e6d435ef6ab
MD5 99b2515a6b6eeed60c064d35dc82b8ce
BLAKE2b-256 23b65a3433e5f6e46a9ad361cb06fea9a45ece1bc779d6486ba1d6ff6339e508

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