# Taiwan Day Trading Stats — 現股當沖 (TWSE + TPEx) (`chamarix/taiwan-day-trading-stats`) Actor

Taiwan same-day trading (現股當沖) turnover per security and per market: day-trading volume, buy and sell value, and the day-trading ratio computed against that session's total turnover — the way the exchanges compute their own market-wide figure. TWSE listed and TPEx OTC, back to 2014-01-06.

- **URL**: https://apify.com/chamarix/taiwan-day-trading-stats.md
- **Developed by:** [chris](https://apify.com/chamarix) (community)
- **Categories:** AI, Developer tools, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Taiwan Day Trading Stats — 現股當沖 Volume, Value & Ratio (TWSE + TPEx)

Get structured JSON access to **Taiwan's same-day trading turnover, security by security** — how much of every stock's daily volume was bought and sold again before the close, what day traders paid, what they got back, and what share of the whole market they were.

Taiwan is the most day-traded equity market in Asia. On a normal session **a quarter of all shares that change hands on the TWSE are round-tripped the same day**, and in individual names the figure routinely passes 70%. Both exchanges publish that breakdown after the close — this Actor normalizes both boards into one flat schema and computes the per-security ratio the exchanges only publish market-wide.

### What you get

| Record type | Rows | What it tells you |
|---|---|---|
| **STOCK** | ~1,200 TWSE + ~840 TPEx per session | Per-security day-trading volume, buy value, sell value, the ratio against that session's own turnover, plus OHLC and close |
| **MARKET** | 1 per board per session | The exchange's own market-wide day-trading volume, value and percentages, with the whole-market totals behind them |

Both boards — TWSE listed (上市) and TPEx OTC (上櫃) — with history back to **2014-01-06**, the day same-day trading became legal in Taiwan.

### Why this data matters

- **Day-trading ratio is a crowding gauge.** A stock where 70% of the volume is intraday round-trips has almost no position-holder behind the move. `day_trading_ratio` gives you that number for every security, every session — the exchanges publish it only for the market as a whole.
- **You can see whether day traders won or lost.** `day_trading_net_value` is the sell leg minus the buy leg: the gross P\&L the day-trading crowd booked in that security, before fees and the 0.15% intraday transaction tax. Aggregate it across a market and you have a sentiment series that has nothing to do with price.
- **Entry and exit prices, not just turnover.** `day_trading_avg_buy_price` and `day_trading_avg_sell_price` are volume-weighted — compare them against the session's OHLC to see whether the crowd was buying strength or fading it.
- **Regulatory suspensions are flagged.** When a security draws 注意/處置 attention, the exchange suspends selling first and buying back the same day. `sell_first_day_trading_suspended` marks it, so a backtest knows the short-side leg was unavailable.
- **Real history.** Twelve years of sessions, one request per board per day, no key and no registration.

### Output

One record per security per session, plus the market line. Every row carries the same keys regardless of board or record type, so the dataset stays tabular.

```json
{
  "record_type": "STOCK",
  "market": "TWSE",
  "date": "2026-08-04",
  "stock_code": "3481",
  "stock_name": "群創",
  "is_etf": false,
  "day_trading_volume": 258266000,
  "day_trading_buy_value": 12022293200,
  "day_trading_sell_value": 12055560850,
  "day_trading_net_value": 33267650,
  "day_trading_avg_buy_price": 46.55,
  "day_trading_avg_sell_price": 46.6789,
  "day_trading_ratio": 74.182,
  "day_trading_buy_value_ratio": 74.016,
  "day_trading_sell_value_ratio": 74.2208,
  "total_volume": 348151865,
  "total_value": 16242834512,
  "open": 45.65,
  "high": 48.55,
  "low": 44.7,
  "close": 47.8,
  "price_change": 2.0,
  "sell_first_day_trading_suspended": false,
  "source_url": "https://www.twse.com.tw/exchangeReport/TWTB4U?response=json&date=20260804&selectType=All"
}
```

```json
{
  "record_type": "MARKET",
  "market": "TWSE",
  "date": "2026-08-04",
  "day_trading_volume": 3010263000,
  "day_trading_buy_value": 451260488660,
  "day_trading_sell_value": 453230864230,
  "day_trading_net_value": 1970375570,
  "day_trading_ratio": 26.54,
  "day_trading_buy_value_ratio": 41.51,
  "day_trading_sell_value_ratio": 41.69,
  "market_total_volume": 11340636777,
  "market_total_value": 1087045875836,
  "securities_count": 1221,
  "source_url": "https://www.twse.com.tw/exchangeReport/TWTB4U?response=json&date=20260804&selectType=All"
}
```

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `startDate` | string | — | `YYYY-MM-DD`, required. Dates before 2014-01-06 are moved up to it. |
| `endDate` | string | = `startDate` | Inclusive. Weekends are skipped without a request. |
| `markets` | array | both | `TWSE`, `TPEX` |
| `stockCodes` | array | all | e.g. `["2330", "3481"]`. MARKET rows are kept regardless. |
| `minDayTradingRatio` | integer | `0` | Keep only securities at or above this day-trading percentage. |
| `excludeEtfs` | boolean | `false` | Drop 00-prefixed codes — ETFs, ETNs, bond and leveraged variants. |
| `includeMarketSummary` | boolean | `true` | Emit the MARKET row per board per session. |
| `includeQuotes` | boolean | `true` | Fetch closing quotes for the ratios and OHLC. Off halves the requests. |

**Screening example** — every TWSE and TPEx ordinary share whose volume was at least 70% intraday round-trips last week:

```json
{
  "startDate": "2026-07-27",
  "endDate": "2026-07-31",
  "minDayTradingRatio": 70,
  "excludeEtfs": true
}
```

### How the ratio is computed

Neither exchange publishes a per-security day-trading ratio — only a market-wide one. This Actor computes it, using the formula reverse-engineered from the exchange's own published figure and verified against it:

```
day_trading_ratio = day-trading volume ÷ that security's total session volume × 100
```

At market level, TWSE's published 26.54% for 2026-08-04 reproduces exactly from its own two published totals (3,010,263,000 ÷ 11,340,636,777 = 26.5440%), and the same holds for the buy- and sell-value percentages. **Every run re-checks this** on TWSE sessions and logs a warning if the exchange's arithmetic and its own numbers ever stop agreeing.

Note that TWSE prints these percentages **truncated** to two decimals rather than rounded — 48.0882% appears as 48.08%. Both conventions are accepted by the check; the values in the dataset are computed to four decimals and not truncated.

TPEx publishes no all-categories market total, so its MARKET rows carry the exchange's own percentages and leave `market_total_volume` empty. Per-security ratios are computed identically on both boards.

### Data integrity

Numbers are checked against other official numbers before anything is published:

- **Per-security turnover must sum to the market line.** All three totals — volume, buy value, sell value — are re-added from the detail table and compared with the exchange's own market row. On both boards, on every session tested, they match to the share and the dollar.
- **Day-trading turnover cannot exceed session turnover.** Every security's round-trip volume is checked against its own total volume from the daily quote table.
- **The market percentages must reproduce.** As described above, on TWSE.
- **The session must be the one you asked for.** TWSE answers a date it has no session for by silently serving the most recent one instead, echoing its own date in the payload. That echo is compared with the requested date before parsing, so a holiday or a future date returns nothing rather than yesterday's numbers filed under the wrong day.
- **A missing column stops the run.** If either exchange drops a column this Actor reads, the run fails loudly instead of publishing a partial dataset that would look like a quiet session.

Known gaps, stated rather than papered over:

- **`sell_first_day_trading_suspended` is null on early TPEx sessions.** The suspension marker was added to the OTC table years after launch — TPEx's 2014 sessions have five columns, not six. Null means the exchange never published it, not that nothing was suspended.
- **`price_change` is null when the session is not comparable.** TWSE marks securities that went ex-dividend or resumed from suspension with `X` instead of a direction; no change is reported for them rather than a misleading zero.

### Sources

All official, all free, no API key:

| Feed | Endpoint |
|---|---|
| TWSE day trading | `www.twse.com.tw/exchangeReport/TWTB4U` |
| TWSE daily quotes and market totals | `www.twse.com.tw/rwd/zh/afterTrading/MI_INDEX` |
| TPEx day trading | `www.tpex.org.tw/www/zh-tw/intraday/stat` |
| TPEx daily quotes | `www.tpex.org.tw/www/zh-tw/afterTrading/otc` |

### Related Actors

Same publisher, same market, designed to join on `stock_code` and `date`:

- **[Taiwan Stock Alerts](https://apify.com/chamarix/taiwan-stock-alerts)** — 注意股/處置股. The securities whose sell-first day trading gets suspended show up here first.
- **[Taiwan Margin Trading](https://apify.com/chamarix/taiwan-margin-trading)** — 融資融券 balances, the leveraged position-holders behind the other side of the tape.
- **[Taiwan SBL & Short Sale Balance](https://apify.com/chamarix/taiwan-sbl-short-sale-balance)** — borrow and short balances.
- **[TWSE Institutional Trades](https://apify.com/chamarix/twse-institutional-trades)** / **[TPEx Institutional Trades](https://apify.com/chamarix/tpex-institutional-trades)** — foreign, trust and dealer net buying.

# Actor input Schema

## `startDate` (type: `string`):

Start date in YYYY-MM-DD format. Same-day trading began on 2014-01-06 and both exchanges refuse anything earlier; earlier dates are moved up to it. Weekends are skipped without a request.

## `endDate` (type: `string`):

End date in YYYY-MM-DD format (inclusive). Leave empty to query only the start date. Each session costs one request per market, plus one more when Include quote data is on.

## `markets` (type: `array`):

Which boards to cover. Leave empty for both.

## `stockCodes` (type: `array`):

Optional list of security codes to keep (e.g., \['2330', '3481']). Leave empty for every day-traded security. Market summary rows are kept regardless.

## `minDayTradingRatio` (type: `integer`):

Keep only securities whose day-trading volume was at least this percentage of their session volume. 60 or above is the crowded end of the market. Leave at 0 for everything. Requires Include quote data.

## `excludeEtfs` (type: `boolean`):

Drop 00-prefixed codes — ETFs, ETNs and their bond and leveraged variants. Bond ETFs in particular show high day-trading ratios on thin volume and can crowd out a screen for ordinary shares.

## `includeMarketSummary` (type: `boolean`):

Add one MARKET record per board per session carrying the exchange's own market-wide day-trading volume, value and percentages.

## `includeQuotes` (type: `boolean`):

Fetch each session's closing quotes so every row carries total volume, total value, OHLC, and the day-trading ratios. Turning this off halves the number of requests but leaves those fields empty — the exchanges publish no per-security ratio of their own.

## Actor input object example

```json
{
  "startDate": "2026-07-01",
  "endDate": "2026-07-31",
  "markets": [
    "TWSE",
    "TPEX"
  ],
  "stockCodes": [],
  "minDayTradingRatio": 0,
  "excludeEtfs": false,
  "includeMarketSummary": true,
  "includeQuotes": true
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startDate": "2026-07-01",
    "endDate": "2026-07-31",
    "markets": [
        "TWSE",
        "TPEX"
    ],
    "stockCodes": [],
    "minDayTradingRatio": 0
};

// Run the Actor and wait for it to finish
const run = await client.actor("chamarix/taiwan-day-trading-stats").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startDate": "2026-07-01",
    "endDate": "2026-07-31",
    "markets": [
        "TWSE",
        "TPEX",
    ],
    "stockCodes": [],
    "minDayTradingRatio": 0,
}

# Run the Actor and wait for it to finish
run = client.actor("chamarix/taiwan-day-trading-stats").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startDate": "2026-07-01",
  "endDate": "2026-07-31",
  "markets": [
    "TWSE",
    "TPEX"
  ],
  "stockCodes": [],
  "minDayTradingRatio": 0
}' |
apify call chamarix/taiwan-day-trading-stats --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=chamarix/taiwan-day-trading-stats",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/mgU3zMzBivKX4Sus6/builds/mkmTbRFXFglB7Ntw0/openapi.json
