Skip to main content

nautilus_testkit/
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//! Test utilities and data management for [NautilusTrader](https://nautilustrader.io).
17//!
18//! The `nautilus-testkit` crate provides testing utilities including test data management,
19//! file handling, and common testing patterns. This crate supports robust testing workflows
20//! across the entire NautilusTrader ecosystem with explicit data preparation and local-only loading:
21//!
22//! - **Test data management**: Explicit downloading, checksum verification, and caching of test datasets before tests.
23//! - **File utilities**: File integrity verification with SHA-256 checksums.
24//! - **Path resolution**: Platform-agnostic test data path management.
25//! - **Precision handling**: Support for both 64-bit and 128-bit precision test data.
26//! - **Event collection**: Draining and correlating the data events a client emits.
27//! - **Common patterns**: Reusable fixtures and test support.
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//!
41//! - `datasets` (default): Enables test dataset discovery, download, validation, parsing, and
42//!   loading.
43//! - `extension-module`: Builds as a Python extension module.
44//! - `high-precision`: Enables
45//!   [high-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation/#precision-mode)
46//!   to use 128-bit value types.
47//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
48//! - `testers` (default): Enables test actors, strategies, and in-memory cache backing.
49//!
50//! Event collection utilities remain available without enabling a feature.
51
52#![warn(rustc::all)]
53#![warn(clippy::pedantic)]
54#![allow(
55    clippy::manual_let_else,
56    clippy::option_if_let_else,
57    clippy::or_fun_call,
58    clippy::redundant_else,
59    clippy::similar_names,
60    clippy::single_match_else,
61    reason = "workspace policy; generated by scripts/update-clippy-allowances.py"
62)]
63#![deny(unsafe_code)]
64#![deny(unsafe_op_in_unsafe_fn)]
65#![deny(nonstandard_style)]
66#![deny(missing_debug_implementations)]
67#![deny(clippy::missing_errors_doc)]
68#![deny(clippy::missing_panics_doc)]
69#![deny(rustdoc::broken_intra_doc_links)]
70#![allow(
71    clippy::assert_is_empty,
72    reason = "`assert!(x.is_empty())` is clearer than comparing against an empty value"
73)]
74#![cfg_attr(
75    test,
76    allow(
77        clippy::cast_possible_truncation,
78        clippy::cast_precision_loss,
79        clippy::float_cmp,
80        clippy::trivially_copy_pass_by_ref,
81        reason = "test fixtures assert exact values and construct binary protocol bytes"
82    )
83)]
84
85#[cfg(feature = "testers")]
86pub mod cache;
87#[cfg(feature = "datasets")]
88pub mod common;
89#[cfg(feature = "testers")]
90pub mod components;
91pub mod connection;
92pub mod events;
93pub mod http;
94
95#[cfg(feature = "datasets")]
96pub mod files;
97#[cfg(feature = "datasets")]
98pub mod itch;
99
100#[cfg(feature = "testers")]
101pub mod testers;
102
103// Re-export for convenience
104#[cfg(feature = "testers")]
105pub use testers::{DataTester, DataTesterConfig, ExecTester, ExecTesterConfig};
106
107#[cfg(feature = "python")]
108pub mod python;