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

运行方式:
    python run_us_rotation.py
    python run_us_rotation.py --save results/us_rotation
"""

import argparse
import time
from pathlib import Path

from strategies.us_rotation.strategy import USRotationStrategy


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


if __name__ == "__main__":
    main()