nautilus_indicators/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//! Technical analysis indicators for [NautilusTrader](https://nautilustrader.io).
17//!
18//! The `nautilus-indicators` crate provides a collection of technical analysis indicators
19//! for quantitative trading and market research. This includes a wide variety of indicators
20//! organized by category, with a unified trait-based architecture for consistent usage:
21//!
22//! - **Moving averages**: SMA, EMA, DEMA, HMA, WMA, VWAP, adaptive averages, linear regression,
23//! and z-score.
24//! - **Momentum indicators**: RSI, MACD, Aroon, Bollinger Bands, CCI, Stochastics, and rate of change.
25//! - **Volatility indicators**: ATR, Donchian Channels, Keltner Channels, and volatility ratios.
26//! - **Ratio analysis**: Efficiency ratios and spread analysis for relative performance.
27//! - **Order book indicators**: Book imbalance ratio for analyzing market microstructure.
28//! - **Common indicator trait**: Unified interface supporting bars, quotes, trades, and order book data.
29//!
30//! All indicators are designed for high-performance real-time processing with bounded memory
31//! usage and efficient circular buffer implementations. The crate supports both Rust-native
32//! usage and Python integration for strategy development and backtesting.
33//!
34//! # NautilusTrader
35//!
36//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
37//! engine for multi-asset, multi-venue trading systems.
38//!
39//! The system spans research, deterministic simulation, and live execution within a single
40//! event-driven architecture, providing research-to-live semantic parity.
41//!
42//! # Feature Flags
43//!
44//! This crate provides feature flags to control source code inclusion during compilation,
45//! depending on the intended use case, i.e. whether to provide Python bindings
46//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
47//! or as part of a Rust only build.
48//!
49//! - `extension-module`: Builds as a Python extension module.
50//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
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::cast_possible_truncation,
72 clippy::cast_possible_wrap,
73 clippy::cast_precision_loss,
74 clippy::cast_sign_loss,
75 reason = "indicator math casts between usize/i64/f64 with values bounded by configured periods"
76)]
77#![allow(
78 clippy::assert_is_empty,
79 reason = "`assert!(x.is_empty())` is clearer than comparing against an empty value"
80)]
81// pyo3's `from_py_object` generates `.clone()` on `Copy` fields that clippy flags from the
82// macro expansion; an item-level `allow` cannot reach the expansion
83#![allow(clippy::clone_on_copy)]
84#![cfg_attr(
85 test,
86 allow(
87 clippy::float_cmp,
88 clippy::should_panic_without_expect,
89 clippy::unreadable_literal,
90 reason = "indicator tests assert exact float outputs and decimal constants from algorithm references"
91 )
92)]
93
94pub mod average;
95pub mod book;
96pub mod indicator;
97pub mod momentum;
98pub mod ratio;
99mod support;
100pub mod testing;
101pub mod volatility;
102
103#[cfg(test)]
104mod stubs;
105
106#[cfg(feature = "python")]
107pub mod python;