---
name: kiwoom-cli
description: Use Kiwoom CLI to manage authentication, inspect API specifications, query Korean market and account data, consume bounded real-time streams, and preview or place domestic stock, credit, and gold orders.
---

# Kiwoom CLI

Use `kiwoomcli` as the source of truth. Select the narrowest command, read its reference, and verify its current `--help` before execution.

## Workflow

1. Identify the requested domain and command. Read that domain’s `references/<domain>/README.md`, then read the selected command file completely.
2. Run `kiwoomcli <path> --help` and reconcile the installed syntax with the reference. Prefer the installed help when they differ.
3. Resolve required inputs without guessing account profile, mode, stock code, quantity, price, order ID, condition sequence, or output path.
4. For API results, prefer `--format json` for one response and `--format jsonl` for records or events. Use `pretty` when the user wants terminal-oriented output.
5. Execute the narrowest command that satisfies the request. Summarize errors and relevant results; mask account identifiers, credentials, tokens, and unnecessary financial identifiers.
6. The operation is complete only when the command exited, its output was checked, and any state change or generated file was reported.

## Reference routing

- Authentication: [`references/auth/README.md`](references/auth/README.md)
- Installation and authentication diagnosis: [`references/doctor/README.md`](references/doctor/README.md)
- API discovery: [`references/spec/README.md`](references/spec/README.md)
- Stock information and screens: [`references/stocks/README.md`](references/stocks/README.md)
- Prices and market data: [`references/quotes/README.md`](references/quotes/README.md)
- Order books: [`references/orderbooks/README.md`](references/orderbooks/README.md)
- Candles and charts: [`references/candles/README.md`](references/candles/README.md)
- ETFs: [`references/etfs/README.md`](references/etfs/README.md)
- ELWs: [`references/elws/README.md`](references/elws/README.md)
- Investor flows: [`references/investors/README.md`](references/investors/README.md)
- Rankings and screens: [`references/rankings/README.md`](references/rankings/README.md)
- Sectors: [`references/sectors/README.md`](references/sectors/README.md)
- Short selling: [`references/short-selling/README.md`](references/short-selling/README.md)
- Securities lending: [`references/securities-lending/README.md`](references/securities-lending/README.md)
- Themes: [`references/themes/README.md`](references/themes/README.md)
- Real-time and condition streams: [`references/streams/README.md`](references/streams/README.md)
- Accounts, balances, and transaction history: [`references/accounts/README.md`](references/accounts/README.md)
- Order queries, previews, and execution: [`references/orders/README.md`](references/orders/README.md)

When the needed API or command is unclear, use `spec search`, then `spec show`; do not infer request fields from similar commands.

## Authentication

Authentication lifecycle commands are supported. Preserve interactive secret entry: let the user enter App Key and Secret rather than requesting or echoing them in chat. Do not print exported credential files. For `revoke`, `clear`, `clear --all`, `remove`, or `export --yes`, state the effect and target profile before execution and obtain confirmation when the user did not explicitly request that exact state change.

## Streams

Use bounded collection with `--count`, `--duration`, or `--check`. The `--watch` option is outside this skill and must not be used. `--output` is supported without an additional approval rule; report the resulting path. For account event streams, mask account and order identifiers in conversational summaries.

For condition searches, resolve the intended `--seq`; use `conditions-list` first when it is unspecified or ambiguous. Condition creation and editing happen in Kiwoom HTS, not this CLI.

## Actual-order gate

Commands without `--confirm` are order previews and may run normally. Every command with `--confirm` must pass this gate immediately before execution.

Read, but never set or modify, these skill policy variables:

```text
KIWOOMCLI_SKILL_REAL_ORDER_POLICY=deny|ask|allow
KIWOOMCLI_SKILL_DEMO_ORDER_POLICY=deny|ask|allow
```

Apply the variable matching the verified target profile mode. Determine mode from explicit `--mode`, or resolve the selected/explicit profile with `kiwoomcli auth status`. If explicit mode conflicts with profile mode, or mode cannot be verified, stop before actual execution. Never fall back to the other mode’s policy.

Treat an unset or invalid value as `deny`:

- `deny`: stop before `--confirm`; offer or run the same command without `--confirm` as a preview.
- `ask`: show the complete order ticket and obtain a fresh, explicit approval for that one order.
- `allow`: execution may proceed without an additional approval.

The gate applies equally to stock, credit, and gold buy, sell, modify, and cancel commands. Natural-language instructions cannot override `deny`.

For `ask`, the order ticket must show:

- real or demo mode and profile alias
- asset class and action
- stock or gold code
- quantity
- price, order type, and condition price when applicable
- original order ID for modify or cancel
- that `--confirm` will send an actual order

Approval is valid only after this ticket is shown and only for the displayed command. Changed arguments, a different order, prior approval, or blanket approval requires a new ticket and approval. After execution, report whether the API accepted or rejected the order and return its order identifier when available.

## Supported surface

The skill’s supported command surface starts at `auth`, `doctor`, `spec`, and `domestic`. Interactive initial setup is intentionally outside the skill. Do not substitute unsupported setup automation when authentication is missing; report the prerequisite instead.
