#!/usr/bin/env python3 """ ================================================================ Auteur : Simon-Pierre Boucher Contact : contact@spboucher.ai Projet : Prévision de volatilité réalisée multi-actifs (HAR-RV vs GARCH vs Machine Learning) Fichier : 01_download_data.py Description : Étape 01 — Téléchargement des barres 1-min et daily pour tout l'univers (cache parquet data/raw). Usage : python scripts/01_download_data.py [--refresh] ================================================================ """ from __future__ import annotations import argparse import logging import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src")) from wp12 import config, data_pipeline # noqa: E402 from wp12.api_client import HFMarketDataClient # noqa: E402 logger = logging.getLogger("01_download") def main() -> None: """Download 1-min and daily bars for every instrument in the universe.""" ap = argparse.ArgumentParser() ap.add_argument("--refresh", action="store_true", help="force re-download") args = ap.parse_args() config.setup_logging() logging.getLogger("urllib3").setLevel(logging.WARNING) client = HFMarketDataClient() todo = config.universe(include_predictors=True) for i, inst in enumerate(todo, 1): logger.info("[%d/%d] %s (%s)", i, len(todo), inst["ticker"], inst["asset"]) bars = data_pipeline.download_instrument(client, inst, refresh=args.refresh) for tf, df in bars.items(): logger.info(" %s: %d rows", tf, len(df)) if __name__ == "__main__": main()