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 `nautilus-live` crate provides high-level abstractions and infrastructure for running live trading
19//! systems, including data streaming, execution management, and system lifecycle handling.
20//! It builds on top of the system kernel to provide simplified interfaces for live deployment:
21//!
22//! - `LiveNode` High-level abstraction for live system nodes.
23//! - `LiveNodeConfig` Configuration for live node deployment.
24//! - `AsyncRunner` for managing system real-time data flow.
25//!
26//! # NautilusTrader
27//!
28//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
29//! engine for multi-asset, multi-venue trading systems.
30//!
31//! The system spans research, deterministic simulation, and live execution within a single
32//! event-driven architecture, providing research-to-live semantic parity.
33//!
34//! # Feature Flags
35//!
36//! This crate provides feature flags to control source code inclusion during compilation,
37//! depending on the intended use case, i.e. whether to provide Python bindings
38//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
39//! or as part of a Rust only build.
40//!
41//! - `node` (default): Enables the full live node, builder, config, and execution manager.
42//! - `plugin` (default): Keeps compatibility stubs for plug-in config validation.
43//! - `ffi`: Enables the C foreign function interface (FFI) from [cbindgen](https://github.com/mozilla/cbindgen).
44//! - `streaming`: Enables `persistence` dependency for streaming configuration (requires `node`).
45//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs) (auto-enables `node` and `streaming`).
46//! - `defi`: Enables DeFi (Decentralized Finance) support.
47//! - `extension-module`: Builds the crate as a Python extension module.
48//!
49//! # Lean adapter builds
50//!
51//! Adapters and other consumers that only need the async event emitter, runner, and
52//! `ExecutionClientCore` re-export can opt out of the full kernel by disabling the
53//! `node` feature:
54//!
55//! ```toml
56//! nautilus-live = { workspace = true, default-features = false }
57//! ```
58//!
59//! With `node` disabled, this crate exposes only `emitter` and `runner`, and skips
60//! the transitive dependencies on `nautilus-system`, `nautilus-trading`,
61//! `nautilus-portfolio`, `nautilus-risk`, and `nautilus-data`.
62//!
63//! # Plug-in support
64//!
65//! The open-source live crate does not host dynamic plug-ins directly.
66//! `nautilus-plugin` is the public guest ABI crate, while host-side loading,
67//! vtables, bridge adapters, and server policy belong to the host-side plug-in
68//! integration.
69//! A non-empty `LiveNodeConfig.plugins` list is rejected unless an application
70//! provides that host-side integration.
71//!
72//! ```toml
73//! nautilus-live = { workspace = true, default-features = false, features = ["node"] }
74//! ```
75//!
76//! With `plugin` disabled, the compatibility `plugin` module is removed. A
77//! non-empty `LiveNodeConfig.plugins` list is rejected under this configuration
78//! as well.
79
80#![warn(rustc::all)]
81#![warn(clippy::pedantic)]
82#![deny(unsafe_code)]
83#![deny(unsafe_op_in_unsafe_fn)]
84#![deny(nonstandard_style)]
85#![deny(missing_debug_implementations)]
86#![deny(clippy::missing_errors_doc)]
87#![deny(clippy::missing_panics_doc)]
88#![deny(rustdoc::broken_intra_doc_links)]
89#![allow(
90 clippy::similar_names,
91 reason = "timing and plug-in identifiers such as elapsed_ms/elapsed_ns and loaded/loader are intentionally parallel"
92)]
93#![allow(
94 clippy::single_match_else,
95 reason = "match can be clearer than if-let-else for some reconciliation state transitions"
96)]
97#![allow(
98 clippy::redundant_closure_for_method_calls,
99 reason = "matches the Rust 1.94 ICE workaround in the workspace lint table"
100)]
101#![allow(
102 clippy::too_many_lines,
103 reason = "live node lifecycle and reconciliation flows exceed the default threshold by design"
104)]
105#![allow(
106 clippy::unsafe_derive_deserialize,
107 reason = "config types deserialize plain field values; unsafe in unrelated impls is sound"
108)]
109
110pub mod execution;
111pub mod runner;
112
113#[cfg(feature = "node")]
114pub mod node;
115
116#[cfg(feature = "python")]
117pub mod python;
118
119// Re-exports for adapters
120pub use execution::{emitter, emitter::ExecutionEventEmitter, manager};
121pub use nautilus_common::factories::OrderEventFactory;
122pub use nautilus_execution::client::core::ExecutionClientCore;
123#[cfg(feature = "plugin")]
124pub use node::plugin;
125#[cfg(feature = "node")]
126pub use node::{builder, config};