Skip to main content

AI-powered A-share stock analysis with multi-platform data collection

Project description

Aimoon — AI A股分析工具

输入股票代码,自动完成 采集 → 整合 → AI分析 → 可视化报告 四步流程。

# 安装
uv tool install --editable .

# 配置(编辑 .env 填入 API Key)
cp .env.example .env

# 分析任何A股
aimoon 600519                  # 贵州茅台(真实数据)
aimoon 600519 --mock           # Mock模式(无需API Key)
aimoon 600519 --test           # 测试模式(采集真实数据,跳过AI分析)
aimoon test 600519             # 同 --test
aimoon 000001                  # 平安银行
aimoon 000858 -o ./reports     # 五粮液,指定输出目录

数据采集覆盖

数据源 采集方式 数据量 状态
实时行情(含PE) 雪球 stock.xueqiu.com API
财务数据 pysnowball (资产负债表/利润表/现金流)
K线历史 akshare (前复权日线) 120根
资金流向 pysnowball + 东方财富(北向)
机构研报 akshare (东方财富) 最近一年
最新年报/半年报/季报 巨潮资讯 API 缓存30天
东方财富股吧 Playwright 15条
巨潮资讯·公司公告 官方API (股票名称搜索) 20条
微信公众号 搜狗微信搜索 (Playwright绕反爬) 20条
今日头条 Playwright 搜索 18-20条

✅ = 开箱即用   ⚠️ = 需手动配置   🚧 = 开发中


安装指南

前置依赖

  • Python ≥ 3.12
  • uv(Python包管理器): powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
  • Chrome 浏览器 (Playwright 需要)

基础安装

# 1. 进入项目目录
cd aimoon

# 2. 安装依赖
uv sync

# 3. 安装 CLI 工具(全局可用)
pip install -e .

# 4. Playwright 浏览器
uv run playwright install chromium

提示: 也可用 uv tool install --editable . 替代 pip install -e .,两者等效。

升级

git pull
uv sync
pip install -e .             # 重新安装 CLI

卸载

uv tool uninstall aimoon

配置文件 (.env)

# === 必配 ===
DEEPSEEK_API_KEY=sk-xxx          # DeepSeek API Key(--test 模式可跳过)

# === 雪球(推荐配置,可获取含PE的实时行情 + 财报 + 雪球热帖)===
XUEQIU_TOKEN=xq_a_token=xxx; u=xxx
XUEQIU_COOKIE=xq_a_token=xxx; u=xxx

# === 可选 ===
DEEPSEEK_BASE_URL=https://api.deepseek.com   # 自定义 DeepSeek API 地址
MOCK_MODE=false                               # 设为 true 等同 --mock
CACHE_DIR=./cache                             # 数据缓存目录

雪球 Cookie 获取: 浏览器登录 xueqiu.com → F12 → Application → Cookies → 复制 xq_a_tokenu


命令行选项

命令 说明
aimoon <code> 完整分析(采集 + AI分析 + 报告)
aimoon <code> --mock 全模拟数据,无需任何 API Key
aimoon <code> --test 采集真实数据,跳过 AI 分析
aimoon test <code> --test
aimoon <code> -o <dir> 指定报告输出目录
aimoon --version 查看版本号

股票代码规则: 6开头 → 上海(SH),0/3开头 → 深圳(SZ),4/8开头 → 北交所(BJ)


架构

用户输入股票代码 (600519)
     │
     ▼
┌─ ① 数据采集 ─────────────────────────────────────────────┐
│                                                           │
│  行情    → 雪球(含PE) → 新浪 → 腾讯   (三级兜底)          │
│  财报    → pysnowball                                     │
│  K线     → akshare (前复权日线120根)                       │
│  资金    → pysnowball + 东方财富(北向)                     │
│  研报    → akshare (东方财富,最近一年)                    │
│  年报    → 巨潮资讯 API (缓存30天)                         │
│  股吧    → Playwright (15条)                               │
│  公告    → 巨潮资讯 API (20条)                             │
│  微信    → 搜狗搜索 Playwright绕反爬 (20条)                │
│  头条    → Playwright (18-20条)                            │
│                                                           │
└───────────────────────┬───────────────────────────────────┘
                        ▼
┌─ ② 数据整合 + 质量校验 ──────────────────────────────────┐
│   - 各采集器按序执行,单个失败不影响全局                      │
│   - 格式校验 + 跨源交叉验证 + 时效性检查                    │
│   - 数据置信度评分(高/中/低)                               │
└───────────────────────┬───────────────────────────────────┘
                        ▼
┌─ ③ AI 分析 (DeepSeek v4-flash) ──────────────────────────┐
│   深度思考模式 · 当前时间注入 · 财务报告缓存读取            │
│   6维度: 情绪25% + 技术15% + 基本面20%                     │
│          资金15% + 新闻15% + 综合10%                       │
└───────────────────────┬───────────────────────────────────┘
                        ▼
