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

Function to_polars_frontier_frame

python/openquant/adapters.py:91–108  ·  view source on GitHub ↗
(
    volatility: Sequence[float],
    returns: Sequence[float],
    sharpe: Sequence[float] | None = None,
    point_ids: Sequence[str] | None = None,
)

Source from the content-addressed store, hash-verified

89
90
91def to_polars_frontier_frame(
92 volatility: Sequence[float],
93 returns: Sequence[float],
94 sharpe: Sequence[float] | None = None,
95 point_ids: Sequence[str] | None = None,
96) -> pl.DataFrame:
97 _validate_equal_length("volatility", volatility, "returns", returns)
98 n = len(volatility)
99 data: dict[str, object] = {"volatility": list(volatility), "return": list(returns)}
100 if sharpe is not None:
101 _validate_equal_length("volatility", volatility, "sharpe", sharpe)
102 data["sharpe"] = list(sharpe)
103 if point_ids is not None:
104 _validate_equal_length("volatility", volatility, "point_ids", point_ids)
105 data["point_id"] = list(point_ids)
106 else:
107 data["point_id"] = [f"p{i}" for i in range(n)]
108 return pl.DataFrame(data)
109
110
111def to_polars_backtest_frame(

Callers

nothing calls this directly

Calls 1

_validate_equal_lengthFunction · 0.85

Tested by

no test coverage detected