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

Class SignalStreamBuffer

python/openquant/adapters.py:129–152  ·  view source on GitHub ↗

Incremental buffer for streaming signal updates in research notebooks.

Source from the content-addressed store, hash-verified

127
128 Typically the bar-by-label indicator matrix of AFML section 4.5 (Snippet 4.3), where
129 entry `[t][i]` is 1 when bar `t` falls inside label `i`'s span. Values are cast to `int`.
130
131 Parameters
132 ----------
133 ind_mat : Sequence[Sequence[int]]
134 Rectangular matrix, one row per bar and one column per label.
135 bar_index : Sequence[int] or None, default None
136 Index for each row; defaults to `0..len(ind_mat) - 1`.
137 label_names : Sequence[str] or None, default None
138 Unique column names for the labels, excluding `bar_index`; defaults to
139 `label_0`, `label_1`, ...
140
141 Returns
142 -------
143 polars.DataFrame
144 Column `bar_index` followed by one integer column per label. An empty `ind_mat`
145 gives a frame with only an empty `bar_index` column.
146
147 Raises
148 ------
149 ValueError
150 If `ind_mat` is not rectangular, or `label_names` or `bar_index` has the wrong
151 length, or label names collide with each other or `bar_index`.
152 """
153 if len(ind_mat) == 0:
154 return pl.DataFrame({"bar_index": []})
155 width = len(ind_mat[0])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected