nautilus_portfolio/lib.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 Posei Systems Pty Ltd. All rights reserved.
3// https://poseitrader.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 [PoseiTrader](http://poseitrader.io).
17//!
18//! The *portfolio* crate provides comprehensive 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//! # Platform
33//!
34//! [PoseiTrader](http://poseitrader.io) is an open-source, high-performance, production-grade
35//! algorithmic trading platform, providing quantitative traders with the ability to backtest
36//! portfolios of automated trading strategies on historical data with an event-driven engine,
37//! and also deploy those same strategies live, with no code changes.
38//!
39//! PoseiTrader's design, architecture, and implementation philosophy prioritizes software correctness and safety at the
40//! highest level, with the aim of supporting mission-critical, trading system backtesting and live deployment workloads.
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 [posei_trader](https://pypi.org/project/posei_trader) Python package,
47//! or as part of a Rust only build.
48//!
49//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
50
51#![warn(rustc::all)]
52#![deny(unsafe_code)]
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(test)]
64mod tests;
65
66// Re-exports
67pub use portfolio::Portfolio;