krx — a service's fields
Show the columns one KRX service returns, by the readable group name pair the Python
client uses. krx fields <group> <method> prints the field (column) names in the order
KRX returns them -- krx fields index kospi gives BAS_DD, IDX_CLSS, IDX_NM,
CLSPRC_IDX, ... It reads a schema bundled in the krx-openapi package, so it runs
offline and needs no API key.
Prerequisite
This plugin calls the krx CLI, so the package must be installed:
pipx install krx-openapi # or: pip install krx-openapi
That puts the krx command on PATH. krx fields needs no KRX_API_KEY (it is
offline) -- only the fetch skill does.
Running
krx fields <GROUP> <NAME> # the field (column) names that service returns
GROUP NAMEis the readable service pair --index kospi,stock daily,bond treasury, ... If you don't have it, use the list skill (krx list) first.--jsonemits JSON instead of the text view.
Procedure
- Have the
group name. If the user gave only a concept, use the list skill (krx list) to find the pair first. - Run.
krx fields index kospi - Relay the result. Show the CLI's stdout -- the column names the fetched rows will
carry. Offer to hand the same
group nameto the fetch skill for the data. - Error handling. An unknown method exits 2 with
krx: unknown service ...-- relay it and suggestkrx list <group>to find the right name.
What this skill does not do
- It does not re-implement the schema (the package ships it); it always calls the CLI.
- It shows column names only -- to list groups and methods use the list skill, and to fetch a day's data use the fetch skill.