Skip to main content

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//! - `ffi`: Enables the C foreign function interface (FFI) from [cbindgen](https://github.com/mozilla/cbindgen).
45//! - `high-precision`: Enables [high-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation#precision-mode) to use 128-bit value types.
46//! - `streaming`: Enables `persistence` dependency for catalog-based data streaming.
47//! - `defi`: Enables DeFi (Decentralized Finance) support.
48
49#![warn(rustc::all)]
50#![warn(clippy::pedantic)]
51#![deny(unsafe_code)]
52#![deny(unsafe_op_in_unsafe_fn)]
53#![deny(nonstandard_style)]
54#![deny(missing_debug_implementations)]
55#![deny(clippy::missing_errors_doc)]
56#![deny(clippy::missing_panics_doc)]
57#![deny(rustdoc::broken_intra_doc_links)]
58#![allow(
59    clippy::similar_names,
60    reason = "data domain terms such as ts_event/ts_init are intentionally parallel"
61)]
62#![allow(
63    clippy::cast_lossless,
64    clippy::cast_possible_truncation,
65    clippy::cast_possible_wrap,
66    clippy::cast_precision_loss,
67    clippy::cast_sign_loss,
68    reason = "data math casts between i64/u64/usize/f64 with values bounded by domain ranges"
69)]
70#![allow(
71    clippy::must_use_candidate,
72    reason = "data accessors are pervasive; #[must_use] noise is not warranted"
73)]
74#![allow(
75    clippy::unused_self,
76    reason = "engine helpers take &self for method-style organization"
77)]
78#![allow(
79    clippy::large_types_passed_by_value,
80    reason = "command and request value types are intentionally moved through dispatch"
81)]
82#![allow(
83    clippy::unsafe_derive_deserialize,
84    reason = "config types deserialize plain field values; unrelated unsafe impls are sound"
85)]
86#![allow(
87    clippy::missing_fields_in_debug,
88    reason = "manual Debug impls intentionally omit verbose internal state"
89)]
90#![allow(
91    clippy::struct_excessive_bools,
92    reason = "config structs mirror existing Python configuration surfaces"
93)]
94#![allow(
95    clippy::too_many_lines,
96    reason = "engine and aggregation dispatch functions exceed the default threshold by design"
97)]
98#![allow(
99    clippy::inline_always,
100    reason = "hot-path helpers in aggregation are intentionally always inlined"
101)]
102#![allow(
103    clippy::match_same_arms,
104    reason = "explicit per-variant arms document data dispatch even when bodies coincide"
105)]
106#![allow(
107    clippy::match_wildcard_for_single_variants,
108    reason = "wildcard arms guard against future enum variants in command dispatch"
109)]
110#![allow(
111    clippy::single_match_else,
112    reason = "two-arm matches are consistent with surrounding command and event dispatch"
113)]
114#![cfg_attr(
115    test,
116    allow(
117        clippy::float_cmp,
118        clippy::should_panic_without_expect,
119        clippy::unreadable_literal,
120        clippy::used_underscore_binding,
121        reason = "data tests assert exact float outputs and use loose patterns for fixture setup"
122    )
123)]
124
125pub mod aggregation;
126pub mod client;
127pub mod engine;
128pub mod option_chains;
129
130#[cfg(feature = "python")]
131pub mod python;
132
133#[cfg(feature = "defi")]
134pub mod defi;
135
136// Re-exports
137pub use aggregation::{
138    FixedTickSchemeRounder, MapVegaProvider, SpreadPriceRounder, SpreadQuoteAggregator,
139    VegaProvider,
140};
141pub use client::DataClientAdapter;