Query Data Source
When to use
- Any question about stock price, financial indicators, macro economic data, company registry, academic citation counts, or legal statute text that has a real, checkable current value.
- Do NOT answer from training memory for these categories — training data is stale and the user can verify against a real source.
- Call
list_data_sources first when unsure which plugin or API fits (optional domain: finance / macro / academic / enterprise / legal).
How to call
list_data_sources(domain="finance") — discover enabled plugins and api_name values.
query_data_source(data_source_name=..., api_name=..., params={...}) — fetch structured JSON.
- Default chart window:
days: 60 (≈3 个月交易日). A candlestick chart with only 5–10 bars
looks sparse/empty in the chat widget, so this is the default for any "走势/行情/表现如何"
style question — including casual phrasing like "最近一周走势" (interpret as "show me how it's
been doing lately", not literally 5 trading days).
- Only request a shorter window when the user gives an unambiguous analytical ask for an
exact short range (e.g. "对比昨天和前天的收盘价" or "最近3个交易日的具体数字"). Map common asks:
1个月→days:20, 3个月→days:60(默认), 6个月→days:120, 1年→days:250.
- For time-series results (price history, macro trend), must follow with
show_widget:
- Prefer structured JSON (Desktop renders via ECharts):
- The top-level
"type": "stock_chart" field is MANDATORY. Omitting it makes the
Desktop client treat the payload as a generic HTML widget and render the raw JSON
text instead of a chart — always double-check this field is present before calling
show_widget.
Single stock:
{
"type": "stock_chart",
"title": "火炬电子 603678",
"chart_type": "candlestick",
"data_source_label": "获取数据 | AkShare(免费行情)",
"points": [
{"date": "2026-07-01", "open": 80, "high": 90, "low": 78, "close": 85, "volume": 120000}
],
"attribution": "数据来源:AkShare"
}
Multiple focused stocks (Kimi-style tabs — user can switch 火炬电子 / 祥鑫科技 / 天齐锂业):
{
"type": "stock_chart",
"data_source_label": "获取数据 | AkShare(免费行情)",
"attribution": "数据来源:AkShare",
"watchlist": [
{
"symbol": "603678.SH",
"name": "火炬电子",
"chart_type": "candlestick",
"points": [{"date": "2026-07-03", "open": 81.26, "high": 89.4, "low": 77.93, "close": 85.48, "volume": 42942215}]
},
{
"symbol": "002965.SZ",
"name": "祥鑫科技",
"chart_type": "candlestick",
"points": [...]
},
{
"symbol": "002466.SZ",
"name": "天齐锂业",
"chart_type": "candlestick",
"points": [...]
}
]
}
When the user mentions several tickers they are tracking, fetch each via query_data_source and pass one show_widget with a watchlist array — do not render three separate widgets.
CRITICAL — never hand-roll HTML/ECharts for stock charts. Always pass the structured
stock_chart JSON (single points or watchlist). The Desktop client has a dedicated,
theme-aware StockChartWidget (dark/light adaptive tabs, 红涨绿跌, quote header). Hand-written
<div>+ECharts <script> HTML produces broken results (e.g. white tab text on white background,
sparse charts) and must not be used for stock/candlestick data.
Copy the OHLCV rows from the query_data_source result verbatim into points — the result is
already trimmed to date/open/high/low/close/volume and the full window (e.g. 60 rows) fits, so
there is no need to re-query with a smaller days. If a result ever looks truncated, use whatever
rows you have; do NOT loop re-querying the same symbol.
- Macro trends: same shape with
"chart_type": "line" and points like {"date": "2021", "value": 8.1}.
- Workflow (same as show_widget discipline): 1–3 sentences visible intro →
query_data_source → show_widget → interpret numbers from tool output only.
Example calls
| User intent |
data_source_name |
api_name |
params notes |
| A-share K-line / recent trend |
akshare |
stock_price_history |
symbol: 6-digit code without exchange suffix (e.g. 603678, not 603678.SH); market: a; days: 60 default (3 个月), 20/120/250 for 1mo/6mo/1yr |
| A-share snapshot |
akshare |
stock_realtime_quote |
symbol: 603678 |
| China / global macro |
world_bank |
see list_data_sources |
country/indicator codes from API schema |
| IMF indicators |
imf |
see list_data_sources |
per plugin schema |
| Tushare (needs MCP) |
tushare |
per MCP tools |
requires connected tushareMcp in settings |
| iFinD (enterprise) |
ifind |
per plugin |
credential-gated; often unavailable on desktop |
Map query_data_source OHLCV rows to stock_chart.points (normalize date/open/high/low/close/volume field names from the JSON).
Fallback discipline
- MissingCredentialError or connection failure on
ifind / tushare → try free sources (akshare, world_bank, imf) before giving up.
- Tushare without MCP → tell user to connect
tushareMcp in Desktop settings; do not invent prices.
- If all applicable sources fail: say explicitly 「当前数据源暂不可用,无法核实最新数据」. Never substitute a remembered or guessed number.
Known plugins (authoritative list: list_data_sources)
| domain |
plugin |
notes |
| finance |
akshare |
free, no credential, A/HK/US history & A-share quote |
| finance |
tushare |
requires connected tushareMcp |
| finance |
ifind |
enterprise-only, credential-gated |
| macro |
world_bank |
free, global development indicators |
| macro |
imf |
free macro indicators |
1---2name: agenticx-query-data-source3description: Use when the user asks about verifiable quantitative facts (stock prices, financial indicators, macro data, company registry, academic metrics, legal statutes) that must come from a live data source rather than training memory.4---56# Query Data Source78## When to use910- Any question about **stock price**, **financial indicators**, **macro economic data**, **company registry**, **academic citation counts**, or **legal statute text** that has a real, checkable current value.11- **Do NOT** answer from training memory for these categories — training data is stale and the user can verify against a real source.12- Call `list_data_sources` first when unsure which plugin or API fits (optional `domain`: `finance` / `macro` / `academic` / `enterprise` / `legal`).1314## How to call15161. `list_data_sources(domain="finance")` — discover enabled plugins and `api_name` values.172. `query_data_source(data_source_name=..., api_name=..., params={...})` — fetch structured JSON.18 - **Default chart window: `days: 60` (≈3 个月交易日).** A candlestick chart with only 5–10 bars19 looks sparse/empty in the chat widget, so this is the default for any "走势/行情/表现如何"20 style question — including casual phrasing like "最近一周走势" (interpret as "show me how it's21 been doing lately", not literally 5 trading days).22 - Only request a shorter window when the user gives an **unambiguous analytical** ask for an23 exact short range (e.g. "对比昨天和前天的收盘价" or "最近3个交易日的具体数字"). Map common asks:24 `1个月→days:20`, `3个月→days:60`(默认), `6个月→days:120`, `1年→days:250`.253. For **time-series** results (price history, macro trend), **must** follow with `show_widget`:26 - Prefer structured JSON (Desktop renders via ECharts):27 - **The top-level `"type": "stock_chart"` field is MANDATORY.** Omitting it makes the28 Desktop client treat the payload as a generic HTML widget and render the raw JSON29 text instead of a chart — always double-check this field is present before calling30 `show_widget`.3132**Single stock:**3334```json35{36 "type": "stock_chart",37 "title": "火炬电子 603678",38 "chart_type": "candlestick",39 "data_source_label": "获取数据 | AkShare(免费行情)",40 "points": [41 {"date": "2026-07-01", "open": 80, "high": 90, "low": 78, "close": 85, "volume": 120000}42 ],43 "attribution": "数据来源:AkShare"44}45```4647**Multiple focused stocks (Kimi-style tabs — user can switch 火炬电子 / 祥鑫科技 / 天齐锂业):**4849```json50{51 "type": "stock_chart",52 "data_source_label": "获取数据 | AkShare(免费行情)",53 "attribution": "数据来源:AkShare",54 "watchlist": [55 {56 "symbol": "603678.SH",57 "name": "火炬电子",58 "chart_type": "candlestick",59 "points": [{"date": "2026-07-03", "open": 81.26, "high": 89.4, "low": 77.93, "close": 85.48, "volume": 42942215}]60 },61 {62 "symbol": "002965.SZ",63 "name": "祥鑫科技",64 "chart_type": "candlestick",65 "points": [...]66 },67 {68 "symbol": "002466.SZ",69 "name": "天齐锂业",70 "chart_type": "candlestick",71 "points": [...]72 }73 ]74}75```7677When the user mentions several tickers they are tracking, fetch each via `query_data_source` and pass **one** `show_widget` with a `watchlist` array — do not render three separate widgets.7879> **CRITICAL — never hand-roll HTML/ECharts for stock charts.** Always pass the structured80> `stock_chart` JSON (single `points` or `watchlist`). The Desktop client has a dedicated,81> theme-aware `StockChartWidget` (dark/light adaptive tabs, 红涨绿跌, quote header). Hand-written82> `<div>`+ECharts `<script>` HTML produces broken results (e.g. white tab text on white background,83> sparse charts) and must not be used for stock/candlestick data.84>85> **Copy the OHLCV rows from the `query_data_source` result verbatim** into `points` — the result is86> already trimmed to `date/open/high/low/close/volume` and the full window (e.g. 60 rows) fits, so87> there is no need to re-query with a smaller `days`. If a result ever looks truncated, use whatever88> rows you have; do NOT loop re-querying the same symbol.8990 - Macro trends: same shape with `"chart_type": "line"` and points like `{"date": "2021", "value": 8.1}`.914. **Workflow** (same as show_widget discipline): 1–3 sentences visible intro → `query_data_source` → `show_widget` → interpret numbers from tool output only.9293## Example calls9495| User intent | data_source_name | api_name | params notes |96|---|---|---|---|97| A-share K-line / recent trend | `akshare` | `stock_price_history` | `symbol`: **6-digit code without exchange suffix** (e.g. `603678`, not `603678.SH`); `market`: `a`; `days`: **60 default** (3 个月), 20/120/250 for 1mo/6mo/1yr |98| A-share snapshot | `akshare` | `stock_realtime_quote` | `symbol`: `603678` |99| China / global macro | `world_bank` | see `list_data_sources` | country/indicator codes from API schema |100| IMF indicators | `imf` | see `list_data_sources` | per plugin schema |101| Tushare (needs MCP) | `tushare` | per MCP tools | requires connected `tushareMcp` in settings |102| iFinD (enterprise) | `ifind` | per plugin | credential-gated; often unavailable on desktop |103104Map `query_data_source` OHLCV rows to `stock_chart.points` (normalize date/open/high/low/close/volume field names from the JSON).105106## Fallback discipline107108- **MissingCredentialError** or connection failure on `ifind` / `tushare` → try free sources (`akshare`, `world_bank`, `imf`) before giving up.109- **Tushare without MCP** → tell user to connect `tushareMcp` in Desktop settings; do not invent prices.110- If **all** applicable sources fail: say explicitly **「当前数据源暂不可用,无法核实最新数据」**. Never substitute a remembered or guessed number.111112## Known plugins (authoritative list: `list_data_sources`)113114| domain | plugin | notes |115|---|---|---|116| finance | akshare | free, no credential, A/HK/US history & A-share quote |117| finance | tushare | requires connected `tushareMcp` |118| finance | ifind | enterprise-only, credential-gated |119| macro | world_bank | free, global development indicators |120| macro | imf | free macro indicators |