nautilus_network/lib.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 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//! Network functionality for [NautilusTrader](http://nautilustrader.io).
17//!
18//! The `nautilus-network` crate provides networking components including HTTP, WebSocket, and raw TCP socket
19//! clients, rate limiting, backoff strategies, and socket TLS utilities for connecting to
20//! trading venues and data providers.
21//!
22//! # Platform
23//!
24//! [NautilusTrader](http://nautilustrader.io) is an open-source, high-performance, production-grade
25//! algorithmic trading platform, providing quantitative traders with the ability to backtest
26//! portfolios of automated trading strategies on historical data with an event-driven engine,
27//! and also deploy those same strategies live, with no code changes.
28//!
29//! NautilusTrader's design, architecture, and implementation philosophy prioritizes software correctness and safety at the
30//! highest level, with the aim of supporting mission-critical, trading system backtesting and live deployment workloads.
31//!
32//! # Feature flags
33//!
34//! This crate provides feature flags to control source code inclusion during compilation,
35//! depending on the intended use case, i.e. whether to provide Python bindings
36//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
37//! or as part of a Rust only build.
38//!
39//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
40//! - `extension-module`: Builds the crate as a Python extension module.
41//! - `turmoil`: Enables deterministic network simulation testing with [turmoil](https://github.com/tokio-rs/turmoil).
42//!
43//! # Testing
44//!
45//! The crate includes both standard integration tests and deterministic network simulation tests using turmoil.
46//!
47//! To run standard tests:
48//! ```bash
49//! cargo nextest run -p nautilus-network
50//! ```
51//!
52//! To run turmoil network simulation tests:
53//! ```bash
54//! cargo nextest run -p nautilus-network --features turmoil
55//! ```
56//!
57//! The turmoil tests simulate various network conditions (reconnections, partitions, etc.) in a deterministic way,
58//! allowing reliable testing of network failure scenarios without flakiness.
59
60#![warn(rustc::all)]
61#![deny(unsafe_code)]
62#![deny(nonstandard_style)]
63#![deny(missing_debug_implementations)]
64#![deny(clippy::missing_errors_doc)]
65#![deny(clippy::missing_panics_doc)]
66#![deny(rustdoc::broken_intra_doc_links)]
67
68pub mod backoff;
69pub mod fix;
70pub mod http;
71pub mod mode;
72pub mod net;
73pub mod retry;
74pub mod socket;
75pub mod websocket;
76
77mod logging;
78mod tls;
79
80#[cfg(feature = "python")]
81pub mod python;
82
83pub mod error;
84pub mod ratelimiter;
85
86/// Sentinel message to signal reconnection to Rust consumers.
87pub const RECONNECTED: &str = "__RECONNECTED__";