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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for orderflow_gregorian09-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e875f4348f1a33db38e000824ab7869cba8e3dc54eabd11acbcedb3b2a550635
MD5 f2282b2d6a2fa0ba8f32a7558d003998
BLAKE2b-256 37b241f0b5cf279a651271d3d428554ad3b6fd1c663333710206e9c892e4b36f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for orderflow_gregorian09-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a09053ae608caf73c1accf333097962132760d4d282f9872bc42ba38445a75fa
MD5 afd4007c6c6ff3d7dc2492834ad995d4
BLAKE2b-256 2a66160e67e4e8c623cb1575a5f98743d7f1b0dfca8a37ea111bfaf68b895df7

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