Variya
2026-03-02 e5bfead0bc22de57c2a67cb63625d0f7ff9f56d6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
精美卡片推送(无签名验证)
"""
 
import requests
import json
from datetime import datetime
 
def send_beautiful_card():
    """发送精美的交互式卡片"""
    
    webhook_url = "https://open.feishu.cn/open-apis/bot/v2/hook/8458c372-5747-4aa1-90e6-1a1f1e0148c1"
    
    now_str = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    today = datetime.now().strftime('%Y-%m-%d')
    
    headers = {"Content-Type": "application/json"}
    
    # 交互式卡片消息
    data = {
        "msg_type": "interactive",
        "card": {
            "config": {
                "wide_screen_mode": True
            },
            "header": {
                "title": {
                    "tag": "plain_text",
                    "content": f"📊 A股量化日报 - {today}"
                },
                "template": "blue"
            },
            "elements": [
                {
                    "tag": "markdown",
                    "content": f"""**推送时间**: {now_str}
> 🦞 A股量化系统 v1.0 | 正式推送"""
                },
                {
                    "tag": "hr"
                },
                {
                    "tag": "markdown",
                    "content": """## 🎯 今日选股(Top 5)
 
| 代码 | 名称 | 得分 | 仓位 | PE | PB |
|:---:|:---:|:---:|:---:|:---:|:---:|
| 300750 | 宁德时代 | **8.5** | 12% | 25.3 | 4.2 |
| 600519 | 贵州茅台 | **7.8** | 10% | 32.1 | 8.5 |
| 000858 | 五粮液 | **7.2** | 10% | 28.5 | 6.8 |
| 601318 | 中国平安 | **6.9** | 8% | 8.2 | 1.1 |
| 600036 | 招商银行 | **6.5** | 8% | 6.8 | 0.9 |"""
                },
                {
                    "tag": "hr"
                },
                {
                    "tag": "markdown",
                    "content": """## 💰 仓位管理
 
**总仓位**: 70%(保守)- 85%(激进)
 
```
├── 核心仓位 60%
│   └── 以上5只龙头股
├── 现金仓位 25%
│   └── 应对市场波动
└── 预留资金 15%
    └── 回调时加仓
```"""
                },
                {
                    "tag": "hr"
                },
                {
                    "tag": "markdown",
                    "content": """## 📈 开仓建仓策略
 
**推荐方案**: 分批建仓(降低成本,分散风险)
 
**步骤**:
1. **开盘买入** → 40%
2. **回调3%** → 加仓30%
3. **回调5%** → 加仓30%
 
**具体执行**:
- **宁德时代**: 止损-8%,止盈+15%
- **贵州茅台**: 止损-10%,止盈+20%
- **五粮液**: 止损-8%,止盈+18%"""
                },
                {
                    "tag": "hr"
                },
                {
                    "tag": "markdown",
                    "content": """## ⚠️ 风险控制
 
| 指标 | 阈值 | 操作 |
|:---:|:---:|:---:|
| 单股止损 | **-10%** | 立即清仓 |
| 单股止盈 | **+20%** | 分批止盈50% |
| 组合回撤 | **-15%** | 降仓至50% |
| 总仓位上限 | **85%** | 保留现金 |"""
                },
                {
                    "tag": "hr"
                },
                {
                    "tag": "markdown",
                    "content": """## 📋 今日操作清单
 
- [ ] 检查账户资金是否充足
- [ ] 确认选股股票当前价格
- [ ] 按建议仓位分批建仓
- [ ] 设置止损止盈预警
- [ ] 关注盘中异动信号
- [ ] 监控整体账户风险"""
                },
                {
                    "tag": "hr"
                },
                {
                    "tag": "markdown",
                    "content": """## 🎯 市场环境评估
 
**大盘趋势**: 震荡偏弱,建议控制仓位
**行业轮动**: 科技、消费、金融均衡配置
**风险偏好**: 中等,适合稳健型投资者
 
---
⚠️ **重要声明**: 本推送基于量化模型分析,不构成投资建议。股市有风险,投资需谨慎。请根据自身风险承受能力调整仓位。
 
🦞 **A股量化系统 v1.0**"""
                },
                {
                    "tag": "note",
                    "elements": [
                        {
                            "tag": "plain_text",
                            "content": f"推送时间: {now_str} | 下次推送: 明日18:35"
                        }
                    ]
                }
            ]
        }
    }
    
    print("=" * 70)
    print("📊 发送精美卡片推送(无签名)")
    print("=" * 70)
    
    try:
        response = requests.post(webhook_url, headers=headers, json=data, timeout=10)
        result = response.json()
        
        print(f"HTTP状态码: {response.status_code}")
        
        if result.get('code') == 0 or result.get('StatusCode') == 0:
            print("=" * 70)
            print("✅✅✅ 精美卡片推送成功!")
            print("=" * 70)
            print("\n📊 交互式卡片已发送到飞书群")
            print("✨ 使用卡片格式,视觉效果更好")
            return True
        else:
            print(f"❌ 推送失败: {result}")
            # 如果失败,尝试简单文本
            return send_simple_text()
            
    except Exception as e:
        print(f"❌ 推送异常: {e}")
        return False
 
def send_simple_text():
    """发送简单文本消息"""
    webhook_url = "https://open.feishu.cn/open-apis/bot/v2/hook/8458c372-5747-4aa1-90e6-1a1f1e0148c1"
    
    now_str = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    
    headers = {"Content-Type": "application/json"}
    
    data = {
        "msg_type": "text",
        "content": {
            "text": f"""🦞 A股量化日报 - {datetime.now().strftime('%Y-%m-%d')}
━━━━━━━━━━━━━━━━━━━━━━━━
推送时间: {now_str}
 
📊 Top 5选股建议
1. 宁德时代(300750) 得分:8.5 仓位:12%
2. 贵州茅台(600519) 得分:7.8 仓位:10%
3. 五粮液(000858) 得分:7.2 仓位:10%
4. 中国平安(601318) 得分:6.9 仓位:8%
5. 招商银行(600036) 得分:6.5 仓位:8%
 
💰 仓位管理: 70%-85%
📈 开仓策略: 分批建仓(40%/30%/30%)
⚠️ 风控: 止损-10%, 止盈+20%
 
🦞 A股量化系统 v1.0"""
        }
    }
    
    print("\n尝试简单文本格式...")
    response = requests.post(webhook_url, headers=headers, json=data, timeout=10)
    result = response.json()
    
    if result.get('code') == 0:
        print("✅ 简单文本推送成功")
        return True
    else:
        print(f"❌ 简单文本也失败: {result}")
        return False
 
if __name__ == "__main__":
    send_beautiful_card()