Skip to main content

nautilus_databento/decode/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Databento message decoding functions.
17//!
18//! # Sentinel Values
19//!
20//! Databento uses sentinel values to represent undefined/null fields:
21//!
22//! | Sentinel          | Value      | Usage                       |
23//! |-------------------|------------|-----------------------------|
24//! | `UNDEF_PRICE`     | `i64::MAX` | Undefined price fields.     |
25//! | `UNDEF_TIMESTAMP` | `u64::MAX` | Undefined timestamp fields. |
26//!
27//! # Fields Potentially Undefined
28//!
29//! According to Databento documentation, the following fields can contain sentinel values:
30//!
31//! | Message Type       | Field                          | Handling                           |
32//! |--------------------|--------------------------------|------------------------------------|
33//! | `MboMsg`           | `price`                        | Passed through as `PRICE_UNDEF`.   |
34//! | `TradeMsg`         | `price`                        | Passed through as `PRICE_UNDEF`.   |
35//! | `OhlcvMsg`         | `open`, `high`, `low`, `close` | Passed through as `PRICE_UNDEF`.   |
36//! | `Mbp1Msg`          | `bid_px`, `ask_px`             | Quote skipped if either undefined. |
37//! | `InstrumentDefMsg` | `activation`                   | Defaults to 0 (epoch).             |
38//! | `InstrumentDefMsg` | `expiration`                   | Returns error if undefined.        |
39//! | `InstrumentDefMsg` | `strike_price`                 | Returns error if undefined.        |
40//!
41//! # References
42//!
43//! - [`UNDEF_PRICE`](https://docs.rs/dbn/latest/dbn/constant.UNDEF_PRICE.html)
44//! - [`UNDEF_TIMESTAMP`](https://docs.rs/dbn/latest/dbn/constant.UNDEF_TIMESTAMP.html)
45//! - [Databento DBN Schema](https://databento.com/docs/schemas)
46
47mod custom;
48mod expiration;
49mod instruments;
50mod market_data;
51mod primitives;
52
53pub use custom::{decode_imbalance_msg, decode_statistics_msg, is_supported_stat_type};
54pub use expiration::{DatabentoDecodeConfig, OptionExpirationRule, corrected_option_expiration};
55pub use instruments::{
56    decode_equity, decode_futures_contract, decode_futures_spread, decode_instrument_def_msg,
57    decode_option_contract, decode_option_spread,
58};
59pub use market_data::{
60    decode_bar_type, decode_bbo_msg, decode_cbbo_msg, decode_cmbp1_msg, decode_mbo_msg,
61    decode_mbp1_msg, decode_mbp10_msg, decode_ohlcv_msg, decode_record, decode_status_msg,
62    decode_tbbo_msg, decode_tcbbo_msg, decode_trade_msg, decode_ts_event_adjustment,
63};
64pub use primitives::{
65    decode_lot_size, decode_multiplier, decode_optional_price, decode_optional_quantity,
66    decode_optional_timestamp, decode_price, decode_price_increment, decode_price_or_undef,
67    decode_quantity, decode_timestamp, parse_aggressor_side, parse_book_action, parse_cfi_iso10926,
68    parse_option_kind, parse_optional_bool, parse_order_side, parse_status_reason,
69    parse_status_trading_event, precision_from_raw,
70};
71
72#[cfg(test)]
73mod tests;