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, and linear regression.
23//! - **Momentum indicators**: RSI, MACD, Aroon, Bollinger Bands, CCI, Stochastics, and rate of change.
24//! - **Volatility indicators**: ATR, Donchian Channels, Keltner Channels, and volatility ratios.
25//! - **Ratio analysis**: Efficiency ratios and spread analysis for relative performance.
26//! - **Order book indicators**: Book imbalance ratio for analyzing market microstructure.
27//! - **Common indicator trait**: Unified interface supporting bars, quotes, trades, and order book data.
28//!
29//! All indicators are designed for high-performance real-time processing with bounded memory
30//! usage and efficient circular buffer implementations. The crate supports both Rust-native
31//! usage and Python integration for strategy development and backtesting.
32//!
33//! # NautilusTrader
34//!
35//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
36//! engine for multi-asset, multi-venue trading systems.
37//!
38//! The system spans research, deterministic simulation, and live execution within a single
39//! event-driven architecture, providing research-to-live semantic parity.
40//!
41//! # Feature Flags
42//!
43//! This crate provides feature flags to control source code inclusion during compilation,
44//! depending on the intended use case, i.e. whether to provide Python bindings
45//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
46//! or as part of a Rust only build.
47//!
48//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
49//! - `extension-module`: Builds the crate as a Python extension module.
50
51#![warn(rustc::all)]
52#![warn(clippy::pedantic)]
53#![deny(unsafe_code)]
54#![deny(unsafe_op_in_unsafe_fn)]
55#![deny(nonstandard_style)]
56#![deny(missing_debug_implementations)]
57#![deny(clippy::missing_errors_doc)]
58#![deny(clippy::missing_panics_doc)]
59#![deny(rustdoc::broken_intra_doc_links)]
60#![allow(
61 clippy::similar_names,
62 reason = "indicator fields such as period_d/period_k and value_d/value_k are intentionally parallel"
63)]
64#![allow(
65 clippy::cast_possible_truncation,
66 clippy::cast_possible_wrap,
67 clippy::cast_precision_loss,
68 clippy::cast_sign_loss,
69 reason = "indicator math casts between usize/i64/f64 with values bounded by configured periods"
70)]
71#![cfg_attr(
72 test,
73 allow(
74 clippy::float_cmp,
75 clippy::should_panic_without_expect,
76 clippy::unreadable_literal,
77 reason = "indicator tests assert exact float outputs and decimal constants from algorithm references"
78 )
79)]
80
81pub mod average;
82pub mod book;
83pub mod indicator;
84pub mod momentum;
85pub mod ratio;
86pub mod testing;
87pub mod volatility;
88
89#[cfg(test)]
90mod stubs;
91
92#[cfg(feature = "python")]
93pub mod python;