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 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#![cfg_attr(
60    test,
61    allow(
62        clippy::cast_possible_truncation,
63        clippy::cast_precision_loss,
64        clippy::float_cmp,
65        clippy::trivially_copy_pass_by_ref,
66        reason = "test fixtures assert exact values and construct binary protocol bytes"
67    )
68)]
69
70#[cfg(feature = "testers")]
71pub mod cache;
72#[cfg(feature = "datasets")]
73pub mod common;
74#[cfg(feature = "testers")]
75pub mod components;
76pub mod events;
77
78#[cfg(feature = "datasets")]
79pub mod files;
80#[cfg(feature = "datasets")]
81pub mod itch;
82
83#[cfg(feature = "testers")]
84pub mod testers;
85
86// Re-export for convenience
87#[cfg(feature = "testers")]
88pub use testers::{DataTester, DataTesterConfig, ExecTester, ExecTesterConfig};
89
90#[cfg(feature = "python")]
91pub mod python;