- Add scripts/scoring/ module with normalizer, sensitivity analysis, and config - Enhance stock_viewer.html with standardized scoring display - Add integration tests and normalization verification scripts - Add documentation for standardization implementation and usage guides - Add data distribution analysis reports for strength scoring dimensions - Update discussion documents with algorithm optimization plans
66 lines
2.3 KiB
Python
66 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
测试generate_stock_viewer.py集成的标准化功能
|
|
"""
|
|
import sys
|
|
import os
|
|
|
|
# 添加路径
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'scripts'))
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'scripts', 'scoring'))
|
|
|
|
from scripts.generate_stock_viewer import load_stock_data
|
|
|
|
print("=" * 80)
|
|
print("测试标准化集成")
|
|
print("=" * 80)
|
|
|
|
# 测试加载数据
|
|
csv_path = "outputs/converging_triangles/all_results.csv"
|
|
if not os.path.exists(csv_path):
|
|
print(f"错误: 文件不存在 {csv_path}")
|
|
print("请先运行: python scripts/pipeline_converging_triangle.py")
|
|
sys.exit(1)
|
|
|
|
print(f"\n加载数据: {csv_path}")
|
|
try:
|
|
stocks, date = load_stock_data(csv_path, target_date=None, all_stocks_mode=False)
|
|
print(f"[OK] 成功加载 {len(stocks)} 只股票")
|
|
print(f"[OK] 数据日期: {date}")
|
|
|
|
# 检查标准化字段
|
|
if stocks:
|
|
sample = stocks[0]
|
|
print(f"\n示例股票: {sample['name']} ({sample['code']})")
|
|
print(f" 原始强度分: {sample['strength']:.4f}")
|
|
|
|
if 'strengthEqual' in sample:
|
|
print(f" 等权强度分: {sample['strengthEqual']:.4f}")
|
|
print(f" 激进强度分: {sample['strengthAggressive']:.4f}")
|
|
print(f" 保守强度分: {sample['strengthConservative']:.4f}")
|
|
print(f" 放量强度分: {sample['strengthVolume']:.4f}")
|
|
|
|
print(f"\n标准化维度:")
|
|
print(f" 突破幅度: {sample['priceUpNorm']:.4f}")
|
|
print(f" 收敛度: {sample['convergenceNorm']:.4f}")
|
|
print(f" 成交量: {sample['volumeNorm']:.4f}")
|
|
print(f" 形态规则: {sample['geometryNorm']:.4f}")
|
|
print(f" 活跃度: {sample['activityNorm']:.4f}")
|
|
print(f" 倾斜度: {sample['tiltNorm']:.4f}")
|
|
else:
|
|
print(" [WARNING] 没有标准化字段 - scoring模块可能未安装")
|
|
|
|
# 统计有标准化字段的股票数量
|
|
has_norm = sum(1 for s in stocks if 'strengthEqual' in s)
|
|
print(f"\n[OK] {has_norm}/{len(stocks)} 只股票包含标准化字段")
|
|
|
|
print("\n" + "=" * 80)
|
|
print("测试通过!")
|
|
print("=" * 80)
|
|
|
|
except Exception as e:
|
|
print(f"\n[ERROR] 错误: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
sys.exit(1)
|