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

Function hcaa_allocate

crates/pyopenquant/src/hcaa.rs:18–49  ·  view source on GitHub ↗
(
    asset_names: Vec<String>,
    asset_prices: Option<Vec<Vec<f64>>>,
    asset_returns: Option<Vec<Vec<f64>>>,
    covariance_matrix: Option<Vec<Vec<f64>>>,
    expected_asset_returns: Option<Vec<

Source from the content-addressed store, hash-verified

16/// `"equal_weighting"` gives 0.5. Below the cut each cluster's weight is shared equally
17/// (`"equal_weighting"`) or by inverse variance (every other metric). Raffinot's
18/// gap-statistic choice of the cluster count is not implemented: None means no cut. Returns
19/// from prices are simple returns; estimated expected returns are annualised by 252
20/// periods, while covariance and tail measures are per-period. The 252 assumes daily rows;
21/// it cancels in the `"sharpe_ratio"` split, so intraday rows give the same weights.
22///
23/// Parameters
24/// ----------
25/// asset_names : list[str]
26/// One name per asset; its length fixes the number of assets `N` and their order.
27/// asset_prices : list[list[float]] | None, default None
28/// Prices, one inner list per observation (oldest first) and `N` columns. Used only
29/// when `asset_returns` is None.
30/// asset_returns : list[list[float]] | None, default None
31/// Per-period returns, one inner list per observation and `N` columns; takes
32/// precedence over prices.
33/// covariance_matrix : list[list[float]] | None, default None
34/// `N x N` covariance; if None, the sample covariance of the returns.
35/// expected_asset_returns : list[float] | None, default None
36/// `N` expected returns for `"sharpe_ratio"`; if None they are estimated from the
37/// return history (`asset_returns`, or the returns of `asset_prices`). Ignored by the
38/// other metrics.
39/// allocation_metric : str, default "equal_weighting"
40/// One of `"minimum_variance"`, `"minimum_standard_deviation"`, `"sharpe_ratio"`,
41/// `"equal_weighting"`, `"expected_shortfall"`, `"conditional_drawdown_risk"`.
42/// confidence_level : float, default 0.05
43/// Tail probability for the two tail metrics (0.05 = worst 5%); not validated, clamped
44/// into `[0, 1]` when the quantile is taken.
45/// optimal_num_clusters : int | None, default None
46/// Where to cut the tree, in `1..=N`; None means `N` (no cut).
47/// resample_by : str | None, default None
48/// For prices only: `"W"`/`"week"`/`"weekly"` keeps every 5th row,
49/// `"M"`/`"month"`/`"monthly"` every 21st (case-insensitive); anything else, or None,
50/// keeps every row.
51/// calculate_expected_returns : str, default "mean"
52/// How expected returns are estimated from the returns for `"sharpe_ratio"`: `"mean"` or

Callers

nothing calls this directly

Calls 1

allocateMethod · 0.45

Tested by

no test coverage detected