(interval: str)
| 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 | |
| 15 | def _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}") |