Building an AI agent? Start with /llms.txt for the full site index.
Capital Flows
Market-level daily margin/short-sale system stats: total margin-purchase balance, total short-sale balance, short-to-margin ratio, net flows, and turnover intensity. Derived from the total margin/short family. Not a forecast, not a recommendation.
GET /v2/datasets/margin-system-statsThis dataset is in build and not yet queryable via the API. The coverage and honest limitations below are the real database state; it moves off "Building" once serving lands (targeted 8/1).
| Field | Type | Description |
|---|---|---|
margin_purchase_balance_total | TWD | |
short_sale_balance_total | shares | |
short_to_margin_balance_ratio | ratio | |
margin_net_flow | TWD | |
maintenance_ratio | ratio | NULL — not loaded (honest gap) |
9,936 rows, 2000-11-28..2026-07-09, per market. maintenance_ratio is NULL — the official system-wide is not loaded (maintenance_ratio_note flags this HONEST GAP). All other fields are computed from official balances.
A real response from this endpoint. Rows are returned under "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.
{ "dataset_id": "margin-system-stats", "row_count": 3, "data": [ { "market": "TWSE", "trade_date": "2026-07-09", "margin_purchase_balance_total": 9614955.0, "short_sale_balance_total": 203714.0, "short_to_margin_balance_ratio": 0.021187, "margin_net_flow": 30708.0, "maintenance_ratio": null }, { "market": "TWSE", "trade_date": "2026-07-08", "margin_purchase_balance_total": 9590605.0, "short_sale_balance_total": 205830.0, "short_to_margin_balance_ratio": 0.021462, "margin_net_flow": 66630.0, "maintenance_ratio": null }, { "market": "TWSE", "trade_date": "2026-07-07", "margin_purchase_balance_total": 9531735.0, "short_sale_balance_total": 213844.0, "short_to_margin_balance_ratio": 0.022435, "margin_net_flow": -122958.0, "maintenance_ratio": null } ]}Captured from the live API on 2026-07-20.
curl "https://api.twmarketdata.com/v2/datasets/margin-system-stats?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-system-stats", params={"symbol": "2330"}, headers={"X-API-Key": "sk_live_..."},)resp.raise_for_status()print(resp.json()["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-system-stats", params={"symbol": "2330"}, headers={"X-API-Key": "sk_live_..."},)resp.raise_for_status()for row in resp.json()["data"]: print(row)This endpoint is GET /v2/datasets/margin-system-stats. The full machine-readable schema (parameters, security, response envelope) lives in the OpenAPI spec.