Skip to main content

nautilus_portfolio/
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//! Portfolio management and risk analysis for [NautilusTrader](https://nautilustrader.io).
17//!
18//! The `nautilus-portfolio` crate provides portfolio management capabilities including
19//! real-time position tracking, performance calculations, and risk management. This includes
20//! sophisticated portfolio analytics and multi-currency support:
21//!
22//! - **Portfolio tracking**: Real-time portfolio state management with position and balance monitoring.
23//! - **Account management**: Support for cash and margin accounts across multiple venues.
24//! - **Performance calculations**: Real-time unrealized PnL, realized PnL, and mark-to-market valuations.
25//! - **Risk management**: Initial margin calculations, maintenance margin tracking, and exposure monitoring.
26//! - **Multi-currency support**: Currency conversion and cross-currency risk exposure analysis.
27//! - **Configuration options**: Flexible settings for price types, currency conversion, and portfolio behavior.
28//!
29//! The crate handles complex portfolio scenarios including multi-venue trading, currency conversions,
30//! and sophisticated margin calculations for both live trading and backtesting environments.
31//!
32//! # NautilusTrader
33//!
34//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
35//! engine for multi-asset, multi-venue trading systems.
36//!
37//! The system spans research, deterministic simulation, and live execution within a single
38//! event-driven architecture, providing research-to-live semantic parity.
39//!
40//! # Feature Flags
41//!
42//! This crate provides feature flags to control source code inclusion during compilation,
43//! depending on the intended use case, i.e. whether to provide Python bindings
44//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
45//! or as part of a Rust only build.
46//!
47//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
48//! - `extension-module`: Builds the crate as a Python extension module.
49
50#![warn(rustc::all)]
51#![deny(unsafe_code)]
52#![deny(unsafe_op_in_unsafe_fn)]
53#![deny(nonstandard_style)]
54#![deny(missing_debug_implementations)]
55#![deny(clippy::missing_errors_doc)]
56#![deny(clippy::missing_panics_doc)]
57#![deny(rustdoc::broken_intra_doc_links)]
58
59pub mod config;
60pub mod manager;
61pub mod portfolio;
62
63#[cfg(feature = "python")]
64pub mod python;
65
66// Re-exports
67pub use portfolio::Portfolio;