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 automated data downloads and validation:
21//!
22//! - **Test data management**: Automated downloading and caching of test datasets.
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 test utilities and helper functions.
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` (enabled by default): Enables test dataset discovery, download, validation, parsing,
42//! and loading.
43//! - `testers` (enabled by default): Enables test actors, strategies, and in-memory cache backing.
44//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
45//! - `high-precision`: Enables [high-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation#precision-mode) to use 128-bit value types.
46//! - `extension-module`: Builds the crate as a Python extension module.
47//!
48//! Event collection utilities remain available without enabling a feature.
49
50#![warn(rustc::all)]
51#![warn(clippy::pedantic)]
52#![deny(unsafe_code)]
53#![deny(unsafe_op_in_unsafe_fn)]
54#![deny(nonstandard_style)]
55#![deny(missing_debug_implementations)]
56#![deny(clippy::missing_errors_doc)]
57#![deny(clippy::missing_panics_doc)]
58#![deny(rustdoc::broken_intra_doc_links)]
59#![allow(
60 clippy::assert_is_empty,
61 reason = "`assert!(x.is_empty())` is clearer than comparing against an empty value"
62)]
63#![cfg_attr(
64 test,
65 allow(
66 clippy::cast_possible_truncation,
67 clippy::cast_precision_loss,
68 clippy::float_cmp,
69 clippy::trivially_copy_pass_by_ref,
70 reason = "test fixtures assert exact values and construct binary protocol bytes"
71 )
72)]
73
74#[cfg(feature = "testers")]
75pub mod cache;
76#[cfg(feature = "datasets")]
77pub mod common;
78#[cfg(feature = "testers")]
79pub mod components;
80pub mod events;
81
82#[cfg(feature = "datasets")]
83pub mod files;
84#[cfg(feature = "datasets")]
85pub mod itch;
86
87#[cfg(feature = "testers")]
88pub mod testers;
89
90// Re-export for convenience
91#[cfg(feature = "testers")]
92pub use testers::{DataTester, DataTesterConfig, ExecTester, ExecTesterConfig};
93
94#[cfg(feature = "python")]
95pub mod python;