# AI 投资顾问

### 概述

基于 Claude 大语言模型的智能投资顾问，将 Claude 的分析能力与 Infoway 实时金融数据相结合。支持自然语言对话、预设分析模板和 Web 可视化界面。

| 项目        | 说明                                                                                  |
| --------- | ----------------------------------------------------------------------------------- |
| Python 版本 | 3.10+                                                                               |
| 依赖        | `infoway-sdk`、`anthropic`、`streamlit`                                               |
| GitHub    | [infoway-api/infoway-ai-advisor](https://github.com/infoway-api/infoway-ai-advisor) |

### 功能特点

* **自然语言交互**：用日常语言提问即可获取专业金融分析
* **10 个内置数据工具**：自动调用 Infoway API 获取实时数据
* **3 个预设分析模板**：每日市场简报、个股诊断、板块轮动分析
* **Streamlit Web UI**：可视化交互界面
* **CLI 命令行**：适合自动化和脚本调用

### 安装

```bash
git clone https://github.com/infoway-api/infoway-ai-advisor.git
cd infoway-ai-advisor
pip install -r requirements.txt
```

#### 环境变量

```bash
export ANTHROPIC_API_KEY="你的 Anthropic API Key"
export INFOWAY_API_KEY="你的 Infoway API Key"
```

### Web UI

```bash
streamlit run web/app.py
```

启动后在浏览器中打开，可以：

* 在左侧配置 API Key
* 使用预设按钮一键生成分析报告
* 自由输入问题进行对话

### CLI 示例

#### 每日市场简报

```bash
python examples/daily_briefing.py
```

生成港股和美股的每日市场概况，包括市场温度、领涨行业、指数表现等。

#### 个股诊断

```bash
python examples/stock_diagnosis.py AAPL.US
```

对单只股票进行深度分析，包括估值评估、机构评级、关键驱动因素等。

#### 板块轮动分析

```bash
python examples/sector_rotation.py HK
```

分析指定市场的板块轮动模式，识别资金流向和热门概念。

### 内置数据工具

| 工具   | 说明              |
| ---- | --------------- |
| 实时行情 | 获取标的最新成交价、量、涨跌幅 |
| K线数据 | 获取历史K线用于趋势分析    |
| 市场温度 | 获取市场整体情绪和估值水平   |
| 涨跌统计 | 获取市场涨跌家数分布      |
| 全球指数 | 获取全球主要指数行情      |
| 领涨行业 | 获取当日表现最佳的行业板块   |
| 行业列表 | 获取完整行业板块列表      |
| 板块成分 | 获取指定板块内的成分股     |
| 公司概览 | 获取公司基本信息        |
| 估值数据 | 获取估值指标（PE/PB等）  |

### 项目结构

```
ai-advisor/
├── advisor/
│   ├── agent.py       # Claude 工具调用循环（最多15轮）
│   ├── tools.py       # 10个工具定义 + 分发器
│   ├── analysis.py    # 预设分析模板
│   └── report.py      # Markdown 报告格式化
├── web/
│   └── app.py         # Streamlit Web UI
└── examples/
    ├── daily_briefing.py      # 每日简报
    ├── stock_diagnosis.py     # 个股诊断
    └── sector_rotation.py     # 板块轮动
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.infoway.io/sdk-and-tools/ai-advisor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
