Archive legacy framework and utility modules that are no longer referenced by the active core (datasource/ and rotation/): - framework/ -> archive/framework/ - framework_v2/ -> archive/framework_v2/ - strategies/ -> archive/strategies/ - config/ -> archive/config/ - visualization/ -> archive/visualization/ - scripts/ -> archive/scripts/ - tests/ -> archive/tests/ - run_rotation.py, run_us_rotation.py -> archive/single_files/ - compare_*.py, test_api_dates.py -> archive/single_files/
55 lines
1.2 KiB
Python
55 lines
1.2 KiB
Python
#!/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() |