> For the complete documentation index, see [llms.txt](https://docs.infoway.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infoway.io/en-docs/sdk-and-tools/ai-advisor.md).

# AI Investment Advisor

### Overview

An AI-powered investment advisor combining Claude's analytical capabilities with Infoway real-time financial data. Supports natural language queries, pre-built analysis templates, and a web visualization interface.

| Item         | Details                                                                             |
| ------------ | ----------------------------------------------------------------------------------- |
| Python       | 3.10+                                                                               |
| Dependencies | `infoway-sdk`, `anthropic`, `streamlit`                                             |
| GitHub       | [infoway-api/infoway-ai-advisor](https://github.com/infoway-api/infoway-ai-advisor) |

### Features

* **Natural language interaction**: Ask questions in everyday language to get professional financial analysis
* **10 built-in data tools**: Automatically calls Infoway API for real-time data
* **3 pre-built analysis templates**: Daily market briefing, stock diagnosis, sector rotation
* **Streamlit Web UI**: Visual interactive interface
* **CLI**: Suitable for automation and scripting

### Installation

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

#### Environment Variables

```bash
export ANTHROPIC_API_KEY="your_anthropic_api_key"
export INFOWAY_API_KEY="your_infoway_api_key"
```

### Web UI

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

Once launched, open in browser to:

* Configure API keys in the sidebar
* Use preset buttons for one-click analysis reports
* Enter free-form questions for conversation

### CLI Examples

#### Daily Market Briefing

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

Generates a daily market overview for HK and US markets, including market temperature, leading industries, index performance, etc.

#### Stock Diagnosis

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

Deep analysis of a single stock, including valuation assessment, institutional ratings, key driver factors, etc.

#### Sector Rotation Analysis

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

Analyzes sector rotation patterns for a given market, identifying capital flows and trending concepts.

### Built-in Data Tools

| Tool               | Description                                       |
| ------------------ | ------------------------------------------------- |
| Real-time Trades   | Get latest price, volume, and change for symbols  |
| K-line Data        | Get historical K-lines for trend analysis         |
| Market Temperature | Get overall market sentiment and valuation levels |
| Market Breadth     | Get advance / decline distribution                |
| Global Indexes     | Get major global index quotes                     |
| Leading Industries | Get top-performing industry sectors               |
| Industry List      | Get full industry sector list                     |
| Sector Members     | Get constituent stocks of a sector                |
| Company Overview   | Get company profile                               |
| Valuation Data     | Get valuation metrics (PE/PB, etc.)               |

### Project Structure

```
ai-advisor/
├── advisor/
│   ├── agent.py       # Claude tool-use loop (max 15 rounds)
│   ├── tools.py       # 10 tool definitions + dispatcher
│   ├── analysis.py    # Pre-built analysis templates
│   └── report.py      # Markdown report formatter
├── web/
│   └── app.py         # Streamlit Web UI
└── examples/
    ├── daily_briefing.py      # Daily briefing
    ├── stock_diagnosis.py     # Stock diagnosis
    └── sector_rotation.py     # Sector rotation
```

***
