# Data Query

> Market data discovery and retrieval for A-shares. List available securities, get security details, and query K-line data across intraday and daily periods from the mist backend.

- Skill: `mist-trade/data-query` (Agent Skill, multi-file: 5 files)
- Install (CLI): `npx skillmds@latest add mist-trade/data-query`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mist-trade/data-query/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Product & Planning
- Author: mist-trade (https://skillmd.com/u/mist-trade)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/mist-trade/data-query

---


# Data Query

Retrieve market data from the mist stock analysis backend.

## Available Scripts

### list_indices
List all available securities (stocks, indices, funds).
```bash
python scripts/list_indices.py
```
Returns: Array of `{id, symbol, name, type}` objects.

### get_index_info
Get details for a specific security by code.
```bash
python scripts/get_index_info.py --code 000001.SH
```
Parameters:
- `--code` (required): Security code, e.g. `000001.SH`, `399006.SZ`

### get_kline_data
Query intraday K-line data. If stored data is missing, this script can
initialize the security, attach a data source, trigger Mist collection, and
retry the query.
```bash
python scripts/get_kline_data.py --code 600519.SH --name "贵州茅台" --period 60min --start-date "2026-06-26 09:30:00" --end-date "2026-06-26 15:00:00"
```
Parameters:
- `--code` (required): Security code
- `--period` (required): One of `1min`, `5min`, `15min`, `30min`, `60min` (converted to Mist numeric period values before request)
- `--start-date` (required): Start date (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS)
- `--end-date` (required): End date (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS)
- `--source` (optional): Data source — `ef` (East Money), `tdx` (TongDaXin), `mqmt` (MaQiMaTe). Defaults to `MIST_DEFAULT_SOURCE` or `tdx`
- `--name` (optional): Security display name used when the security must be initialized
- `--no-auto-collect` (optional): Only query stored data; do not initialize or collect

### get_daily_kline
Query daily K-line data. If stored data is missing, this script can initialize
the security, attach a data source, trigger Mist collection, and retry the query.
```bash
python scripts/get_daily_kline.py --code 600519.SH --name "贵州茅台" --start-date "2026-06-21" --end-date "2026-06-28"
```
Parameters:
- `--code` (required): Security code
- `--start-date` (required): Start date
- `--end-date` (required): End date
- `--source` (optional): Data source, defaults to `MIST_DEFAULT_SOURCE` or `tdx`
- `--name` (optional): Security display name used when the security must be initialized
- `--no-auto-collect` (optional): Only query stored data; do not initialize or collect

## Usage Pattern

1. Run `list_indices` first to discover available securities
2. Use `get_index_info` to verify a specific symbol
3. Query K-line data with `get_kline_data` (intraday/minute/hour) or `get_daily_kline` (daily)
4. For a daily query like "贵州茅台最近一周日线", call `get_daily_kline` directly with `--code 600519.SH --name "贵州茅台"`; do not call the security API manually, because Mist uses `POST /v1/securities`, `POST /v1/security-sources`, and `POST /v1/collector/collect` internally.

## AstrBot Intent Examples

- "有哪些股票可以查" → run `list_indices`
- "贵州茅台最近一周日线" → run `get_daily_kline --code 600519.SH --name 贵州茅台`
- "贵州茅台今天 60 分钟 K 线" → run `get_kline_data --code 600519.SH --name 贵州茅台 --period 60min`

Defaults and guardrails:
- Default source is `tdx` unless the user requests another source.
- Prefer `daily` when the user does not specify a period.
- Ask for a code or infer one confidently before calling scripts.
- Reject unbounded multi-symbol history requests and ask the user to narrow the scope.

## Response Fields

K-line data returns: `id`, `symbol`, `time`, `amount`, `open`, `close`, `high`, `low`.

## Mist API Notes

The current Mist backend expects numeric period enum values. Use the aliases
above in Skill calls; scripts convert them automatically.