┌─ ④ HTML 报告 (Jinja2 + Chart.js) ────────────────────────┐
│   亮色/暗色主题切换 · 响应式Grid · 红涨绿跌                    │
│   K线折线图 · 三列并排卡片 · 20条帖子展示                   │
│   纯静态HTML,可离线查看                                    │
└─────────────────────────────────────────────────────────────┘

项目结构

src/aimoon/
├── main.py              # CLI 入口 + 流程编排
├── config/settings.py   # 配置管理 (Pydantic + .env)
├── models/              # 数据模型
│   ├── stock.py         # StockQuote, FinancialData, KlineData, FinancialReportData
│   ├── social.py        # SocialPost, CollectResult
│   └── report.py        # AnalysisReport, DimensionScore
├── collectors/          # 数据采集器
│   ├── base.py          # 采集器基类 + 注册表
│   ├── quote.py         # 行情(雪球→新浪→腾讯)
│   ├── kline.py         # K线历史(akshare)
│   ├── fund_flow.py     # 资金流向
│   ├── research_report.py # 机构研报(东方财富,最近一年)
│   ├── eastmoney_playwright.py # 东方财富股吧 (Playwright, 15条)
│   ├── cninfo.py        # 巨潮资讯·公司公告 (20条)
│   ├── wechat.py        # 微信公众号(搜狗搜索 Playwright, 20条)
│   ├── toutiao.py       # 今日头条(Playwright, 18-20条)
│   └── mock.py          # Mock 数据生成器
├── financial/           # 财务数据
│   ├── pysnowball_adapter.py # pysnowball 适配器
│   └── annual_report.py      # 年报/半年报/季报获取与缓存(30天)
├── indicators/          # 技术指标
│   ├── technical.py     # MA/MACD/KDJ/RSI/Bollinger
│   └── capital_flow.py  # 资金流向指标计算
├── ai/                  # DeepSeek 分析引擎
│   └── analyzer.py      # DeepSeek v4-flash 深度思考模式
├── validation/          # 数据质量
│   ├── integrity_checker.py
│   ├── cross_validator.py
│   ├── format_validator.py
│   └── freshness_checker.py
├── scoring/             # 多维评分
│   └── scorer.py        # 11因子评分模型
├── pipeline.py          # 流程编排
├── report/              # 报告生成
│   ├── generator.py     # Jinja2 模板渲染
│   └── templates/index.html
└── utils.py             # 工具函数

输出示例

生成的 HTML 报告包含:

  • 头部:股票代码、实时行情(价格/涨跌/PE)、当前时间
  • 三列卡片:基本面(含数据来源如"2026一季报")/ 资金面 / 估值百分位
  • K线走势图:近120日收盘价折线图 + 成交量柱状图(Chart.js 交互式图表)
  • 全网热度:各平台帖子列表(15-20条,含点赞/评论/链接)
  • 机构研报:评级分布、EPS预测、PDF下载链接(最近一年)
  • AI 综合分析报告:DeepSeek v4-flash 深度思考模式生成
  • 数据质量校验:置信度评分
  • 亮色/暗色主题切换:右上角按钮一键切换,状态自动保存
  • 数据来源清单:每个平台采集状态

报告为纯静态 HTML,可直接通过浏览器打开或分享。


开发

uv sync --group dev          # 安装开发依赖(pytest + ruff + bandit + pylint)
uv sync --extra selenium     # 启用东方财富股吧 Selenium 增强采集
uv run ruff check src/       # Lint 检查
uv run mypy src/aimoon/      # 类型检查

免责声明

本报告由 AI 自动生成,所有分析内容仅供参考,不构成任何投资建议。投资有风险,入市需谨慎。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aimoon-0.3.3.tar.gz (61.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aimoon-0.3.3-py3-none-any.whl (69.6 kB view details)

Uploaded Python 3

File details

Details for the file aimoon-0.3.3.tar.gz.

File metadata

  • Download URL: aimoon-0.3.3.tar.gz
  • Upload date:
  • Size: 61.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for aimoon-0.3.3.tar.gz
Algorithm Hash digest
SHA256 d03451535fe07cb498f9cd0189e1e3102a0cc1717f3df07395a12766a9d5f583
MD5 d82c718d1afbec33e9f363801a033154
BLAKE2b-256 f1a22cea8e1ac610b4d671cc334eab355413d91706b2c919731d719978e4e5db

See more details on using hashes here.

File details

Details for the file aimoon-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: aimoon-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 69.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for aimoon-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ef4d1406fad16feaa1b9e476cabe806c997031000b6bc78a4cd43d9f514451ea
MD5 74fc2ba90125c8b12dfa9602e17077ee
BLAKE2b-256 6d95b94263536dccf7cc5798b6dda5045204150f3f6df8e7ce9f3c54430f7ed6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page