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

Function _interval_to_seconds

python/openquant/data.py:157–167  ·  view source on GitHub ↗
(interval: str)

Source from the content-addressed store, hash-verified

155def _inferred_interval_us(sorted_df: pl.DataFrame) -> int | None:
156 """The bar spacing of a frame sorted by (symbol, ts_us): the most common positive spacing
157 between consecutive bars of one symbol, pooled over symbols (the smallest on a tie).
158
159 `None` when no symbol has two bars at different times. Mirrors
160 `openquant::data_processing` in Rust.
161 """
162 spacings = (
163 sorted_df.select(
164 pl.when(pl.col("symbol") == pl.col("symbol").shift(1))
165 .then(pl.col("ts_us") - pl.col("ts_us").shift(1))
166 .alias("spacing")
167 )
168 .get_column("spacing")
169 .drop_nulls()
170 )

Callers 1

align_calendarFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected