Skip to main content

openquant/
lib.rs

1//! Rust implementations of the methods in Marcos López de Prado, *Advances in Financial
2//! Machine Learning* (Wiley, 2018; "AFML"), and of the portfolio and HPC tooling around them.
3//!
4//! Each module maps to one or more AFML chapters, and its documentation cites the section and
5//! snippet it implements. Where a function departs from the book or from the `mlfinlab`
6//! reference it mirrors, the item's documentation says so.
7//!
8//! # Modules by AFML chapter
9//!
10//! | Chapter | Modules |
11//! | --- | --- |
12//! | 2. Financial data structures | [`data_structures`], [`filters`], [`etf_trick`] |
13//! | 3. Labeling | [`labeling`], [`util::volatility`] |
14//! | 4. Sample weights | [`sampling`], [`sample_weights`], [`sb_bagging`] |
15//! | 5. Fractionally differentiated features | [`fracdiff`] |
16//! | 6. Ensemble methods | [`ensemble_methods`] |
17//! | 7. Cross-validation in finance | [`cross_validation`] |
18//! | 8. Feature importance | [`feature_importance`], [`fingerprint`] |
19//! | 9. Hyper-parameter tuning | [`hyperparameter_tuning`] |
20//! | 10. Bet sizing | [`bet_sizing`], [`ef3m`] |
21//! | 11–12. Backtesting, walk-forward and CPCV | [`backtesting_engine`] |
22//! | 13. Backtesting on synthetic data | [`synthetic_backtesting`] |
23//! | 14. Backtest statistics | [`backtest_statistics`], [`risk_metrics`] |
24//! | 15. Understanding strategy risk | [`strategy_risk`] |
25//! | 16. Machine learning asset allocation | [`hrp`], [`hcaa`], [`onc`], [`cla`], [`portfolio_optimization`] |
26//! | 17. Structural breaks | [`structural_breaks`] |
27//! | 18–19. Entropy and microstructural features | [`microstructural_features`], [`codependence`] |
28//! | 20. Multiprocessing and vectorization | [`hpc_parallel`], [`streaming_hpc`] |
29//! | 21. Brute force and quantum computers | [`dynamic_allocation`], [`combinatorial_optimization`] |
30//!
31//! [`pipeline`] strings several of these together (events, signals, portfolio, risk,
32//! backtest) for research workflows, [`data_processing`] loads, cleans and calendar-aligns
33//! OHLCV bars, and [`util`] holds shared primitives such as [`util::fast_ewma`] and the common
34//! [`util::InputError`].
35//!
36//! # Conventions
37//!
38//! - Series are ordered **oldest first**. Whether a function wants prices, log prices or
39//!   returns, and whether returns are per period or annualised, is stated on each function.
40//! - Fallible functions return a typed error per module (or [`util::InputError`]) rather
41//!   than panicking; any remaining reachable panic is listed under `# Panics` on the item.
42//! - Randomised functions take a seed or a generator, or have a variant that does, so that
43//!   results can be reproduced.
44//!
45//! The same material, with worked examples and caveats, is on the documentation site's module
46//! pages, which these docs follow.
47//!
48//! ```
49//! use openquant::fracdiff::frac_diff_ffd;
50//!
51//! // Fractional differencing of order 1 is the ordinary first difference (AFML Snippet 5.3).
52//! let diffed = frac_diff_ffd(&[1.0, 2.0, 4.0, 7.0], 1.0, 1e-5);
53//! assert!(diffed[0].is_nan());
54//! assert_eq!(&diffed[1..], &[1.0, 2.0, 3.0]);
55//! ```
56#![deny(missing_docs)]
57
58pub mod backtest_statistics;
59pub mod backtesting_engine;
60pub mod bet_sizing;
61pub mod cla;
62pub mod codependence;
63pub mod combinatorial_optimization;
64pub mod cross_validation;
65pub mod data_processing;
66pub mod data_structures;
67pub mod dynamic_allocation;
68pub mod ef3m;
69pub mod ensemble_methods;
70pub mod etf_trick;
71pub mod feature_importance;
72pub mod filters;
73pub mod fingerprint;
74pub mod fracdiff;
75pub mod hcaa;
76pub mod hpc_parallel;
77pub mod hrp;
78pub mod hyperparameter_tuning;
79pub mod labeling;
80pub mod microstructural_features;
81pub mod onc;
82pub mod pipeline;
83pub mod portfolio_optimization;
84pub mod risk_metrics;
85pub mod sample_weights;
86pub mod sampling;
87pub mod sb_bagging;
88pub mod strategy_risk;
89pub mod streaming_hpc;
90pub mod structural_breaks;
91pub mod synthetic_backtesting;
92pub mod util;