#!/usr/bin/env python3
"""
Download historical data for Multi-Pair Divergence Strategy.

Downloads 1h OHLCV data for top 10 cryptocurrencies from OKX.
"""
import sys
sys.path.insert(0, '.')

from engine.data_manager import DataManager
from engine.market import MarketType
from engine.logging_config import setup_logging, get_logger
from strategies.multi_pair import MultiPairConfig

logger = get_logger(__name__)


def main():
    """Download data for all configured assets."""
    setup_logging()
    
    config = MultiPairConfig()
    dm = DataManager()
    
    logger.info("Downloading data for %d assets...", len(config.assets))
    
    for symbol in config.assets:
        logger.info("Downloading %s perpetual 1h data...", symbol)
        try:
            df = dm.download_data(
                exchange_id=config.exchange_id,
                symbol=symbol,
                timeframe=config.timeframe,
                market_type=MarketType.PERPETUAL
            )
            if df is not None:
                logger.info("Downloaded %d candles for %s", len(df), symbol)
            else:
                logger.warning("No data downloaded for %s", symbol)
        except Exception as e:
            logger.error("Failed to download %s: %s", symbol, e)
    
    logger.info("Download complete!")


if __name__ == "__main__":
    main()
