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

Function align_calendar

python/openquant/data.py:249–283  ·  view source on GitHub ↗
(
    df: pl.DataFrame,
    *,
    interval: str = "1d",
)

Source from the content-addressed store, hash-verified

247 "null_counts": dict(null_counts),
248 }
249
250
251def _interval_to_seconds(interval: str) -> int:
252 s = interval.strip().lower()
253 if s.endswith("d"):
254 return int(s[:-1]) * 24 * 3600
255 if s.endswith("h"):
256 return int(s[:-1]) * 3600
257 if s.endswith("m"):
258 return int(s[:-1]) * 60
259 if s.endswith("s"):
260 return int(s[:-1])
261 raise ValueError(f"unsupported interval format: {interval}")
262
263
264@overload
265def clean_ohlcv(
266 df: pl.DataFrame,
267 *,
268 dedupe_keep: Literal["first", "last"] = ...,
269 return_report: Literal[False] = ...,
270) -> pl.DataFrame: ...
271
272
273@overload
274def clean_ohlcv(
275 df: pl.DataFrame,
276 *,
277 dedupe_keep: Literal["first", "last"] = ...,
278 return_report: Literal[True],
279) -> tuple[pl.DataFrame, dict[str, Any]]: ...
280
281
282@overload
283def clean_ohlcv(
284 df: pl.DataFrame,
285 *,
286 dedupe_keep: Literal["first", "last"] = ...,

Callers

nothing calls this directly

Calls 2

clean_ohlcvFunction · 0.85
_interval_to_secondsFunction · 0.70

Tested by

no test coverage detected