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

Function _interval_to_seconds

python/openquant/bars.py:12–22  ·  view source on GitHub ↗
(interval: str)

Source from the content-addressed store, hash-verified

10
11# The bar-size parameter: an int for tick and time bars, a float for volume and dollar bars.
12_Param = TypeVar("_Param", int, float)
13
14
15def _interval_to_seconds(interval: str) -> int:
16 s = interval.strip().lower()
17 if s.endswith("d"):
18 return int(s[:-1]) * 24 * 3600
19 if s.endswith("h"):
20 return int(s[:-1]) * 3600
21 if s.endswith("m"):
22 return int(s[:-1]) * 60
23 if s.endswith("s"):
24 return int(s[:-1])
25 raise ValueError(f"unsupported interval format: {interval}")

Callers 1

build_time_barsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected