OpenQuant Docs banner
OpenQuant icon openquant-rs / documentation terminal

onc

Portfolio Construction and Risk

Optimal Number of Clusters utilities for clustering stability and allocation workflows.

Why This Module Exists

Cluster count selection is a key source of model risk in hierarchical portfolio methods.

Key Public APIs

  • get_onc_clusters
  • check_improve_clusters
  • OncResult

Core Math

Cluster Score

\[J(k)=\text{intra}(k)-\text{inter}(k)\]

Selection

\[k^*=\arg\min_k J(k)\]

Code Examples

Infer cluster structure

use openquant::onc::get_onc_clusters;

let out = get_onc_clusters(&corr, 20)?;
println!("{}", out.clusters.len());

Implementation Notes

  • Run with repeated seeds/restarts for robust k selection.
  • Use correlation cleaning before clustering unstable universes.