提供A股实时行情、技术指标、财务数据和市场情绪分析,生成详细的Markdown格式综合投资报告。
本技能提供全方位的A股分析能力,包括:
fetch_realtime_data.py 获取实时行情fetch_technical_indicators.py 分析技术指标fetch_fundamental_data.py 获取财务数据fetch_sentiment_data.py 分析市场情绪generate_report.py 生成美观的分析报告# 1. 获取实时行情
from scripts.fetch_realtime_data import AShareRealTimeFetcher
fetcher = AShareRealTimeFetcher()
data = fetcher.fetch_stock_data("600519")
# 2. 技术分析
from scripts.fetch_technical_indicators import AShareTechnicalAnalyzer
analyzer = AShareTechnicalAnalyzer()
technical = analyzer.analyze_technical_indicators("0.600519")
# 3. 基本面分析
from scripts.fetch_fundamental_data import AShareFundamentalFetcher
fund_fetcher = AShareFundamentalFetcher()
fundamental = fund_fetcher.fetch_financial_report("600519")
# 4. 生成报告
from scripts.generate_report import AShareReportGenerator
generator = AShareReportGenerator()
report = generator.generate_markdown_report({
"stocks": {
"600519": {
"name": "贵州茅台",
**data,
"technical": technical,
"fundamental": fundamental
}
}
})
print(report)
from scripts.fetch_realtime_data import AShareRealTimeFetcher
fetcher = AShareRealTimeFetcher()
# 获取单个指数
sh_index = fetcher.fetch_index_data("sh000001") # 上证指数
sz_index = fetcher.fetch_index_data("sz399001") # 深证成指
# 批量获取指数
indices = fetcher.fetch_multiple_indices([
"sh000001", # 上证指数
"sz399001", # 深证成指
"sz399006", # 创业板指
"sz399005", # 科创50
])
# 获取单个股票
stock_data = fetcher.fetch_stock_data("600519") # 贵州茅台
# 批量获取股票
stocks_data = fetcher.fetch_multiple_stocks([
"600519", # 贵州茅台
"000858", # 五粮液
"300750", # 宁德时代
])
{
"code": "600519",
"name": "贵州茅台",
"price": 1800.50, # 当前价格
"change": 8.50, # 涨跌额
"change_percent": 0.47, # 涨跌幅 (%)
"volume": "12.5万", # 成交量
"amount": "22.5亿", # 成交额
"high": 1810.00, # 最高价
"low": 1790.00, # 最低价
"open": 1792.00, # 开盘价
"pre_close": 1792.00, # 昨收价
"time": "2026-02-27 14:30:00" # 更新时间
}
from scripts.fetch_technical_indicators import AShareTechnicalAnalyzer
analyzer = AShareTechnicalAnalyzer()
# 获取技术指标
technical = analyzer.analyze_technical_indicators("0.600519")
{
"code": "0.600519",
"name": "贵州茅台",
"current_price": 1800.50,
"ma": {
"5": 1795.23, # MA5
"10": 1788.45, # MA10
"20": 1775.67, # MA20 (中期趋势)
"60": 1750.89 # MA60 (长期趋势)
},
"macd": {
"dif": 5.23, # DIF
"dea": 3.45, # DEA
"macd": 3.56, # MACD柱
"signal": "bullish" # 看多/看空信号
},
"rsi": 65.32, # RSI值
"volume_ratio": 1.85, # 成交量比
"trend": "bullish", # 趋势: bullish/bearish/neutral
"support": 1780.00, # 支撑位
"resistance": 1830.00 # 阻力位
}
均线排列:
MACD信号:
bullish: DIF > DEA 且金叉,看多信号bearish: DIF < DEA 且死叉,看空信号RSI信号:
from scripts.fetch_fundamental_data import AShareFundamentalFetcher
fund_fetcher = AShareFundamentalFetcher()
# 获取财务报表
financial = fund_fetcher.fetch_financial_report("600519", "20231231")
{
"code": "600519",
"name": "贵州茅台",
"report_date": "20231231",
"total_revenue": 1234567890, # 营业总收入
"operating_revenue": 1234567890, # 营业收入
"net_profit": 617283945, # 净利润
"total_profit": 617283945, # 利润总额
"total_revenue_growth": 12.34, # 营收同比增长
"net_profit_growth": 15.67, # 净利润同比增长
"roe": 32.56, # ROE (%)
"debt_to_asset": 20.15, # 资产负债率 (%)
"gross_margin": 91.23, # 毛利率 (%)
"net_margin": 50.00, # 净利率 (%)
"return_on_asset": 25.67, # ROA (%)
"current_ratio": 3.45, # 流动比率
"quick_ratio": 2.34, # 速动比率
"psr": 4.56, # 市销率
"pe_ttm": 28.56, # 市盈率TTM
"pb": 8.23, # 市净率
"market_cap": 2256789000000, # 总市值
"circulating_market_cap": 2256789000000 # 流通市值
}
# 计算估值指标(需要传入当前股价)
valuation = fund_fetcher.calculate_valuation_metrics("600519", 1800.50)
{
"code": "600519",
"name": "贵州茅台",
"current_price": 1800.50,
"market_cap": 2256789000000,
"pe": 28.56, # PE = 净利润 / 股价
"pb": 8.23, # PB = 市值 / 总资产
"ps": 4.56, # PS = 市值 / 营收
"roe": 32.56,
"net_margin": 50.00
}
from scripts.fetch_sentiment_data import AShareSentimentAnalyzer
sentiment_analyzer = AShareSentimentAnalyzer()
# 获取情绪分析
sentiment = sentiment_analyzer.analyze_sentiment_summary()
{
"date": "2026-02-27",
"northbound": {
"stock_count": 3567,
"total_inflow": 45.67, # 总成交额 (亿元)
"net_inflow": 23.45, # 净流入 (亿元)
"avg_net_inflow": 0.0066, # 平均净流入 (亿元/只)
"signal": "强势流入" # 信号: 强势流入/小幅流入/小幅流出/强势流出
},
"market_sentiment": {
"bullish_ratio": 45.23, # 看多比例
"bearish_ratio": 30.45, # 看空比例
"neutral_ratio": 24.32, # 观望比例
"signal": "NEUTRAL" # bullish/bearish/neutral
},
"l2h_list": [
{
"code": "300750",
"name": "宁德时代",
"change_percent": 10.01,
"limit_type": "首次上榜",
"net_amount": 12300000, # 净买入 (元)
"buy_amount": 25000000,
"sell_amount": 12700000
}
]
}
from scripts.generate_report import AShareReportGenerator
generator = AShareReportGenerator()
# 生成报告
report = generator.generate_markdown_report(
analysis_data={
"summary": "今日A股市场震荡调整...",
"indices": {...},
"stocks": {
"600519": {
"name": "贵州茅台",
**stock_data,
"technical": technical_data,
"fundamental": fundamental_data
}
},
"sentiment": sentiment_data,
"recommendations": {
"indices": {...},
"stocks": {...},
"risk_level": "中等风险"
}
},
report_title="贵州茅台深度分析报告"
)
print(report)
# 保存到文件
filepath = generator.save_report(report, "a-share-analysis-report.md")
print(f"报告已保存至: {filepath}")
| 指数名称 | 代码 | 说明 |
|---|---|---|
| 上证指数 | sh000001 | 上海主板综合指数 |
| 深证成指 | sz399001 | 深圳主板综合指数 |
| 创业板指 | sz399006 | 创业板综合指数 |
| 科创50 | sz399005 | 科创板50指数 |
| 沪深300 | sh000300 | 沪深300指数 |
| 中证500 | sz399905 | 中证500指数 |
| 中证1000 | sz399910 | 中证1000指数 |
0.600519 (贵州茅台)1.000858 (五粮液)技术面:
基本面:
情绪面:
综合判断:
趋势判断:
市场情绪:
投资建议:
a-share-analysis/
├── SKILL.md (本文件)
├── scripts/
│ ├── fetch_realtime_data.py # 实时行情获取
│ ├── fetch_technical_indicators.py # 技术指标分析
│ ├── fetch_fundamental_data.py # 基本面分析
│ ├── fetch_sentiment_data.py # 情绪分析
│ └── generate_report.py # 报告生成
└── references/
└── data_sources.md # 数据源说明
ZIP package — ready to use