Taiwan Stock Data
Use this skill to help users discover, fetch, validate, and analyze Taiwan market datasets exposed by the tw-stock CLI.
The CLI is the source of truth. Prefer calling tw-stock or uv run tw-stock instead of reimplementing crawler logic in the agent.
The current CLI normalizes common output columns to English snake_case. Before writing analysis code that depends on exact columns, inspect tw-stock describe <dataset> --json, tw-stock fetch <dataset> --schema-only --format json, or references/datasets.md.
Dependency
This skill does not bundle the market data crawler itself. It expects the tw-stock CLI from the tw-stock-cli project to be available.
Use commands in this order:
- If
tw-stock is installed in the current environment, call tw-stock ....
- If working inside a checkout of the
tw-stock-cli project, call uv run tw-stock ... from that repository root, or use uv run --project /path/to/tw-stock-cli tw-stock ... when running from another directory.
- If neither command is available, tell the user that the skill can identify the right dataset and command, but fetching requires installing or opening the
tw-stock-cli project.
First steps
If the user is asking what data exists, run:
tw-stock list-datasets --json
If the user mentions a specific topic but not a dataset ID, inspect the dataset catalog and map their request to the closest dataset.
Before fetching a large dataset, describe it or sample it:
tw-stock describe taifex.futures-tick --json
tw-stock fetch taifex.futures-tick --date 2026-04-30 --limit 5 --format json
For analysis workflows, prefer jsonl for AI/tool pipelines and csv for user-facing files:
tw-stock fetch twse.stock-price --date 2026-04-30 --format jsonl
tw-stock fetch twse.stock-price --date 2026-04-30 --format csv --output data.csv
Use metadata-only flags before fetching when the user needs schema or source context:
tw-stock fetch twse.stock-price --schema-only --format json
tw-stock fetch twse.stock-price --source-url-only --format json
Dataset selection
Use these common mappings:
- Stock price / open-high-low-close:
twse.stock-price, tpex.stock-price
- Stock list / security codes:
twse.stock-list, tpex.stock-list
- PER / dividend yield / PBR:
twse.stock-per, tpex.stock-per
- Institutional investor buy/sell:
twse.institutional-trade, tpex.institutional-trade
- Margin purchase / short sale:
twse.margin-trade, tpex.margin-trade
- Foreign holdings:
twse.foreign-holding, tpex.foreign-holding
- Total return indices:
twse.total-return-index, tpex.total-return-index
- Futures and options market data:
taifex.*
- Monthly revenue and financial statements:
mops.month-revenue, mops.company-*, mops.income-statement, mops.balance-sheet, mops.cash-flow
- MOPS PDF/electronic-book download indexes:
mops.financial-report-electronic-book, mops.annual-report-electronic-book, mops.related-company-reports, mops.sustainability-report, mops.major-shareholder-relationship
- MOPS governance, ESG, insiders, related-party, and corporate actions: inspect references/datasets.md and prefer the exact
mops.* dataset before scraping MOPS manually.
For the complete list, read references/datasets.md.
Column expectations
Use normalized column names from the current CLI:
- Price columns are
open, high, low, close; do not assume old names such as max or min.
- Valuation columns are
per and pbr; do not assume old uppercase names such as PER or PBR.
- Security identifiers are
stock_id and stock_name.
- TAIFEX FCM outputs use
fcm_id, fcm_name, subtotal, total, market_share, product columns such as mtx, and total product columns such as total_mtx.
- MOPS statement line items may remain in Chinese, but shared identifier columns are normalized to
stock_id and stock_name.
Safety and data quality
Taiwan exchange endpoints can change format. If the user needs reliable output, validate first:
tw-stock validate twse.stock-price --date 2026-04-30 --json
If validation fails, report the dataset ID, date/parameters, error code, and source URL. Do not silently substitute another data source unless the user asks for that.
For non-trading days, expect empty data or exchange messages. Ask for a nearby trading day only if the user's date is ambiguous.
Large datasets
Tick data can return hundreds of thousands of rows. Always use --limit when exploring:
tw-stock fetch taifex.options-tick --date 2026-04-30 --limit 20 --format jsonl
Only fetch full tick datasets when the user clearly needs full raw data or provides an output path.
Reference files
- references/datasets.md: dataset IDs, parameters, and examples.
- references/cli-usage.md: command patterns and output formats.
- references/data-caveats.md: known source quirks and edge cases.
1---2name: tw-stock-data3description: Fetch, validate, and analyze Taiwan stock, OTC, futures, options, and MOPS financial datasets using the tw-stock CLI. Use whenever the user asks for TWSE, TPEX, TAIFEX, MOPS, 台股, 上市櫃, 期貨, 選擇權, 法人買賣超, 融資融券, 外資持股, 股價, 月營收, 財報, or Taiwan market data, even if they do not mention the CLI.4---56# Taiwan Stock Data78Use this skill to help users discover, fetch, validate, and analyze Taiwan market datasets exposed by the `tw-stock` CLI.910The CLI is the source of truth. Prefer calling `tw-stock` or `uv run tw-stock` instead of reimplementing crawler logic in the agent.1112The current CLI normalizes common output columns to English `snake_case`. Before writing analysis code that depends on exact columns, inspect `tw-stock describe <dataset> --json`, `tw-stock fetch <dataset> --schema-only --format json`, or [references/datasets.md](references/datasets.md).1314## Dependency1516This skill does not bundle the market data crawler itself. It expects the `tw-stock` CLI from the `tw-stock-cli` project to be available.1718Use commands in this order:19201. If `tw-stock` is installed in the current environment, call `tw-stock ...`.212. If working inside a checkout of the `tw-stock-cli` project, call `uv run tw-stock ...` from that repository root, or use `uv run --project /path/to/tw-stock-cli tw-stock ...` when running from another directory.223. If neither command is available, tell the user that the skill can identify the right dataset and command, but fetching requires installing or opening the `tw-stock-cli` project.2324## First steps25261. If the user is asking what data exists, run:2728 ```bash29 tw-stock list-datasets --json30 ```31322. If the user mentions a specific topic but not a dataset ID, inspect [the dataset catalog](references/datasets.md) and map their request to the closest dataset.33343. Before fetching a large dataset, describe it or sample it:3536 ```bash37 tw-stock describe taifex.futures-tick --json38 tw-stock fetch taifex.futures-tick --date 2026-04-30 --limit 5 --format json39 ```40414. For analysis workflows, prefer `jsonl` for AI/tool pipelines and `csv` for user-facing files:4243 ```bash44 tw-stock fetch twse.stock-price --date 2026-04-30 --format jsonl45 tw-stock fetch twse.stock-price --date 2026-04-30 --format csv --output data.csv46 ```47485. Use metadata-only flags before fetching when the user needs schema or source context:4950 ```bash51 tw-stock fetch twse.stock-price --schema-only --format json52 tw-stock fetch twse.stock-price --source-url-only --format json53 ```5455## Dataset selection5657Use these common mappings:5859- Stock price / open-high-low-close: `twse.stock-price`, `tpex.stock-price`60- Stock list / security codes: `twse.stock-list`, `tpex.stock-list`61- PER / dividend yield / PBR: `twse.stock-per`, `tpex.stock-per`62- Institutional investor buy/sell: `twse.institutional-trade`, `tpex.institutional-trade`63- Margin purchase / short sale: `twse.margin-trade`, `tpex.margin-trade`64- Foreign holdings: `twse.foreign-holding`, `tpex.foreign-holding`65- Total return indices: `twse.total-return-index`, `tpex.total-return-index`66- Futures and options market data: `taifex.*`67- Monthly revenue and financial statements: `mops.month-revenue`, `mops.company-*`, `mops.income-statement`, `mops.balance-sheet`, `mops.cash-flow`68- MOPS PDF/electronic-book download indexes: `mops.financial-report-electronic-book`, `mops.annual-report-electronic-book`, `mops.related-company-reports`, `mops.sustainability-report`, `mops.major-shareholder-relationship`69- MOPS governance, ESG, insiders, related-party, and corporate actions: inspect [references/datasets.md](references/datasets.md) and prefer the exact `mops.*` dataset before scraping MOPS manually.7071For the complete list, read [references/datasets.md](references/datasets.md).7273## Column expectations7475Use normalized column names from the current CLI:7677- Price columns are `open`, `high`, `low`, `close`; do not assume old names such as `max` or `min`.78- Valuation columns are `per` and `pbr`; do not assume old uppercase names such as `PER` or `PBR`.79- Security identifiers are `stock_id` and `stock_name`.80- TAIFEX FCM outputs use `fcm_id`, `fcm_name`, `subtotal`, `total`, `market_share`, product columns such as `mtx`, and total product columns such as `total_mtx`.81- MOPS statement line items may remain in Chinese, but shared identifier columns are normalized to `stock_id` and `stock_name`.8283## Safety and data quality8485Taiwan exchange endpoints can change format. If the user needs reliable output, validate first:8687```bash88tw-stock validate twse.stock-price --date 2026-04-30 --json89```9091If validation fails, report the dataset ID, date/parameters, error code, and source URL. Do not silently substitute another data source unless the user asks for that.9293For non-trading days, expect empty data or exchange messages. Ask for a nearby trading day only if the user's date is ambiguous.9495## Large datasets9697Tick data can return hundreds of thousands of rows. Always use `--limit` when exploring:9899```bash100tw-stock fetch taifex.options-tick --date 2026-04-30 --limit 20 --format jsonl101```102103Only fetch full tick datasets when the user clearly needs full raw data or provides an output path.104105## Reference files106107- [references/datasets.md](references/datasets.md): dataset IDs, parameters, and examples.108- [references/cli-usage.md](references/cli-usage.md): command patterns and output formats.109- [references/data-caveats.md](references/data-caveats.md): known source quirks and edge cases.