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

Function to_polars_signal_frame

python/openquant/adapters.py:14–27  ·  view source on GitHub ↗
(
    timestamps: Sequence[str],
    signal: Sequence[float],
    side: Sequence[float] | None = None,
    symbol: str | None = None,
)

Source from the content-addressed store, hash-verified

12
13
14def to_polars_signal_frame(
15 timestamps: Sequence[str],
16 signal: Sequence[float],
17 side: Sequence[float] | None = None,
18 symbol: str | None = None,
19) -> pl.DataFrame:
20 _validate_equal_length("timestamps", timestamps, "signal", signal)
21 data: dict[str, object] = {"ts": list(timestamps), "signal": list(signal)}
22 if side is not None:
23 _validate_equal_length("timestamps", timestamps, "side", side)
24 data["side"] = list(side)
25 if symbol is not None:
26 data["symbol"] = [symbol] * len(timestamps)
27 return pl.DataFrame(data).with_columns(pl.col("ts").str.strptime(pl.Datetime, strict=False))
28
29
30def to_polars_event_frame(

Callers 1

appendMethod · 0.85

Calls 1

_validate_equal_lengthFunction · 0.85

Tested by

no test coverage detected