投资风险指标
投资风险指标:计算投资组合风险指标,包括年化收益率、夏普比率、索提诺比率、最大回撤和卡玛比率,支持滚动窗口统计和 NaN 数据处理,适用于多市场数据。 含 25 条反模式约束。
晶体简介
Constraints
Evidence Quality
Medium confidence — review before critical use
30 条不可违反的约束
WHENWhen implementing rolling window calculations for financial metrics
ACTIONpass a zero-length window to rolling_window function
CONSEQUENCERolling window with length 0 causes ValueError('Can't have 0-length window') at runtime, breaking all downstream rolling metric calculations like roll_sharpe_ratio and roll_max_drawdown
WHENWhen implementing rolling window operations with stride tricks
ACTIONpass a scalar array to the rolling_window function
CONSEQUENCEPassing a scalar array causes IndexError('Can't restride a scalar'), preventing any rolling calculations from completing
WHENWhen creating pandas structures from numpy arrays
ACTIONconvert arrays with dimensionality greater than 2 to pandas Series or DataFrame
CONSEQUENCEAttempting to convert arrays with dim > 2 raises ValueError('cannot convert array of dim > 2 to a pandas structure'), causing data transformation failures
常见问题
讨论 (0)
暂无讨论,成为第一个发言的人吧!
更新历史
v0.1.0: 首次发布到 Doramagic.ai。基于 zvtvz/zvt 的自动化 batch-v1 元数据 + 自动生成 FAQ。