Python bindings for encoding and decoding Databento Binary Encoding (DBN). This library provides efficient Rust-backed functionality for working with DBN data streams and files, offering features like record buffering, mutable record references, and direct access to timestamp fields. As of version 0.54.0, it includes enhancements for dynamic record types and improved memory management. Releases occur frequently, typically on a monthly or bi-monthly basis.
pip install databento-dbnVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to encode a DBN record from Python objects and then decode the resulting DBN bytes. It covers creating metadata, encoding an MBO record, and decoding from both raw bytes and a file-like object. It also highlights checking for `UNDEF_TIMESTAMP` for fields like `ts_out`.
Access `record.ts_out` directly. Its value will be `databento_dbn.UNDEF_TIMESTAMP` if not set. Avoid relying on `record.__dict__` for record attributes.
Update type hints and `isinstance` checks to use `DBNRecord` instead of `Record` (e.g., `isinstance(rec, DBNRecord)`).
For explicit version-specific types, import from `databento_dbn.v1`, `databento_dbn.v2`, or `databento_dbn.v3` (e.g., `from databento_dbn.v3 import MBO`). When working with decoded records, use `getattr()` or handle `AttributeError` for potentially missing fields if the DBN version is unknown.
Use `import dbn` to correctly import the library after installing it with `pip install databento-dbn`.
Inspect the `rtype` (record type) of the `DBNRecord` to determine its specific schema and then access the appropriate fields. For example, `if record.rtype == dbn.RType.TRADE: print(record.price)`.
Ensure the input file or stream is a legitimate DBN file. Verify the file integrity and that it was generated correctly by a Databento source or converter. If reading from a network stream, confirm the data source is sending DBN formatted data.
No dependency data recorded yet.