Building an AI agent? Start with /llms.txt for the full site index.
Capital Flows
Margin and short balances with utilization and day-over-day change pre-computed on top of the official TWSE margin trading figures.
GET /v2/datasets/margin-short-enhancedmargin-short-enhanced is a derived dataset: it starts from the official TWSE margin-purchase and short-sale balances and adds the utilization ratios and day-over-day changes an agent would otherwise compute itself. The lineage block points back to the underlying margin report so the base balances stay auditable.
| Field | Type | Description |
|---|---|---|
symbol | string | Ticker. |
date | string | Trading date. |
margin_balance | number | Margin-purchase balance (shares). |
margin_utilization | number | Margin balance as a ratio of its quota (0-1). |
margin_change | number | Day-over-day change in margin balance (shares). |
short_margin_ratio | number | Short balance as a ratio of margin balance. |
source_role | string | Canonical source role (derived_twse_margin_enhanced). |
| Rows | 7,798,493 |
| Window | 2000-11-28 – 2026-07-09 |
| Grade | Derived |
A real response from this endpoint. Rows are returned under "envelope.data", and provenance is carried in the shape shown below — it is not identical across datasets, so read this page's rather than assuming another's.
{ "api_version": "v2", "endpoint": "/v2/datasets/margin-short-enhanced", "request_id": "req_36b76b1d40b7", "plan_id": "enterprise", "dataset": "margin_short", "query": { "ticker": "2330", "date_from": null, "date_to": null, "limit": 50, "offset": 0, "sort_by": "trade_date", "sort_order": "desc" }, "meta": { "rows_returned": 50, "mandatory_contract_fields_present": [ "api_version", "data", "data_as_of" ], "plan": "enterprise", "row_limit": 100000, "is_limited": false }, "envelope": { "api_version": "v2", "dataset": "margin_short", "dataset_version": "v2.0.0-preview", "release_version": "v2.2026-07-09.preview", "release_date": "2026-07-09", "data_as_of": "2026-07-09", "request_context": { "ticker": "2330", "as_of_date": "2026-07-09", "family": "chip_deep", "field_group_type": "derived", "dataset_view": "margin_short_enhanced_v1", "supported_sort_by": [ "trade_date" ], "supported_filter_fields": [ "ticker", "date_from", "date_to" ] }, "data": [ { "ticker": "2330", "market": "TWSE", "trade_date": "2026-07-09", "margin_balance": 33061, "short_balance": 71, "margin_balance_change": 778, "short_balance_change": -14, "margin_usage_ratio": 0.997857, "short_usage_ratio": 0.002143, "margin_buy": 1064, "margin_sell": 272, "short_sell": 14, "short_cover": 0, "securities_lending_balance": null, "securities_lending_change": null, "provider": "twse_official", "source_role": "official_twse_mi_margn", "lineage": { "feeds": [ "margin_trading_daily", "short_selling_daily" ], "merged_from": "margin_short_daily", "transformation_version": "margin_short_deep_merge_v1" }, "data_gaps": [], "updated_at": "2026-07-14T14:03:17.715986" }, { "ticker": "2330", "market": "TWSE", "trade_date": "2026-07-08", "margin_balance": 32283, "short_balance": 85, "margin_balance_change": -259, "short_balance_change": -4, "margin_usage_ratio": 0.997374, "short_usage_ratio": 0.002626, "margin_buy": 807, "margin_sell": 829, "short_sell": 8, "short_cover": 4, "securities_lending_balance": null, "securities_lending_change": null, "provider": "twse_official", "source_role": "official_twse_mi_margn", "lineage": { "feeds": [ "margin_trading_daily", "short_selling_daily" ], "merged_from": "margin_short_daily", "transformation_version": "margin_short_deep_merge_v1" }, "data_gaps": [], "updated_at": "2026-07-14T14:03:17.715986" } ], "quality": { "freshness_state": "fresh", "freshness_as_of": "2026-07-09", "completeness_ratio": 1, "quality_status": "ready" }, "lineage": { "source_role": "canonical", "selected_source": "twse_official", "fallback_chain": [ "tpex_official", "data_gov_mirror" ], "policy_notes": [ "official/public-first canonical", "margin_short enhanced product rows derived from chip_deep margin/short/lending canonical payloads", "unstable fields excluded from public contract (scores/signals/custom factors)" ] }, "error": { "error_code": null, "error_message": null, "dataset": "margin_short", "request_id": "read-api-d78cfcbeec22", "blocking_gate": null } }}Captured from the live API on 2026-07-20.
curl "https://api.twmarketdata.com/v2/datasets/margin-short-enhanced?symbol=2330" \ -H "X-API-Key: sk_live_..."| Parameter | Required | Type | Description |
|---|---|---|---|
symbol | Yes | string | Ticker, e.g. 2330. |
start_date | No | string (YYYY-MM-DD) | Start of the query range. |
end_date | No | string (YYYY-MM-DD) | End of the query range. |
limit | No | integer | Maximum rows to return. |
A first call:
import requests resp = requests.get( "https://api.twmarketdata.com/v2/datasets/margin-short-enhanced", params={"symbol": "2330"}, headers={"X-API-Key": "sk_live_..."},)resp.raise_for_status()print(resp.json()["envelope"]["data"])With a date-range filter:
import requests # The full verified example — the same call with every supported filter set.resp = requests.get( "https://api.twmarketdata.com/v2/datasets/margin-short-enhanced", params={"symbol": "2330"}, headers={"X-API-Key": "sk_live_..."},)resp.raise_for_status()for row in resp.json()["envelope"]["data"]: print(row)This endpoint is GET /v2/datasets/margin-short-enhanced. The full machine-readable schema (parameters, security, response envelope) lives in the OpenAPI spec.