nautilus_live/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//! Live system node for [NautilusTrader](https://nautilustrader.io).
17//!
18//! The crate provides live event transport, execution state management, and node lifecycle support.
19//!
20//! - [`execution`] supplies adapter-facing order context, failure classification, report filtering,
21//! event emission, and the execution manager. The manager tracks reconciliation state, requests
22//! reports for individual checks, and applies startup reconciliation events.
23//! - `node` (with the `node` feature) owns the kernel lifecycle, recurring reconciliation tasks,
24//! collection deadlines, cancellation, and dispatch through the live event loop.
25//! - [`runner`] routes asynchronous data, execution, system, and timer traffic.
26//!
27//! # NautilusTrader
28//!
29//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
30//! engine for multi-asset, multi-venue trading systems.
31//!
32//! The system spans research, deterministic simulation, and live execution within a single
33//! event-driven architecture, providing research-to-live semantic parity.
34//!
35//! # Feature Flags
36//!
37//! This crate provides feature flags to control source code inclusion during compilation,
38//! depending on the intended use case, i.e. whether to provide Python bindings
39//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
40//! or as part of a Rust only build.
41//!
42//! - `defi`: Enables DeFi (Decentralized Finance) support.
43//! - `examples`: Enables example strategies and testkit support for live nodes.
44//! - `extension-module`: Builds as a Python extension module.
45//! - `fuzz`: Provides shared libFuzzer integration for adapter fuzz binaries.
46//! - `node` (default): Enables the live node, builder, configuration, and system-kernel dependencies.
47//! - `plugin` (default): Keeps compatibility stubs for plug-in config validation.
48//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs) and auto-enables `node` and
49//! `streaming`.
50//! - `simulation`: Enables deterministic simulation testing with
51//! [MadSim](https://crates.io/crates/madsim).
52//! - `streaming`: Enables the `nautilus-persistence` dependency for streaming configuration and
53//! requires `node`.
54//! - `test-support`: Enables engine-wired execution support for adapter integration tests.
55//!
56//! # Lean adapter builds
57//!
58//! Adapters and other consumers that only need the async event emitter, runner, and
59//! `ExecutionClientCore` re-export can opt out of the full kernel by disabling the
60//! `node` feature:
61//!
62//! ```toml
63//! nautilus-live = { workspace = true, default-features = false }
64//! ```
65//!
66//! With `node` disabled, execution support (including the manager), run-to-completion
67//! reconciliation, the runner, socket controls, and task support remain available. This skips
68//! the transitive dependencies on `nautilus-system`, `nautilus-trading`,
69//! `nautilus-portfolio`, `nautilus-risk`, and `nautilus-data`.
70//!
71//! # Plug-in support
72//!
73//! The open-source live crate does not host dynamic plug-ins directly.
74//! `nautilus-plugin` is the public guest ABI crate, while host-side loading,
75//! vtables, bridge adapters, and server policy belong to the host-side plug-in
76//! integration.
77//! A non-empty `LiveNodeConfig.plugins` list is rejected unless an application
78//! provides that host-side integration.
79//!
80//! ```toml
81//! nautilus-live = { workspace = true, default-features = false, features = ["node"] }
82//! ```
83//!
84//! With `plugin` disabled, the compatibility `plugin` module is removed. A
85//! non-empty `LiveNodeConfig.plugins` list is rejected under this configuration
86//! as well.
87
88#![warn(rustc::all)]
89#![warn(clippy::pedantic)]
90#![allow(
91 clippy::manual_let_else,
92 clippy::option_if_let_else,
93 clippy::or_fun_call,
94 clippy::redundant_else,
95 clippy::similar_names,
96 clippy::single_match_else,
97 reason = "workspace policy; generated by scripts/update-clippy-allowances.py"
98)]
99#![deny(unsafe_code)]
100#![deny(unsafe_op_in_unsafe_fn)]
101#![deny(nonstandard_style)]
102#![deny(missing_debug_implementations)]
103#![deny(clippy::missing_errors_doc)]
104#![deny(clippy::missing_panics_doc)]
105#![deny(rustdoc::broken_intra_doc_links)]
106#![allow(
107 clippy::too_many_lines,
108 reason = "live node lifecycle and reconciliation flows exceed the default threshold by design"
109)]
110#![allow(
111 clippy::unsafe_derive_deserialize,
112 reason = "config types deserialize plain field values; unsafe in unrelated impls is sound"
113)]
114#![allow(
115 clippy::assert_is_empty,
116 reason = "`assert!(x.is_empty())` is clearer than comparing against an empty value"
117)]
118// pyo3's `from_py_object` generates `.clone()` on `Copy` fields that clippy flags from the
119// macro expansion; an item-level `allow` cannot reach the expansion
120#![allow(clippy::clone_on_copy)]
121
122pub mod book;
123pub mod execution;
124pub mod runner;
125pub mod socket;
126pub mod task;
127
128#[cfg(feature = "fuzz")]
129#[doc(hidden)]
130pub mod fuzz;
131
132#[cfg(feature = "fuzz")]
133#[doc(hidden)]
134pub use fuzz::Corpus;
135
136#[cfg(feature = "node")]
137pub mod node;
138
139#[cfg(feature = "python")]
140pub mod python;
141
142#[cfg(feature = "test-support")]
143pub mod testing;
144
145mod dispatch;
146
147// Re-exports for adapters
148pub use execution::{emitter, emitter::ExecutionEventEmitter, manager};
149pub use nautilus_common::factories::OrderEventFactory;
150pub use nautilus_execution::client::core::ExecutionClientCore;
151#[cfg(feature = "plugin")]
152pub use node::plugin;
153#[cfg(feature = "node")]
154pub use node::{builder, config};
155pub use socket::{
156 SocketControl, SocketControlFactory, SocketReconnectLookup, SocketReconnectRegistry,
157 SocketReconnectRequestOutcome,
158};