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#![deny(unsafe_code)]
55#![deny(unsafe_op_in_unsafe_fn)]
56#![deny(nonstandard_style)]
57#![deny(missing_debug_implementations)]
58#![deny(clippy::missing_errors_doc)]
59#![deny(clippy::missing_panics_doc)]
60#![deny(rustdoc::broken_intra_doc_links)]
61#![allow(
62    clippy::assert_is_empty,
63    reason = "`assert!(x.is_empty())` is clearer than comparing against an empty value"
64)]
65#![cfg_attr(
66    test,
67    allow(
68        clippy::cast_possible_truncation,
69        clippy::cast_precision_loss,
70        clippy::float_cmp,
71        clippy::trivially_copy_pass_by_ref,
72        reason = "test fixtures assert exact values and construct binary protocol bytes"
73    )
74)]
75
76#[cfg(feature = "testers")]
77pub mod cache;
78#[cfg(feature = "datasets")]
79pub mod common;
80#[cfg(feature = "testers")]
81pub mod components;
82pub mod events;
83
84#[cfg(feature = "datasets")]
85pub mod files;
86#[cfg(feature = "datasets")]
87pub mod itch;
88
89#[cfg(feature = "testers")]
90pub mod testers;
91
92// Re-export for convenience
93#[cfg(feature = "testers")]
94pub use testers::{DataTester, DataTesterConfig, ExecTester, ExecTesterConfig};
95
96#[cfg(feature = "python")]
97pub mod python;