1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Pure-Rust port of [PyPortfolioOpt][pyo].
//!
//! The crate mirrors PyPortfolioOpt's module structure:
//!
//! - [`expected_returns`] — historical mean / EMA / CAPM return estimators.
//! - [`risk_models`] — sample / EWMA / semi-covariance + Ledoit-Wolf and
//! oracle-approximating shrinkage; cov ↔ corr helpers.
//! - [`efficient_frontier`] — mean-variance optimisation: minimum variance,
//! tangency (max Sharpe), efficient risk / return, with weight bounds.
//! - [`black_litterman`] — equilibrium prior + view-blended posterior.
//! - [`hrp`] — hierarchical risk parity (correlation distance, single
//! linkage, recursive bisection).
//! - [`cla`] — Markowitz's Critical Line Algorithm.
//! - [`discrete_allocation`] — convert continuous weights to integer share
//! counts under a budget.
//!
//! All matrix / vector inputs and outputs use [`nalgebra`]'s `DMatrix` /
//! `DVector` so they slot into broader nalgebra-based pipelines.
//!
//! Every estimator and optimiser keeps the same default annualisation
//! convention as PyPortfolioOpt: 252 trading days unless explicitly
//! overridden by the caller.
//!
//! [pyo]: https://github.com/PyPortfolio/PyPortfolioOpt
pub use *;
/// Crate-wide error type. Most fallible operations return [`PortfolioError`]
/// rather than panicking so callers can decide how to recover from
/// misconfigured inputs (mismatched shapes, infeasible optimisation, etc.).
/// Convenience alias used by every module in the crate.
pub type Result<T> = Result;
/// Default annualisation factor — 252 trading days per year, matching
/// PyPortfolioOpt's defaults.
pub const TRADING_DAYS_PER_YEAR: usize = 252;