- 移动调试脚本到 debug_scripts/ 目录 - 清理 Python 缓存文件和编译文件 - 添加综合数据调度器和相关文档 - 整理项目结构,提高代码可维护性 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from strategy_validation.advanced_validator import AdvancedStrategyValidator, StrategyConfig
|
|
from api.strategy_validation_api import triple_ma_strategy
|
|
import pandas as pd
|
|
import numpy as np
|
|
from datetime import datetime, timedelta
|
|
|
|
def main():
|
|
print("调试策略验证器...")
|
|
|
|
# 创建策略配置
|
|
config = StrategyConfig(
|
|
name="测试三均线策略",
|
|
description="调试用",
|
|
parameters={'ma5': 5, 'ma10': 10, 'ma20': 20, 'volume_threshold': 1.2},
|
|
risk_params={'max_position_size': 0.20, 'stop_loss': 0.05, 'take_profit': 0.10}
|
|
)
|
|
|
|
# 创建验证器
|
|
validator = AdvancedStrategyValidator(config)
|
|
|
|
print("开始验证...")
|
|
try:
|
|
result = validator.comprehensive_validation(
|
|
stock_codes=['000001.SZ'],
|
|
start_date='2024-08-01',
|
|
end_date='2025-08-01',
|
|
strategy_func=triple_ma_strategy,
|
|
save_results=False
|
|
)
|
|
|
|
print("验证成功!")
|
|
print(f"总收益率: {result.total_return:.4f}")
|
|
print(f"年化收益率: {result.annualized_return:.4f}")
|
|
print(f"总交易数: {result.total_trades}")
|
|
print(f"夏普比率: {result.sharpe_ratio:.4f}")
|
|
print(f"胜率: {result.win_rate:.4f}")
|
|
|
|
except Exception as e:
|
|
print(f"验证失败: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
if __name__ == "__main__":
|
|
main() |