Python bindings for the dbn Rust library.
Used by the Databento Python client library.
Using this library is for advanced users and is not fully documented or supported.
To install the latest stable version from PyPI:
pip install -U databento-dbnTo read the metadata from a DBN file into a dict, read the raw bytes and pass them to decode_metadata.
from databento_dbn import decode_metadata
with open("my.dbn.zst", "rb") as fin:
metadata = decode_metadata(fin.read())
# Print symbology mappings
print(metadata["mappings"])You can write Zstd-compressed DBN files using write_dbn_file:
from databento_dbn import write_dbn_file
records = [
{"rtype": 160, "publisher_id": 1, "instrument_id": 1, "ts_event": 647784973705, "order_id": 1,
"price": 3723000000000, "size": 1, "flags": 128, "channel_id": 0, "action": ord('C'),
"side": ord('A'), "ts_recv": 1609160400000704060, "ts_in_delta": 0, "sequence": 1170352}
]
with open("my.dbn.zst", "wb") as out:
write_dbn_file(file=out, compression="zstd", schema="mbo", dataset="custom",
records=records, stype="instrument_id")Note that the keys in the dictionaries in records must match the field names of the schema, or
the function will raise a KeyError.
databento-dbn is written in Rust, so you'll need to have Rust installed
as well as Maturin.
To build, run the following commands:
git clone https://github.com/databento/dbn
cd dbn
maturin buildTo build the Python package and install it for the active Python interpreter in your PATH, run:
maturin developThis will install a package named databento-dbn in your current Python environment.
Distributed under the Apache 2.0 License.