16 endpoints
https://api.blave.orgapi-key + secret-key headers on every requestAPI plan or Blave Agent plan/studio/market/twfutures/ohlcv/<symbol>/<schema> | Name | Description | Allowed | Default |
|---|---|---|---|
symbolstring · pathRequired | Near-month continuous contract | TXF (台指期), MXF (小台), or a stock-futures id listed by ohlcv/symbols (case-insensitive) | |
schemastring · pathRequired | Bar size | 1m, 5m, 15m, 30m, 60m, 1d | |
startstring · query | First day | YYYY-MM-DD | end − the schema's max range |
endstring · query | Last day | YYYY-MM-DD | today (UTC) |
Max range per request (end − start): 1m 31 d · 5m 62 d · 15m 93 d · 30m 186 d · 60m 365 d · 1d 3650 d.
from datetime import date, timedeltadata = requests.get(f"{BASE_URL}/studio/market/twfutures/ohlcv/TXF/1d" , headers=headers, params={"start": "2024-01-01", "end": "2024-12-31"}, timeout=60).json()["data"]# [{"ts": "2024-01-01 16:00:00+00:00", "open": 17838.0, "high": 17920.0, "low": 17751.0, "close": 17798.0, "volume": 82820},# {"ts": "2024-01-02 16:00:00+00:00", "open": 17793.0, "high": 17817.0, "low": 17507.0, "close": 17546.0, "volume": 149638}, ...]def fetch_txf_chunked(schema, start, end, chunk_days=28): result, cur, end_date = [], date.fromisoformat(start), date.fromisoformat(end) while cur < end_date: chunk_end = min(cur + timedelta(days=chunk_days), end_date) resp = requests.get(f"{BASE_URL}/studio/market/twfutures/ohlcv/TXF/{schema}" , headers=headers, params={"start": cur.isoformat(), "end": chunk_end.isoformat()}, timeout=60) result.extend(resp.json().get("data", [])) cur = chunk_end return result{"symbol", "schema", "data": [...]}.
| Field | Type | Unit | Description |
|---|---|---|---|
ts | string | UTC ISO | Bar open time |
open / high / low / close | float | index points (price for stock futures) | Prices |
volume | int | contracts (口) | Volume |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid symbol. Allowed: [...]"} | Symbol not covered |
| 400 | {"error": "Invalid schema. Allowed: [...]"} | Bad schema |
| 400 | {"error": "Invalid date format. Use YYYY-MM-DD"} | Malformed date |
| 400 | {"error": "date_range_too_large", "message": "...", "max_days": <n>} | Range over the cap |
| 503 | error message | Data source temporarily unavailable |
TXF, MXF, and stock futures alike): monthly settlement day — the 3rd Wednesday, or the next trading day when that Wednesday is closed — is the expiring month for the whole day. It trades through its 13:30 Taipei close, no bar is stamped 13:31–14:59 Taipei on that day, and the series is the next month from the 15:00 night session on. The settlement day's 1d bar is the expiring month's, so its close is that contract's last trade at 13:30.ohlcv/<symbol>/export/<year> instead of chunked JSON.200 with [].MXF and CAF asked for everything up to the request date both came back with a last bar months old. Read data[-1]["ts"].1d bars carry a 16:00:00+00:00 time component (00:00 Taipei), not midnight UTC — take the date from ts rather than assuming the timestamp is date-aligned.1d and intraday; MXF's is for 1d. Stock futures start per contract — CAF has 1d bars at least as early as 2016-09-18./studio/market/twfutures/ohlcv/symbols None.
symbols = requests.get(f"{BASE_URL}/studio/market/twfutures/ohlcv/symbols" , headers=headers, timeout=30).json()["data"]{"data": ["CDF", "DHF", "MXF", "TXF", ...]} — symbols accepted by ohlcv, ohlcv/export, and bid_ask_vol: TXF, MXF, plus the stock futures with minute-line coverage. Coverage changes over time — check a contract's minute_line_enabled in stock_futures/list rather than assuming a count.
Shared errors only.
/studio/market/twfutures/ohlcv/<symbol>/export/<year> | Name | Description | Allowed | Default |
|---|---|---|---|
symbolstring · pathRequired | Symbol | As ohlcv/symbols | |
yearint · pathRequired | Calendar year | 2014 – current year |
import ioimport pandas as pdr = requests.get(f"{BASE_URL}/studio/market/twfutures/ohlcv/TXF/export/2024" , headers=headers, timeout=120)raw = pd.read_parquet(io.BytesIO(r.content))raw.index = pd.to_datetime(raw["ts"], utc=True)bars_60m = (raw[["open", "high", "low", "close", "volume"]] .resample("60min") .agg(open=("open", "first"), high=("high", "max"), low=("low", "min"), close=("close", "last"), volume=("volume", "sum")) .dropna(subset=["open"]))application/octet-stream, a parquet file (<SYMBOL>_<year>_1m.parquet) with columns ts, open, high, low, close, volume (1m bars).
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid symbol. Allowed: [...]"} | Symbol not covered |
| 400 | {"error": "Invalid year. Allowed: 2014-<current>"} | Year out of range |
| 404 | {"error": "no_data", "message": "No 1m data on disk for <symbol> in <year>"} | No file |
ohlcv/<symbol>/1m, under the same settlement-day roll rule (no bars stamped 13:31–14:59 Taipei on monthly settlement day)./studio/market/twfutures/bid_ask_vol/<symbol> | Name | Description | Allowed | Default |
|---|---|---|---|
symbolstring · pathRequired | Symbol | TXF, MXF (both verified to return data); other ohlcv/symbols ids untested | |
startstring · query | First day | YYYY-MM-DD | end − 31 days |
endstring · query | Last day; end − start ≤ 31 days | YYYY-MM-DD | today (UTC) |
data = requests.get(f"{BASE_URL}/studio/market/twfutures/bid_ask_vol/TXF" , headers=headers, params={"start": "2026-05-29", "end": "2026-05-29"}, timeout=60).json()["data"]# [{"ts": "2026-05-29 00:45:00+00:00", "bid_vol": 669, "ask_vol": 447, "total_vol": 1156}, ...]{"symbol", "start", "end", "data": [...]}, 1-minute rows, day and night sessions.
| Field | Type | Unit | Description |
|---|---|---|---|
ts | string | UTC ISO | Bar open time |
bid_vol | int | contracts | 內盤 — trades hitting the bid (seller-initiated) |
ask_vol | int | contracts | 外盤 — trades lifting the ask (buyer-initiated) |
total_vol | int | contracts | Total, including unclassified ticks |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid symbol. Allowed: [...]"} | Symbol not covered |
| 400 | {"error": "Invalid date format. Use YYYY-MM-DD"} | Malformed date |
| 400 | {"error": "date_range_too_large", "message": "...", "max_days": 31} | Range over 31 days |
| 503 | error message | Data source temporarily unavailable |
ohlcv: on monthly settlement day there are no rows between the expiring month's 13:30 Taipei close and the 15:00 night open; from the night session on the rows are the next month./studio/market/twfutures/daily/<futures_id> | Name | Description | Allowed | Default |
|---|---|---|---|
futures_idstring · pathRequired | Product | 2–6 letters, case-insensitive — e.g. TX, MTX, TMF, TE, TF, or a stock-futures id (e.g. CDF) | |
startstring · query | First date | YYYY-MM-DD | 1998-07-01 |
endstring · query | Last date | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twfutures/daily/TX" , headers=headers, params={"start": "2026-08-01"}, timeout=60).json()["data"]{"futures_id", "data": [...]}; several rows per day (every contract month × trading session).
| Field | Description |
|---|---|
date, futures_id | Day, product |
contract_date | Contract month (spread contracts contain /) |
open / max / min / close | Prices (max = high, min = low) |
spread / spread_per | Change / change % |
volume | Contracts |
settlement_price | Settlement price |
open_interest | Open interest |
trading_session | position (regular) or after_market (night) |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid futures_id"} | Format check failed |
| 404 | {"error": "No data found for futures_id: <id>"} | No data |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
TX / MTX / TMF comes from the official TAIFEX publication.TX is the earliest product; others start later (CDF is a stock future)./studio/market/twfutures/stock_futures/list None.
rows = requests.get(f"{BASE_URL}/studio/market/twfutures/stock_futures/list" , headers=headers, timeout=30).json()["data"]# Live capture 2026-11-06 (abridged with ...):# [{"futures_id": "CAF", "code": "CA", "stock_id": "1303", "stock_name": "南亞",# "stock_full_name": "南亞塑膠工業股份有限公司", "unit": 2000, "minute_line_enabled": true}, ...,# {"futures_id": "CDF", "code": "CD", "stock_id": "2330", "stock_name": "台積電",# "stock_full_name": "台灣積體電路製造股份有限公司", "unit": 2000, "minute_line_enabled": true}, ...,# {"futures_id": "QFF", "code": "QF", "stock_id": "2330", "stock_name": "台積電",# "stock_full_name": "台灣積體電路製造股份有限公司", "unit": 100, "minute_line_enabled": true}, ... 240 rows]by_stock = {}for r in rows: # one stock can have a standard and a mini contract by_stock.setdefault(r["stock_id"], []).append(r["futures_id"]){"data": [...]}, one row per contract, sorted by futures_id.
| Field | Type | Description |
|---|---|---|
futures_id | string | Contract id used by the other futures endpoints, e.g. CDF (= code + F) |
code | string | TAIFEX product code, e.g. CD |
stock_id | string | Underlying stock code, e.g. 2330 |
stock_name / stock_full_name | string | Underlying short / full name |
unit | int | Shares per contract (standard 2,000; mini 100) |
minute_line_enabled | bool | true when the contract has minute bars (ohlcv/<symbol>/<schema>, bid_ask_vol/<symbol>) |
| Status | Body | When |
|---|---|---|
| 503 | {"error": "Stock futures symbol list temporarily unavailable. Please retry shortly."} | Listing unavailable |
stock_id → futures_id is one-to-many: a stock can have a standard (2,000 shares) and a mini (100 shares) contract. Their lot counts are not comparable — the mini's notional per lot is 1/20.stock_futures/batch/daily accepts./studio/market/twfutures/stock_futures/liquidity_ranking None.
rows = requests.get(f"{BASE_URL}/studio/market/twfutures/stock_futures/liquidity_ranking" , headers=headers, timeout=120).json()["data"]# Live capture 2026-11-06 (abridged with ...):# [{"rank": 1, "futures_id": "CCF", "code": "CC", "stock_id": "2303", "stock_name": "聯電",# "stock_full_name": "聯華電子股份有限公司", "unit": 2000,# "avg_volume": 50357.3, "avg_open_interest": 75444.95, "minute_line_enabled": true},# {"rank": 2, "futures_id": "QFF", "code": "QF", "stock_id": "2330", "stock_name": "台積電",# "stock_full_name": "台灣積體電路製造股份有限公司", "unit": 100,# "avg_volume": 44525.55, "avg_open_interest": 109939.75, "minute_line_enabled": true}, ... 240 rows]standard = [r for r in rows if r["unit"] == 2000][:20] # compare lots within one unit only{"data": [...]}, every stock-futures contract that has daily data, sorted by avg_volume descending.
| Field | Type | Unit | Description |
|---|---|---|---|
rank | int | — | 1-based rank by avg_volume |
futures_id, code, stock_id, stock_name, stock_full_name, unit | — | — | Same as stock_futures/list |
avg_volume | float | contracts | Average daily volume over the last 20 trading days: regular session only, every contract month summed per day, spread contracts and after-hours excluded |
avg_open_interest | float | contracts | Average daily open interest over the same days, summed the same way |
minute_line_enabled | bool | — | Same as stock_futures/list |
| Status | Body | When |
|---|---|---|
| 503 | {"error": "Stock futures symbol list temporarily unavailable. Please retry shortly."} | Listing unavailable |
unit: a mini contract's lot is 1/20 of a standard one, so rank across units by notional (lots × unit × price) instead.stock_futures/list if you need every contract./studio/market/twfutures/stock_futures/batch/daily | Name | Description | Allowed | Default |
|---|---|---|---|
futures_idsstring · queryRequired | Ids | Comma-separated stock-futures ids, ≤ 250 | |
startstring · query | First date | YYYY-MM-DD | 1998-07-01 |
endstring · query | Last date | YYYY-MM-DD | today |
body = requests.get(f"{BASE_URL}/studio/market/twfutures/stock_futures/batch/daily" , headers=headers, params={"futures_ids": "CDF,DHF", "start": "2026-08-01"}, timeout=120).json(){"data": {"<futures_id>": [...rows as /daily...]}, "failed": [...]}. failed = ids whose fetch failed (retry); an id absent from both genuinely has no data.
| Status | Body | When |
|---|---|---|
| 400 | {"error": "futures_ids parameter required"} | Missing |
| 400 | {"error": "futures_ids exceeds max 250 per request"} | Too many |
| 400 | {"error": "Invalid stock futures_id(s): [...]"} | Any id is not a stock future |
| 503 | {"error": "Stock futures symbol list temporarily unavailable. Please retry shortly."} | Symbol list unavailable |
/studio/market/twfutures/institutional/<futures_id> | Name | Description | Allowed | Default |
|---|---|---|---|
futures_idstring · pathRequired | Product | Index futures — TX, MTX, TMF, TE, TF (all verified to return data); stock futures not supported | |
startstring · query | First date | YYYY-MM-DD | 2018-06-05 |
endstring · query | Last date | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twfutures/institutional/TX" , headers=headers, params={"start": "2026-08-01"}, timeout=60).json()["data"]{"futures_id", "data": [...]}, 3 rows per day (自營商 / 投信 / 外資).
| Field | Description |
|---|---|
date, futures_id | Day, product |
institutional_investors | Investor type |
long_deal_volume / long_deal_amount | Long trades (contracts / TWD thousand) |
short_deal_volume / short_deal_amount | Short trades |
long_open_interest_balance_volume / long_open_interest_balance_amount | Long OI |
short_open_interest_balance_volume / short_open_interest_balance_amount | Short OI |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid futures_id"} | Format check failed |
| 404 | {"error": "institutional data not available for stock futures (<id>)"} | Stock future |
| 404 | {"error": "No data found for futures_id: <id>"} | Product has no data at all. A range with no rows in it is 200 with "data": [] |
| 503 | upstream rate limit / symbol list unavailable | Retry later |
*_amount is TWD thousand — inferred from magnitude, not stated upstream, but the arithmetic backs it: a TX row with long_open_interest_balance_amount 722870036 over ..._volume 78292 is 9,233 per contract, and a TX contract is index × 200, so 9,233 thousand ÷ 200 ≈ 46,160 index points, which is where the index was trading that day. Read as TWD it would be 1,000× too small./studio/market/twfutures/large_traders/<futures_id> | Name | Description | Allowed | Default |
|---|---|---|---|
futures_idstring · pathRequired | Product | Index futures, e.g. TX; stock futures not supported | |
startstring · query | First date | YYYY-MM-DD | 1998-07-01 |
endstring · query | Last date | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twfutures/large_traders/TX" , headers=headers, params={"start": "2026-08-01"}, timeout=60).json()["data"]{"futures_id", "data": [...]}, 3 rows per day (contract_type: week / current month / all).
| Field | Description |
|---|---|
date, futures_id, name, contract_type | Day, product, product name, contract scope |
buy_top5_trader_open_interest / buy_top10_trader_open_interest (+ _per) | Long OI of top 5 / 10 traders (contracts, % of market) |
sell_top5_trader_open_interest / sell_top10_trader_open_interest (+ _per) | Short OI of top 5 / 10 traders |
buy_top5_specific_open_interest / buy_top10_specific_open_interest (+ _per) | Long OI of top 5 / 10 specific legal persons |
sell_top5_specific_open_interest / sell_top10_specific_open_interest (+ _per) | Short OI of top 5 / 10 specific legal persons |
market_open_interest | Total market OI |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid futures_id"} | Format check failed |
| 404 | {"error": "large_traders data not available for stock futures (<id>)"} | Stock future |
| 404 | {"error": "No data found for futures_id: <id>"} | Product has no data at all. A range with no rows in it is 200 with "data": [] |
| 503 | upstream rate limit / symbol list unavailable | Retry later |
/studio/market/twfutures/retail_long_short_ratio/<futures_id> | Name | Description | Allowed | Default |
|---|---|---|---|
futures_idstring · pathRequired | Product | Index futures, 2–6 letters, case-insensitive — TMF (微型臺指), MTX (小型臺指), TX (臺股期貨) | |
datestring · query | One trading day | YYYY-MM-DD | latest settled day |
row = requests.get(f"{BASE_URL}/studio/market/twfutures/retail_long_short_ratio/TMF" , headers=headers, timeout=60).json()# Live capture 2026-11-06:# {"date": "2026-11-06", "futures_id": "TMF", "market_open_interest": 96708,# "institutional_long_open_interest": 6870, "institutional_short_open_interest": 52454,# "retail_long_open_interest": 89838, "retail_short_open_interest": 44254,# "retail_long_short_ratio": 47.13570749059023}# Same day: MTX 17.37, TX 5.92 — each product has its own retail share, so never compare across them# For a series use /retail_long_short_ratio/<futures_id>/history (one call for a whole range)One object for one day (no data wrapper).
| Field | Type | Unit | Description |
|---|---|---|---|
date | string | — | Trading day |
futures_id | string | — | Product |
market_open_interest | int | contracts | Whole-market open interest: every contract month, regular session, spread contracts excluded |
institutional_long_open_interest | int | contracts | Long OI of the three institutional investors (自營商 + 投信 + 外資) |
institutional_short_open_interest | int | contracts | Short OI of the three institutional investors |
retail_long_open_interest | int | contracts | market_open_interest − institutional_long_open_interest |
retail_short_open_interest | int | contracts | market_open_interest − institutional_short_open_interest |
retail_long_short_ratio | float | % | (retail long − retail short) ÷ market_open_interest × 100. Positive = retail net long |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid futures_id"} | Format check failed |
| 400 | {"error": "Invalid date, expected YYYY-MM-DD"} | Malformed date |
| 404 | {"error": "No retail long/short ratio data for futures_id <id> on <date>"} | date is not a trading day, or not published yet |
| 404 | {"error": "No data found for futures_id: <id>"} (or a similar no-data message) | Product has no data (stock futures have no institutional data) |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
position) rows of daily/<futures_id> count toward market OI; the after-hours rows carry no OI, and calendar-spread contracts are excluded. The institutional side is the sum of the three rows of institutional/<futures_id> for the same day.TMF (微型臺指, index × 10 per contract) has the highest retail share of the three (its long side is almost all retail), MTX (小型臺指, index × 50) sits in between, and TX (臺股期貨, index × 200) is mostly institutional, so the residual there is small. On 2026-11-06 the ratio was 47.14 for TMF, 17.37 for MTX and 5.92 for TX. Track one product over time and compare it only with itself.TMF history starts 2024-07-29, its listing date./studio/market/twfutures/retail_long_short_ratio/<futures_id>/history | Name | Description | Allowed | Default |
|---|---|---|---|
futures_idstring · pathRequired | Product | Index futures, 2–6 letters, case-insensitive — TMF (微型臺指), MTX (小型臺指), TX (臺股期貨) | |
startstring · query | First date | YYYY-MM-DD | earliest available |
endstring · query | Last date | YYYY-MM-DD | today |
import pandas as pdresp = requests.get(f"{BASE_URL}/studio/market/twfutures/retail_long_short_ratio/TMF/history" , headers=headers, params={"start": "2026-10-27", "end": "2026-11-07"}, timeout=60).json()# Live capture 2026-11-09: 9 rows, 2026-10-27 .. 2026-11-06# {"futures_id": "TMF", "data": [..., {"date": "2026-11-06", "futures_id": "TMF",# "market_open_interest": 96708, "institutional_long_open_interest": 6870,# "institutional_short_open_interest": 52454, "retail_long_open_interest": 89838,# "retail_short_open_interest": 44254, "retail_long_short_ratio": 47.13570749059023}]}df = pd.DataFrame(resp["data"]).set_index("date"){"futures_id", "data": [...]}; one row per trading day, oldest first. Each row has the same fields as the single-day endpoint above (date, futures_id, market_open_interest, institutional_long_open_interest, institutional_short_open_interest, retail_long_open_interest, retail_short_open_interest, retail_long_short_ratio).
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid futures_id"} | Format check failed |
| 400 | {"error": "Invalid start date, expected YYYY-MM-DD"} (or end) | Malformed date |
| 400 | {"error": "start must not be after end"} | Reversed range |
| 404 | {"error": "No data found for futures_id: <id>"} | Product has no data at all |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
A range with no settled day in it (a weekend, or before the product's history) is 200 with "data": [], not an error.
TMF, MTX and TX with each other.start the whole history comes back (about 2,050 rows for TX, 2026-11)./studio/market/twfutures/option/institutional/<option_id> | Name | Description | Allowed | Default |
|---|---|---|---|
option_idstring · pathRequired | Option product | TXO (2–6 letters accepted) | |
startstring · query | First date | YYYY-MM-DD | 2018-06-05 |
endstring · query | Last date | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twfutures/option/institutional/TXO" , headers=headers, params={"start": "2026-08-01"}, timeout=60).json()["data"]{"option_id", "data": [...]}, 6 rows per day (3 investor types × call / put). Fields: date, option_id, call_put (買權 / 賣權), institutional_investors, and the same long_* / short_* deal and open-interest volume / amount fields as futures institutional.
400 {"error": "Invalid option_id"}; 404 {"error": "No data found for option_id: <id>"} when the product has no data at all (a range with no rows is 200 with "data": []); 503 upstream rate limit.
/studio/market/twfutures/option/large_traders/<option_id> | Name | Description | Allowed | Default |
|---|---|---|---|
option_idstring · pathRequired | Option product | TXO (2–6 letters accepted) | |
startstring · query | First date | YYYY-MM-DD | 1998-07-01 |
endstring · query | Last date | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twfutures/option/large_traders/TXO" , headers=headers, params={"start": "2026-08-01"}, timeout=60).json()["data"]{"option_id", "data": [...]}, 6 rows per day (call / put × week / current month / all). Fields: date, option_id, name, put_call, contract_type, and the same top-5 / top-10 trader and specific-legal-person open-interest fields as futures large traders, plus market_open_interest.
400 {"error": "Invalid option_id"}; 404 {"error": "No data found for option_id: <id>"} when the product has no data at all (a range with no rows is 200 with "data": []); 503 upstream rate limit.
/studio/market/twfutures/option/pcr | Name | Description | Allowed | Default |
|---|---|---|---|
startstring · query | First date | YYYY-MM-DD | 2001-12-24 |
endstring · query | Last date | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twfutures/option/pcr" , headers=headers, params={"start": "2024-01-01", "end": "2024-12-31"}, timeout=60).json()["data"]# [{"date": "2024-01-02", "put_volume": 309583, "call_volume": 404231, "volume_pcr": 76.59,# "put_oi": 263673, "call_oi": 246495, "oi_pcr": 106.97, "pcr": 106.97},# {"date": "2024-01-03", "put_volume": 622854, "call_volume": 729547, "volume_pcr": 85.38,# "put_oi": 177203, "call_oi": 178062, "oi_pcr": 99.52, "pcr": 99.52}, ...]{"data": [...]}, one row per trading day.
| Field | Unit | Description |
|---|---|---|
date | — | Trading day |
put_volume / call_volume | contracts | Put / call volume |
volume_pcr | % | Put/call volume ratio |
put_oi / call_oi | contracts | Put / call open interest |
oi_pcr | % | Put/call open-interest ratio (買賣權未平倉量比率) |
pcr | % | Same as oi_pcr (kept for compatibility) |
503 store not ready or upstream rate limit. A range with no rows is 200 with "data": [].
/studio/market/twfutures/carrying_cost/<identity> Blave's estimate of the average cost of one institution's net TAIEX-futures position, with its unrealized and realized PnL. An estimate from daily aggregates, not the institution's real fills.
Method:
scope=all), or TX only (scope=tx).| Name | Description | Allowed | Default |
|---|---|---|---|
identitystring · pathRequired | 外資 / 投信 / 自營商 | foreign, investment_trust, dealer | |
startstring · query | First trading date, inclusive | YYYY-MM-DD | 2023-10-18 (whole history) |
endstring · query | Last trading date, inclusive | YYYY-MM-DD | today |
scopestring · query | all = TX + MTX + TMF in TX-equivalent contracts; tx = 大台 only (the basis most Taiwanese sites quote) | all, tx | all |
The ledger always runs from the start of the stored history; start / end only cut the window, so the same day has the same values whatever window you ask for.
body = requests.get(f"{BASE_URL}/studio/market/twfutures/carrying_cost/foreign" , headers=headers, params={"start": "2026-10-06"}, timeout=60).json()rows = body["data"]# Live capture 2026-10-07 (scope=all):# {"identity": "foreign", "scope": "all", "data": [# {"date": "2026-10-06", "net_open_interest": -78570.7, "net_open_interest_change": -3923.5,# "cost": 46527.57, "txf_close": 50060.0, "mark_price": 50088.51,# "unrealized_pnl": -55957022956, "realized_pnl": -5893982992, "total_pnl": -61851005948,# "cycle_start": "2026-09-16"},# {"date": "2026-10-07", "net_open_interest": -78435.8, "net_open_interest_change": 134.9,# "cost": 46527.57, "txf_close": 49979.0, "mark_price": 49974.38,# "unrealized_pnl": -54070636128, "realized_pnl": -5988669182, "total_pnl": -60059305310,# "cycle_start": "2026-09-16"}]}gap = rows[-1]["txf_close"] - rows[-1]["cost"] # points the market is above (+) / below (−) their cost{"identity", "scope", "data": [...]}, one row per trading day, oldest → newest; "stale": true is added only when the server's copy is behind TAIFEX's last published day (the newest row may be missing).
| Field | Type | Unit | Description |
|---|---|---|---|
date | string | — | Trading day (Taipei) |
net_open_interest | float | TX-equivalent contracts | Long − short OI (negative = net short) |
net_open_interest_change | float | contracts | Change vs the previous trading day |
cost | float | null | index points | Weighted-average cost of the net position; null when flat |
txf_close | float | null | index points | TX near-month day-session close (the expiring contract is skipped on settlement day) |
mark_price | float | null | index points | TAIFEX valuation of the position, at settlement prices |
unrealized_pnl | int | TWD | (mark − cost) × net contracts × 200 |
realized_pnl | int | TWD | Realized since cycle_start; resets to 0 on every settlement day |
total_pnl | int | TWD | unrealized_pnl + realized_pnl |
cycle_start | string | — | The settlement day that opened the current cycle |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid identity. Allowed: ['dealer', 'foreign', 'investment_trust']"} | Unknown identity |
| 400 | {"error": "Invalid scope. Allowed: ['all', 'tx']"} | Unknown scope |
| 400 | {"error": "Invalid start date, expected YYYY-MM-DD"} (or end) / {"error": "start must not be after end"} | Bad date / reversed range |
| 503 | {"error": "Market data is not ready on this server. Please retry later."} | Store not ready — retry later, never read as "no position" |
| 500 | {"error": "Internal error"} | Unexpected server error |
scope=tx).