nautilus_data/lib.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//! Data engine and market data processing for [NautilusTrader](https://nautilustrader.io).
17//!
18//! The `nautilus-data` crate provides a framework for handling market data ingestion,
19//! processing, and aggregation within the NautilusTrader ecosystem. This includes real-time
20//! data streaming, historical data management, and various aggregation methodologies:
21//!
22//! - High-performance data engine for orchestrating data operations.
23//! - Data client infrastructure for connecting to market data providers.
24//! - Bar aggregation machinery supporting tick, volume, value, and time-based aggregation.
25//! - Order book management and delta processing capabilities.
26//! - Subscription management and data request handling.
27//! - Configurable data routing and processing pipelines.
28//!
29//! # NautilusTrader
30//!
31//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
32//! engine for multi-asset, multi-venue trading systems.
33//!
34//! The system spans research, deterministic simulation, and live execution within a single
35//! event-driven architecture, providing research-to-live semantic parity.
36//!
37//! # Feature Flags
38//!
39//! This crate provides feature flags to control source code inclusion during compilation,
40//! depending on the intended use case, i.e. whether to provide Python bindings
41//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
42//! or as part of a Rust only build.
43//!
44//! - `defi`: Enables DeFi (Decentralized Finance) support.
45//! - `extension-module`: Enables Python extension-module support.
46//! - `high-precision`: Enables
47//! [high-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation/#precision-mode)
48//! to use 128-bit value types.
49//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
50//! - `streaming`: Enables the `nautilus-persistence` dependency for catalog-based data streaming.
51
52#![warn(rustc::all)]
53#![warn(clippy::pedantic)]
54#![deny(unsafe_code)]
55#![deny(unsafe_op_in_unsafe_fn)]
56#![deny(nonstandard_style)]
57#![deny(missing_debug_implementations)]
58#![deny(clippy::missing_errors_doc)]
59#![deny(clippy::missing_panics_doc)]
60#![deny(rustdoc::broken_intra_doc_links)]
61#![allow(
62 clippy::similar_names,
63 reason = "data domain terms such as ts_event/ts_init are intentionally parallel"
64)]
65#![allow(
66 clippy::cast_lossless,
67 clippy::cast_possible_truncation,
68 clippy::cast_possible_wrap,
69 clippy::cast_precision_loss,
70 clippy::cast_sign_loss,
71 reason = "data math casts between i64/u64/usize/f64 with values bounded by domain ranges"
72)]
73#![allow(
74 clippy::must_use_candidate,
75 reason = "data accessors are pervasive; #[must_use] noise is not warranted"
76)]
77#![allow(
78 clippy::unused_self,
79 reason = "engine operations take &self for method-style organization"
80)]
81#![allow(
82 clippy::large_types_passed_by_value,
83 reason = "command and request value types are intentionally moved through dispatch"
84)]
85#![allow(
86 clippy::unsafe_derive_deserialize,
87 reason = "config types deserialize plain field values; unrelated unsafe impls are sound"
88)]
89#![allow(
90 clippy::missing_fields_in_debug,
91 reason = "manual Debug impls intentionally omit verbose internal state"
92)]
93#![allow(
94 clippy::struct_excessive_bools,
95 reason = "config structs mirror existing Python configuration surfaces"
96)]
97#![allow(
98 clippy::too_many_lines,
99 reason = "engine and aggregation dispatch functions exceed the default threshold by design"
100)]
101#![allow(
102 clippy::inline_always,
103 reason = "hot-path aggregation functions are intentionally always inlined"
104)]
105#![allow(
106 clippy::match_same_arms,
107 reason = "explicit per-variant arms document data dispatch even when bodies coincide"
108)]
109#![allow(
110 clippy::match_wildcard_for_single_variants,
111 reason = "wildcard arms guard against future enum variants in command dispatch"
112)]
113#![allow(
114 clippy::single_match_else,
115 reason = "two-arm matches are consistent with surrounding command and event dispatch"
116)]
117#![allow(
118 clippy::assert_is_empty,
119 reason = "`assert!(x.is_empty())` is clearer than comparing against an empty value"
120)]
121#![cfg_attr(
122 test,
123 allow(
124 clippy::float_cmp,
125 clippy::should_panic_without_expect,
126 clippy::unreadable_literal,
127 clippy::used_underscore_binding,
128 reason = "data tests assert exact float outputs and use loose patterns for fixture setup"
129 )
130)]
131
132pub mod aggregation;
133pub mod client;
134pub mod engine;
135pub mod option_chains;
136
137#[cfg(feature = "python")]
138pub mod python;
139
140#[cfg(feature = "defi")]
141pub mod defi;
142
143mod subscription;
144
145// Re-exports
146pub use aggregation::{
147 FixedTickSchemeRounder, MapVegaProvider, SpreadPriceRounder, SpreadQuoteAggregator,
148 VegaProvider,
149};
150pub use client::DataClientAdapter;