#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 30分钟市场状态识别 - 测试报告邮件发送 """ import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.header import Header from datetime import datetime import pandas as pd # SMTP配置 SMTP_SERVER = 'localhost' SMTP_PORT = 25 SENDER = 'quant@openclaw.local' RECEIVER = '380880504@qq.com' print("="*60) print(f"30分钟市场状态识别 - 测试报告") print(f"生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") print("="*60) # 加载优化版结果 try: df = pd.read_csv('/root/.openclaw/workspace/market-regime-identifier-30/cyb50_30min_regime_v2.csv', index_col=0, parse_dates=True) latest = df.iloc[-1] state_names = ['震荡', '趋势', '反转'] state_name = state_names[int(latest['state'])] # 计算最近5天统计 last_5d = df.tail(80) # 约5个交易日 state_dist = last_5d['state'].value_counts() html = f"""
生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
| 状态 | 概率 | 交易建议 |
|---|---|---|
| 🟦 震荡 | {latest['prob_ranging']:.2%} | 观望/区间交易 |
| 🟩 趋势 | {latest['prob_trend']:.2%} | 趋势跟随 |
| 🟧 反转 | {latest['prob_reversal']:.2%} | 反向/减仓 |
| 状态 | 周期数 | 占比 |
|---|---|---|
| 🟦 震荡 | {state_dist.get(0, 0)} | {state_dist.get(0, 0)/len(last_5d)*100:.1f}% |
| 🟩 趋势 | {state_dist.get(1, 0)} | {state_dist.get(1, 0)/len(last_5d)*100:.1f}% |
| 🟧 反转 | {state_dist.get(2, 0)} | {state_dist.get(2, 0)/len(last_5d)*100:.1f}% |
测试准确率: 83.41%
特征数量: 61个
策略回测收益: +29.00%
策略胜率: 48.4%
交易次数: 281次
| 排名 | 特征 | 重要性 |
|---|---|---|
| 1 | 4小时累计收益 | 37.7% |
| 2 | 半日收益率 | 27.1% |
| 3 | 当前周期收益 | 12.6% |
| 4 | MACD柱状图 | 5.3% |
| 5 | 均线斜率 | 3.6% |
数据来源: 创业板50指数 (sz399673)
模型版本: 30分钟状态识别 v2 (优化版)
数据区间: 2024-03-12 ~ 2026-01-19