(
path: str | Path,
*,
symbol: str | None = None,
return_report: bool = False,
)
| 222 | |
| 223 | |
| 224 | def load_ohlcv( |
| 225 | path: str | Path, |
| 226 | *, |
| 227 | symbol: str | None = None, |
| 228 | return_report: bool = False, |
| 229 | ) -> pl.DataFrame | tuple[pl.DataFrame, dict[str, Any]]: |
| 230 | file_path = Path(path) |
| 231 | if not file_path.exists(): |
| 232 | raise FileNotFoundError(f"file not found: {file_path}") |
| 233 | suffix = file_path.suffix.lower() |
| 234 | if suffix == ".csv": |
| 235 | raw = pl.read_csv(file_path) |
| 236 | elif suffix in {".parquet", ".pq"}: |
| 237 | raw = pl.read_parquet(file_path) |
| 238 | else: |
| 239 | raise ValueError(f"unsupported file type: {suffix}") |
| 240 | |
| 241 | raw = _canonicalize_columns(raw) |
| 242 | if "symbol" not in raw.columns: |
| 243 | if symbol is None: |
| 244 | raise ValueError("symbol column missing and no symbol argument provided") |
| 245 | raw = raw.with_columns(pl.lit(symbol).alias("symbol")) |
| 246 | return clean_ohlcv(raw, return_report=return_report) |
| 247 | |
| 248 | |
| 249 | def align_calendar( |
nothing calls this directly
no test coverage detected