Expand description
Network functionality for NautilusTrader.
The nautilus-network crate provides networking components including HTTP, WebSocket, and raw TCP socket
clients, rate limiting, backoff strategies, and socket TLS utilities for connecting to
trading venues and data providers.
§NautilusTrader
NautilusTrader is an open-source, production-grade, Rust-native engine for multi-asset, multi-venue trading systems.
The system spans research, deterministic simulation, and live execution within a single event-driven architecture, providing research-to-live semantic parity.
§Feature Flags
This crate provides feature flags to control source code inclusion during compilation, depending on the intended use case, i.e. whether to provide Python bindings for the nautilus_trader Python package, or as part of a Rust only build.
python: Enables Python bindings from PyO3.extension-module: Builds the crate as a Python extension module.turmoil: Enables deterministic network simulation testing with turmoil.transport-sockudo: Adds the sockudo-ws WebSocket backend, selectable viaWebSocketConfig.backend.
§Testing
The crate includes both standard integration tests and deterministic network simulation tests using turmoil.
To run standard tests:
cargo nextest run -p nautilus-networkTo run turmoil network simulation tests:
cargo nextest run -p nautilus-network --features turmoilThe turmoil tests simulate various network conditions (reconnections, partitions, etc.) in a deterministic way, allowing reliable testing of network failure scenarios without flakiness.
Re-exports§
pub use transport::Message;pub use transport::TransportError;
Modules§
- backoff
- Provides an implementation of an exponential backoff mechanism with jitter support. It is used for managing reconnection delays in the socket clients.
- dst
- Deterministic simulation testing (DST) seam for network async primitives.
- error
- Network error types.
- http
- A high-performance HTTP client implementation.
- mode
- Connection mode enumeration for socket clients.
- net
- Network abstractions for dependency injection and testing.
- python
- Python bindings from PyO3.
- ratelimiter
- A rate limiter implementation heavily inspired by governor.
- retry
- Generic retry mechanism for network operations.
- socket
- High-performance raw TCP client implementation with TLS capability, automatic reconnection with exponential backoff and state management.
- transport
- Transport abstraction layer for WebSocket backends.
- websocket
- WebSocket client implementation with automatic reconnection and subscription tracking.
Constants§
- RECONNECTED
- Sentinel message to signal reconnection completion to Rust consumers.