Initial commit: Hermes Agent skills collection
- Trading skills (OKX, dividend, lottery, quantitative) - Creative skills (ASCII art, diagrams, video) - Development skills (GitHub, debugging, TDD) - Research skills (arXiv, blog monitoring) - Productivity skills (email, documents, notes) - MCP integration skills - Custom user skills
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
# A股买点分析框架
|
||||
|
||||
综合技术面 + 估值 + 财务 + 盈利预测的完整分析模板。
|
||||
|
||||
## 分析步骤
|
||||
|
||||
### 1. 获取数据
|
||||
|
||||
```python
|
||||
import akshare as ak
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
symbol = '000333' # 股票代码
|
||||
today = datetime.now().strftime('%Y%m%d')
|
||||
start_1y = (datetime.now() - timedelta(days=365)).strftime('%Y%m%d')
|
||||
|
||||
# K线(近1年)
|
||||
df = ak.stock_zh_a_hist(symbol=symbol, period='daily',
|
||||
start_date=start_1y, end_date=today, adjust='qfq')
|
||||
```
|
||||
|
||||
**⚠️ 代理问题**:如果系统有全局代理,AKShare 会报 `ProxyError`。
|
||||
先清除代理:
|
||||
```bash
|
||||
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
|
||||
```
|
||||
或 Python 内:
|
||||
```python
|
||||
for k in ['http_proxy','https_proxy','HTTP_PROXY','HTTPS_PROXY']:
|
||||
os.environ.pop(k, None)
|
||||
```
|
||||
|
||||
### 2. 技术面分析
|
||||
|
||||
#### 价格位置
|
||||
```python
|
||||
current = df.iloc[-1]
|
||||
year_high = df['最高'].max()
|
||||
year_low = df['最低'].min()
|
||||
position = (current['收盘'] - year_low) / (year_high - year_low) * 100
|
||||
```
|
||||
|
||||
#### 均线系统
|
||||
```python
|
||||
for m in [5, 10, 20, 60, 120]:
|
||||
ma = pd.Series(df['收盘']).rolling(m).mean().iloc[-1]
|
||||
dist = (current['收盘'] - ma) / ma * 100 # 偏离度
|
||||
```
|
||||
|
||||
均线多头排列 = 短期在长期之上。偏离度 >5% 警惕回调,<-5% 可能超跌。
|
||||
|
||||
#### ATR 波动率
|
||||
```python
|
||||
tr_list = []
|
||||
for i in range(1, len(df.tail(20))):
|
||||
h_l = df.tail(20).iloc[i]['最高'] - df.tail(20).iloc[i]['最低']
|
||||
h_pc = abs(df.tail(20).iloc[i]['最高'] - df.tail(20).iloc[i-1]['收盘'])
|
||||
l_pc = abs(df.tail(20).iloc[i]['最低'] - df.tail(20).iloc[i-1]['收盘'])
|
||||
tr_list.append(max(h_l, h_pc, l_pc))
|
||||
atr14 = sum(tr_list[-14:]) / min(14, len(tr_list))
|
||||
```
|
||||
|
||||
#### 支撑阻力
|
||||
```python
|
||||
support20 = df.tail(20)['最低'].min()
|
||||
resist20 = df.tail(20)['最高'].max()
|
||||
support60 = df.tail(60)['最低'].min()
|
||||
resist60 = df.tail(60)['最高'].max()
|
||||
```
|
||||
|
||||
#### 量能分析
|
||||
```python
|
||||
avg_vol_20 = df.tail(20)['成交量'].mean()
|
||||
latest_vol_ratio = df.iloc[-1]['成交量'] / avg_vol_20
|
||||
```
|
||||
量比 > 1.5 = 显著放量,< 0.5 = 缩量。
|
||||
|
||||
#### MACD
|
||||
```python
|
||||
closes = df['收盘'].values
|
||||
ema12 = pd.Series(closes).ewm(span=12).mean().iloc[-1]
|
||||
ema26 = pd.Series(closes).ewm(span=26).mean().iloc[-1]
|
||||
dif = ema12 - ema26
|
||||
dea = pd.Series(pd.Series(closes).ewm(span=12).mean() - pd.Series(closes).ewm(span=26).mean()).ewm(span=9).mean().iloc[-1]
|
||||
```
|
||||
|
||||
#### 近期趋势强度
|
||||
```python
|
||||
up_days = len(df.tail(20)[df.tail(20)['涨跌幅'] > 0])
|
||||
down_days = 20 - up_days
|
||||
recent_10_return = df.tail(10)['涨跌幅'].sum()
|
||||
recent_5_return = df.tail(5)['涨跌幅'].sum()
|
||||
```
|
||||
|
||||
### 3. 估值分析
|
||||
|
||||
```python
|
||||
# 东方财富实时行情含PE/PB/市值
|
||||
df_spot = ak.stock_zh_a_spot_em()
|
||||
row = df_spot[df_spot['代码'] == symbol].iloc[0]
|
||||
pe_dynamic = row['市盈率-动态']
|
||||
pb = row['市净率']
|
||||
market_cap = row['总市值']
|
||||
```
|
||||
|
||||
### 4. 盈利预测
|
||||
|
||||
```python
|
||||
df_fc = ak.stock_profit_forecast_ths(symbol=symbol)
|
||||
# 返回: 年度, 预测机构数, 最小值, 均值, 最大值, 行业平均数
|
||||
|
||||
# 计算远期PE
|
||||
current_price = df.iloc[-1]['收盘']
|
||||
for _, r in df_fc.iterrows():
|
||||
pe_fwd = current_price / r['均值']
|
||||
print(f"{r['年度']}E PE: {pe_fwd:.1f}x")
|
||||
```
|
||||
|
||||
### 5. 财务基本面
|
||||
|
||||
**new API (长格式)**:
|
||||
```python
|
||||
df_f = ak.stock_financial_abstract_new_ths(symbol=symbol)
|
||||
profit = df_f[df_f['metric_name'] == 'parent_holder_net_profit'].iloc[0]
|
||||
yoy = profit['yoy'] # 同比增长率
|
||||
```
|
||||
|
||||
**旧API (宽格式)**:
|
||||
```python
|
||||
df_f = ak.stock_financial_abstract_ths(symbol=symbol)
|
||||
```
|
||||
|
||||
**现金流**:
|
||||
```python
|
||||
df_cf = ak.stock_financial_cash_ths(symbol=symbol)
|
||||
```
|
||||
|
||||
**资产负债**:
|
||||
```python
|
||||
df_d = ak.stock_financial_debt_ths(symbol=symbol)
|
||||
```
|
||||
|
||||
### 6. 买点策略模板
|
||||
|
||||
#### 策略A:回踩均线建仓(稳健)
|
||||
```
|
||||
第一买点: MA20 ± 0.5
|
||||
止损: S60 - 1 (略低于中期支撑)
|
||||
目标: R20 (近20日高点)
|
||||
```
|
||||
|
||||
#### 策略B:突破确认加仓(激进)
|
||||
```
|
||||
第一买点: 现价轻仓
|
||||
第二买点: 突破MA20后回踩确认
|
||||
止损: MA10下方
|
||||
目标: 前高
|
||||
```
|
||||
|
||||
#### 策略C:等回调(最稳健)
|
||||
```
|
||||
买点: S20 ~ (S20 + 0.5 * ATR)
|
||||
止损: S60 - ATR
|
||||
目标: R20
|
||||
```
|
||||
|
||||
### 输出格式
|
||||
|
||||
简洁卡片式,用 emoji + 表格,避免大段文字。包含:
|
||||
- 📊 盘面概览(今日涨跌、量比、ATR)
|
||||
- 📈 均线位置(表格式)
|
||||
- 🎯 支撑阻力
|
||||
- 💰 估值(PE/PB + 远期PE)
|
||||
- ⚡ 催化剂 + ⚠️ 风险
|
||||
- 具体买点/止损/目标位
|
||||
|
||||
### 数据源选择
|
||||
|
||||
| 数据 | 推荐函数 | 速度 |
|
||||
|------|----------|------|
|
||||
| K线/行情 | `stock_zh_a_hist()` 东方财富 | 1-2s |
|
||||
| 实时行情含PE | `stock_zh_a_spot_em()` 东方财富 | ~70s(首) / 快(缓存) |
|
||||
| 财务摘要(新) | `stock_financial_abstract_new_ths()` | 2-3s |
|
||||
| 财务摘要(旧/宽) | `stock_financial_abstract_ths()` | 2-3s |
|
||||
| 盈利预测 | `stock_profit_forecast_ths()` | 2-3s |
|
||||
| 现金流 | `stock_financial_cash_ths()` | 2-3s |
|
||||
| 资产负债 | `stock_financial_debt_ths()` | 2-3s |
|
||||
| 主营业务 | `stock_zyjs_ths()` | 1-2s |
|
||||
Reference in New Issue
Block a user