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

Function to_polars_weights_frame

python/openquant/adapters.py:76–88  ·  view source on GitHub ↗
(
    asset_names: Sequence[str],
    weights: Sequence[float],
    as_of: str | None = None,
)

Source from the content-addressed store, hash-verified

74
75
76def to_polars_weights_frame(
77 asset_names: Sequence[str],
78 weights: Sequence[float],
79 as_of: str | None = None,
80) -> pl.DataFrame:
81 _validate_equal_length("asset_names", asset_names, "weights", weights)
82 data: dict[str, object] = {"asset": list(asset_names), "weight": list(weights)}
83 if as_of is not None:
84 data["as_of"] = [as_of] * len(asset_names)
85 df = pl.DataFrame(data)
86 if as_of is not None:
87 df = df.with_columns(pl.col("as_of").str.strptime(pl.Datetime, strict=False))
88 return df
89
90
91def to_polars_frontier_frame(

Callers

nothing calls this directly

Calls 1

_validate_equal_lengthFunction · 0.85

Tested by

no test coverage detected