Query a dataset (PIT-safe)
query_datasetQuery rows with built-in look-ahead protection.
★ POINT-IN-TIME: pass `as_of` (YYYY-MM-DD) for backtesting/agent-learning. For non-point-in-time-safe
datasets (fundamentals, monthly_revenue, dividend_policy…) rows are filtered by DISCLOSURE date <= as_of,
so the agent only sees what was public at that moment. Omit as_of only for present-day lookups (warned).
★ IF A VALUE IS IN `coverage.missing`, IT IS NOT AVAILABLE. Say it is not available. **Never
estimate it, interpolate it, infer it from a neighbouring period, or carry the last known value
forward.** `coverage.missing` lists exactly what was requested and not returned, with a reason
(e.g. "9999 在 as_of 當日未上市"). An empty `data` array alongside a populated `missing` list is a
complete and correct answer to "what do you have" — not an invitation to fill the gap.
★ EVERY VALUE IS ATTRIBUTABLE. `provenance` carries {source, source_role, ingested_at, revision,
provenance_uri}; `meta.query_id` names this exact question. Quote the query_id when reporting a
number — `replay_query(query_id)` returns the bytes that were served, so the claim can be checked
later. `freshness.is_stale` is computed server-side against the dataset's own cadence budget;
`null` means it could not be determined, which is NOT the same as fresh.
Args:
dataset_id: see list_datasets. tickers: e.g. ['2330','2317']. start/end: 'YYYY-MM-DD' range.
as_of: knowledge-time cutoff 'YYYY-MM-DD' (use for backtests). limit: <=5000.
Returns: {meta:{table,coverage,row_count,as_of_applied,point_in_time_safe,warnings,query_id},
data:[...], provenance:{...}, coverage:{requested,returned,missing,reason},
freshness:{status,latest_available,expected_lag,is_stale}}
Example: query_dataset('income_statement', tickers=['2330'], as_of='2023-06-30')
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"dataset_id": "<dataset_id>"
},
"name": "query_dataset"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | No | ||
| as_of | No | ||
| limit | No | ||
| start | No | ||
| cursor | No | ||
| tickers | No | ||
| dataset_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | ||
| hint | No | ||
| meta | No | ||
| error | No | ||
| status | No | ||
| blocked | No | ||
| license | No | ||
| message | No | ||
| coverage | No | ||
| freshness | No | ||
| provenance | No | ||
| attribution | No | ||
| not_investment_advice | No |