Skip to main content

quantwave_core/regimes/
mod.rs

1//! Regime Detection and Market State Tools
2//!
3//! This module provides algorithms for identifying market regimes, such as volatility clustering,
4//! hidden Markov models (HMM), and changepoint detection.
5
6pub mod volatility_clustering;
7pub mod hmm;
8pub mod ecld;
9pub mod gaussian_hmm;
10pub mod hmm_forecast;
11
12pub use ecld::{ecld_cdf, ecld_log_pdf, ecld_pdf, ecld_variance, natural_to_work, work_to_natural};
13pub use gaussian_hmm::{
14    fit_em, EmissionFamily, GaussianHmmDecode, GaussianHmmError, GaussianHmmFilter,
15    GaussianHmmFitConfig, GaussianHmmFitResult, GaussianHmmParams,
16};
17pub use hmm_forecast::{
18    calc_stats_from_obs, decode_stats_history, forecast_observation_mean, forecast_observation_pdf,
19    forecast_state, forecast_volatility, pseudo_residuals, HmmDecodeStatsRow, HmmDiagnostics,
20    HmmStateObsStats,
21};
22pub mod gmm;
23pub mod pelt;
24pub mod analytics;
25pub mod ms_garch;
26pub mod ensemble;
27pub mod india;
28pub mod tar;
29pub mod hsmm;
30pub mod hmm_gas;
31pub mod multi_asset;
32
33use serde::{Deserialize, Serialize};
34
35/// Represents common market regime states.
36#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
37pub enum MarketRegime {
38    /// A period of low volatility and generally upward price movement.
39    Bull,
40    /// A period of high volatility or downward price movement.
41    Bear,
42    /// A transitional or unstable period.
43    Crisis,
44    /// A steady state with normal characteristics.
45    Steady,
46    /// Custom state for user-defined clusters.
47    Cluster(u8),
48}
49
50impl Default for MarketRegime {
51    fn default() -> Self {
52        Self::Steady
53    }
54}