Building an AI agent? Start with /llms.txt for the full site index.
Capital Flows
Market-wide total margin-purchase and short-sale balances per trading day from the official TWSE margin trading report.
GET /v2/datasets/total-margin-shorttotal-margin-short returns one market-wide row per trading day with the total margin-purchase and short-sale balances across all listed stocks, sourced from the official TWSE margin trading report. Each row carries its source role so the totals are traceable. This endpoint is a preview surface — coverage is currently partial and served as a snapshot rather than a fully backfilled history.
| Field | Type | Description |
|---|---|---|
date | string | Trading date. |
total_margin_balance | number | Market-wide margin-purchase balance (TWD thousands). |
total_short_balance | number | Market-wide short-sale balance (shares thousands). |
margin_change | number | Day-over-day change in total margin balance (TWD thousands). |
source_role | string | Canonical source role (official_twse_margin_total). |
| Rows | 9,936 |
| Window | 2000-11-28 – 2026-07-09 |
| Grade | Reference |
A real response from this endpoint. Rows are returned under "rows", 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": "total_margin_short", "dataset_id": "total_margin_short", "rows": [ { "market": "TWSE", "trade_date": "2026-07-09", "margin_purchase_balance_total": 9614955, "short_sale_balance_total": 203714, "margin_purchase_buy_total": 372813, "margin_purchase_sell_total": 342105, "short_sale_buy_total": 24248, "short_sale_sell_total": 24111, "margin_purchase_amount_total": null, "currency": "TWD", "market_scope": "TWSE", "source_provider": "derived_twmd", "source_role": "derived_market_total_from_margin_short_enhanced", "source_lineage": { "derivation": "sum per-ticker margin_short_enhanced by (market,trade_date)", "verified_vs": "total_margin_short_daily_items official overlap 100%" }, "data_gaps": [ "<Chinese value - see the zh page>" ], "not_investment_advice": true }, { "market": "TWSE", "trade_date": "2026-07-08", "margin_purchase_balance_total": 9590605, "short_sale_balance_total": 205830, "margin_purchase_buy_total": 406961, "margin_purchase_sell_total": 340331, "short_sale_buy_total": 29930, "short_sale_sell_total": 25013, "margin_purchase_amount_total": null, "currency": "TWD", "market_scope": "TWSE", "source_provider": "derived_twmd", "source_role": "derived_market_total_from_margin_short_enhanced", "source_lineage": { "derivation": "sum per-ticker margin_short_enhanced by (market,trade_date)", "verified_vs": "total_margin_short_daily_items official overlap 100%" }, "data_gaps": [ "<Chinese value - see the zh page>" ], "not_investment_advice": true } ], "count": 50, "plan_id": "enterprise", "meta": { "plan": "enterprise", "row_limit": 100000, "market": "TWSE", "start_date": null, "end_date": "2026-07-20", "private_beta_contract": true, "twse_only_scope": true, "is_limited": false }}Captured from the live API on 2026-07-20.
Chinese data values are shown as a marker here so this page stays in English; the /zh page shows them verbatim.
curl "https://api.twmarketdata.com/v2/datasets/total-margin-short?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/total-margin-short", params={"symbol": "2330"}, headers={"X-API-Key": "sk_live_..."},)resp.raise_for_status()print(resp.json()["rows"])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/total-margin-short", params={"symbol": "2330"}, headers={"X-API-Key": "sk_live_..."},)resp.raise_for_status()for row in resp.json()["rows"]: print(row)This endpoint is GET /v2/datasets/total-margin-short. The full machine-readable schema (parameters, security, response envelope) lives in the OpenAPI spec.