MCPcopy Create free account
hub / github.com/Open-Quant/openquant / bets_concentration

Function bets_concentration

crates/openquant/src/backtest_statistics.rs:76–89  ·  view source on GitHub ↗
(returns: &[f64])

Source from the content-addressed store, hash-verified

74}
75
76pub fn bets_concentration(returns: &[f64]) -> Option<f64> {
77 if returns.len() <= 2 {
78 return None;
79 }
80 let sum: f64 = returns.iter().sum();
81 if sum == 0.0 {
82 return None;
83 }
84 let weights: Vec<f64> = returns.iter().map(|r| r / sum).collect();
85 let hhi: f64 = weights.iter().map(|w| w * w).sum();
86 let n = returns.len() as f64;
87 let adj = (hhi - 1.0 / n) / (1.0 - 1.0 / n);
88 Some(adj)
89}
90
91pub fn all_bets_concentration(
92 returns: &[(NaiveDateTime, f64)],

Callers 3

all_bets_concentrationFunction · 0.85
test_bets_concentrationFunction · 0.85
bs_bets_concentrationFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected