domonic18/ai-invest-assisstant

AlphaSight:AI 投资研究工作台——自托管行情采集、每日复盘、涨停归因、产业链分析、知识库问答与交易 Agent 中枢

0forks 1PythonGitHub

AlphaSight · AI Invest Assistant

An end-to-end AI investment research platform: data collection → cleaning & storage → intelligent analysis → visualization.

English | 简体中文


AlphaSight turns raw market data into daily, reusable research: a self-hosted collector pipeline keeps market / capital-flow / news data fresh, an agent runtime (deepagents on LangGraph) generates reviews, attributions and chain analyses, and a React workspace presents everything in one responsive console.

Highlights

Workbench — one-stop market overview: sentiment, hotspots, indices and your watchlist at a glance.

Workbench

Feature Tour

Daily Review — index performance & turnover, limit-up ladder (连板天梯), sector heatmap, limit-up attribution and an AI-generated market summary for every trading day.

Daily Review

Agent Hub (智体中枢) — the mission-control board for your trading agents: live pulse of selections, records, plans, execution and reviews.

Agent Hub

Agent Experience & Lessons — trading agents accumulate memory across runs: lessons learned, disciplines and methods, surfaced as reviewable cards.

Agent Experiences

Knowledge Base Search — the global AI assistant answers investment questions by retrieving knowledge cards from your own course/book library, with original-text citations.

Knowledge Base Search

Industry Chain Graph — versioned industry-chain analysis (nodes, edges, narratives) rendered as an interactive graph.

Industry Chain

Full Capability Map

DomainCapabilities
Market ResearchMulti-timeframe K-line / call-auction trends / sector fund flow (river chart + ranking) / macro index monitoring
Daily ReviewIndex stats / limit-up review / AI market summary (module-level editing) / watchlist cards
AI AnalysisVersioned industry-chain analysis / limit-up attribution / daily watchlist analysis / research & earnings summaries / anomaly detection & attribution / AI trendlines / AI stock screening
News & KnowledgeNear-real-time cls.cn telegraph / news importance grading / hot-topic clustering / investment calendar / knowledge-base retrieval QA
AI AssistantGlobal chat panel (deepagents streaming + tool calling + session persistence + page-context awareness)
Agent HubTrading agents with per-task prompts & skills, run streaming, HITL interrupts, experience memory (lessons / disciplines / methods)
Paper TradingJuejin online simulation (account sync / order & cancel / NAV curve / trade markers on K-line)
PlatformSkill square (zip distribution / custom skills) / user settings (theme, MAs, AI quota) / admin console (21 modules) / user-group feature permissions

Architecture

Browser (desktop / mobile, responsive SPA)
   │  HTTPS  invest.example.com
   ▼
Caddy (TLS termination, auto Let's Encrypt)
   │  reverse proxy
   ▼
web :9000  ── all-in-one image ── FastAPI + React SPA (single uvicorn, SSE streaming,
   │                            in-process deepagents assistant)
   │  same-host docker network
   ├─ PostgreSQL (TimescaleDB, pg_trgm + pgvector)  ├─ Redis
   ├─ celery-beat + workers (realtime+batch / heavy)
   ├─ collector-stream (news telegraph)             ├─ paper-trade sidecar
   └─ douyin-signer sidecar                         ── COS (S3): PDFs, KB files, backups
  • Data layer: PostgreSQL with TimescaleDB; hybrid retrieval via pg_trgm + pgvector (halfvec).
  • Task layer: Celery beat + dual workers; a dedicated stream consumer ingests the news telegraph.
  • AI layer: deepagents (LangChain/LangGraph) with YAML prompts, skills and MCP tools; per-user BYOD model config (bring your own key) with quota metering.
  • Deployment: GitHub Actions builds images → Tencent Container Registry (TCR) → production server pulls by tag (develop-<sha>).

Full architecture design: docs/arch/ (10 documents, 00–09).

Tech Stack

LayerTechnologies
Backend APIFastAPI, Python 3.10+, SQLAlchemy 2.0, Pydantic 2.7
Web FrontendReact 18, TypeScript, Vite, TanStack Query, Zustand, Ant Design
AI Agentdeepagents (LangChain / LangGraph) + YAML prompts + Skills + MCP
Data CollectionIn-house collector runtime, Celery, httpx / akshare / curl_cffi
VisualizationECharts, AntV G6 v5, D3.js
StoragePostgreSQL (TimescaleDB, pg_trgm + pgvector), Redis, COS (S3-compatible)
Package Mgmtuv (Python), npm (frontend)

Quick Start

Option A — full stack via Docker Compose

cp .env.example .env                # fill in what you need
docker compose up -d postgres redis # infrastructure first, wait for healthy
bash docker/database/migrate.sh     # create schema / run migrations (ledger-based)
docker compose up -d                # web on :9000, health check at /health

Option B — local development (outside containers)

Requires uv and Node.js 18+.

# 1. Infrastructure
docker compose up -d postgres redis

# 2. Backend on :9000 (Vite dev proxy targets 127.0.0.1:9000)
cd backend
uv sync
uv run uvicorn app.main:app --reload --port 9000

# 3. Frontend on :5173 (proxies /api to the backend)
cd web
npm install
npm run dev

# 4. Optional sidecars
docker compose up -d paper-trade douyin-signer

Open http://localhost:5173 and register the first user (promote to admin via role in DB or the admin console).

Production deployment

Production runs from a single compose file on the server (images only, no build):

docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d postgres --wait
bash docker/database/migrate.sh     # with COMPOSE_FILE=docker-compose.prod.yml
docker compose -f docker-compose.prod.yml up -d --wait --remove-orphans --no-build

Images are built and pushed to TCR by GitHub Actions; the pinned tag lives in the server's .env as APP_TAG=develop-<sha>.

Common Commands

# Backend type-check / lint / tests
cd backend
uv run mypy app/
uv run ruff check .
uv run pytest -m unit

# Frontend type-check / lint / tests
cd web
npm run typecheck
npm run lint
npm run test:unit

Project Structure

ai-invest-assisstant/
├── backend/
│   ├── app/                    # FastAPI app (api / services / repositories / models / schemas / agent)
│   ├── collector/              # collector runtime (core / runtime / specs / spiders / stores)
│   └── tests/                  # pytest unit & integration tests
├── web/                        # React web app (src/ + Playwright e2e/)
├── shared/                     # FE/BE shared contract package (endpoints + types)
├── skills/                     # skill units (SKILL.md + prompt.yaml, self-contained)
├── docker/                     # images (web / collector / signer / paper-trade) + database migrations
├── docs/                       # arch (design) / plan / requirement / prototypes
├── qa/                         # black-box integration QA (standalone uv project)
└── docker-compose.yml          # full-stack orchestration (dev & prod base)

Documentation

License

MIT — see LICENSE.

进展动态

  1. feat(watchlist): 自选股右键菜单支持移动到其他分组@诸葛东明commit
  2. feat(watchlist): 自选股右键菜单支持移动到其他分组@Domoniccommit
  3. feat(watchlist): 自选股列表支持右键删除个股@诸葛东明commit
  4. feat(watchlist): 自选股列表支持右键删除个股@Domoniccommit
  5. Merge pull request #179 from domonic18/fix/cninfo-annual-report-summary-collision@诸葛东明commit
  6. fix(cninfo): 同日年报摘要不再覆盖年报正文@Domoniccommit
  7. Merge pull request #178 from domonic18/fix/cninfo-pdf-nul-bytes@诸葛东明commit
  8. fix(cninfo): 清洗 PDF 抽取文本中的 NUL 字节,修复年报写入失败@Domoniccommit
  9. Merge pull request #177 from domonic18/feat/kline-history-backfill@诸葛东明commit
  10. feat(web): 个股页打开即补采全历史,并提示历史不足@Domoniccommit
  11. feat(kline): 接口透出历史截断判据,供前端触发全历史补采@Domoniccommit
  12. fix(trading): 计划输入锚点兜底落库全量历史,避免半截历史污染个股K线@Domoniccommit
  13. feat(collector): 日K采集宇宙扩展至Agent选股与交易计划@Domoniccommit
  14. fix(collector): 补抓科创板名单,修复 688/689 上市日期缺失@Domoniccommit
  15. Merge pull request #176 from domonic18/develop@诸葛东明commit
  16. Merge pull request #175 from domonic18/feat/llm-slot-primary-backup@诸葛东明commit
  17. feat(assistant): 流中断对账恢复与工具调用三态呈现@Domoniccommit
  18. feat(assistant): SSE 心跳维持连接活性,state 端点暴露 run 存活信号@Domoniccommit
  19. Merge pull request #174 from domonic18/feat/llm-slot-primary-backup@诸葛东明commit
  20. test(stock): 切股视图继承契约与缩放窗口映射单测@Domoniccommit