#!/usr/bin/env python3
"""
ETF轮动策略回测入口

用法:
    python run_rotation.py
    python run_rotation.py --config strategies/rotation/config.yaml
    python run_rotation.py --save-path results/my_rotation
"""

import argparse
import time
from datetime import datetime

from strategies.rotation.strategy import RotationStrategy


def main():
    parser = argparse.ArgumentParser(description="ETF轮动策略回测")
    parser.add_argument(
        "--config",
        type=str,
        default="strategies/rotation/config.yaml",
        help="配置文件路径",
    )
    parser.add_argument(
        "--save-path",
        type=str,
        default="results/rotation",
        help="报告保存路径前缀",
    )
    args = parser.parse_args()
    
    start_time = time.time()
    
    # 从配置创建策略
    strategy = RotationStrategy.from_yaml(args.config)
    
    # 运行回测
    result = strategy.run_backtest(save_path=args.save_path)
    
    elapsed = time.time() - start_time
    print(f"\n总耗时: {elapsed:.1f}秒")
    
    return result


if __name__ == "__main__":
    main()