Python ctypes binding for the Orderflow C API
Project description
Python Binding (ctypes)
This package wraps crates/of_ffi_c through ctypes.
Build the native library
From workspace root:
cargo build -p of_ffi_c
Default lookup path is target/debug/libof_ffi_c.so (Linux), with platform-specific suffix handling.
You can override lookup with:
export ORDERFLOW_LIBRARY_PATH=/absolute/path/to/libof_ffi_c.so
Install package (editable)
From bindings/python:
python -m pip install -e .
Quick usage
from orderflow import BookAction, Engine, EngineConfig, ExternalFeedPolicy, Side, Symbol, StreamKind
cfg = EngineConfig(instance_id="py-client", config_path="")
with Engine(cfg) as eng:
sym = Symbol("CME", "ESM6", depth_levels=10)
eng.subscribe(sym, StreamKind.ANALYTICS)
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.poll_once()
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.unsubscribe(sym)
print(eng.analytics_snapshot(sym))
print(eng.signal_snapshot(sym))
print(eng.metrics())
Notes
config_pathcan point to runtime.tomlor.jsonconfig consumed by Rust runtime.ORDERFLOW_LIBRARY_PATHis honored whenlibrary_pathis not passed toEngine(...).- Optional callback is supported on
subscribe(...)and fires duringpoll_once(...)and externalingest_*calls. StreamKind.HEALTHemits only on health state changes and includes fields likehealth_seq,connected,degraded,reconnect_state,quality_flags, andprotocol_info.Engine.reset_symbol_session(symbol)resets per-session analytics/profile context for a symbol.Engine.ingest_trade(...)andEngine.ingest_book(...)let you inject external feed events directly without using a market-data adapter stream.Engine.configure_external_feed(...),Engine.set_external_reconnecting(...), andEngine.external_health_tick()provide uniform sequence-gap/stale/reconnect supervision for external feeds.
Examples
bindings/python/examples/basic.pybindings/python/examples/health_example.pybindings/python/examples/external_ingest.py
Run:
python bindings/python/examples/health_example.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file orderflow_gregorian09-0.1.0.tar.gz.
File metadata
- Download URL: orderflow_gregorian09-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b6bd13ba3a405ce0173010f5bb7fde2e641d664ccbd55291f978050162ad2ec
|
|
| MD5 |
451472bd0f4f358256dd5353ec36aca7
|
|
| BLAKE2b-256 |
191881d366c09c8c5bf8af069160fd4885969c694779b8a4d982928a1a5c288d
|
File details
Details for the file orderflow_gregorian09-0.1.0-py3-none-any.whl.
File metadata
- Download URL: orderflow_gregorian09-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fdddc8d4a476386d102388135e69283c7a523442246d85a514b77be00c1912e
|
|
| MD5 |
b7407e08ad687e4fec2c3121736b0a6f
|
|
| BLAKE2b-256 |
f0e96cb427053be0009205dde4443b84d1e8c081f082a4a6cad32dd1417379d5
|