From 8a1b29043cf11553da9d7a886aaf190937ff8279 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Tue, 3 Nov 2026 14:04:32 +0700 Subject: [PATCH 01/16] docs: Stockbit session endpoints and the design of features on them docs/STOCKBIT.md: every market-data endpoint in Stockbit's web client, probed with a session on 2026-11-03 (corporate actions, shareholder movements, composition, market detector, analyst consensus, hourly charts, market states), the read-only rules all session features follow, and the design of corporate actions and shareholder movements. Linked from AGENTS.md and ROADMAP.md. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- AGENTS.md | 1 + ROADMAP.md | 12 ++- docs/STOCKBIT.md | 248 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 257 insertions(+), 4 deletions(-) create mode 100644 docs/STOCKBIT.md diff --git a/AGENTS.md b/AGENTS.md index 36d9690..360d15c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,6 +33,7 @@ Docs: - `docs/OWNERSHIP_SYNC.md` / `docs/OWNERSHIP_PUBLISH.md`: snapshot consumer contract / maintainer publishing - `docs/SMOKE.md`: Nix checks, test layout, and the live drift check - `docs/DESIGN.md`: idx-core / idx-mcp design and parity gates +- `docs/STOCKBIT.md`: Stockbit session endpoints and the design of features on them - `docs/IDX_NEWS.md`: news sources research (IDX disclosures, Google News, Yahoo) and a proposed publisher design - `ROADMAP.md`: open work diff --git a/ROADMAP.md b/ROADMAP.md index 05d1fd3..593bcec 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -14,10 +14,14 @@ history lives in git. - Multi-period financial statements (today `financials` is single-period) - Order book depth without a login: no free source exists (IDX sells delayed depth to vendors); `stocks orderbook` needs the user's Stockbit login. -- Stockbit login follow-ups: intraday OHLCV from the session's `1d` chart; - confirming session 1 is `STATE_NAME_SESSION_1` (session 2, `BREAK` and - `MARKET_CLOSED` were recorded on 2026-11-03), and when `has_foreign_bs` - turns on with the day's foreign figures; an +- Corporate actions (`stocks actions`, `calendar`) and shareholder movements + (`ownership movements`) from the Stockbit session; design and endpoints in + `docs/STOCKBIT.md`. +- Stockbit login follow-ups: hourly OHLCV from the session's `1w` chart (the + `1d` chart is per-minute closes only); confirming session 1 is + `STATE_NAME_SESSION_1` (session 2, `BREAK` and `MARKET_CLOSED` were + recorded on 2026-11-03), and when `has_foreign_bs` turns on with the day's + foreign figures; an opt-in daily refresh so a session outlives the refresh token's week, once it is known whether Stockbit caps a session's total life; and the sign-in response (`/login/v6/*`, read over DevTools' `Fetch`) as a second signal diff --git a/docs/STOCKBIT.md b/docs/STOCKBIT.md new file mode 100644 index 0000000..c2f14aa --- /dev/null +++ b/docs/STOCKBIT.md @@ -0,0 +1,248 @@ +# Stockbit Session Features: Research and Design + +What the user's Stockbit session (`idx stockbit login`, see the Stockbit +sections of `docs/ARCHITECTURE.md`) can serve beyond the order book, live +quotes and daily history, and how idx should add it. Endpoints were found in +Stockbit's web bundle (`stockbit.com/_next/static/chunks/*.js`, the API client +module) and probed with a real session on Tue 2026-11-03 during trading hours, +one GET at a time at least 1 s apart. Nothing here ships yet unless marked. + +## Rules for every session feature + +1. **Read-only by construction.** The session client (`api/stockbit/exodus.rs`) + issues GET on an allowlist of path prefixes, plus `POST /login/refresh`. + The bundle also holds trading (orders, day trade, PIN, cash withdrawal, + portfolio), chat, posting and account endpoints; idx never calls them, and + the allowlist makes a stray call fail before it leaves the process. +2. **One client.** Every endpoint goes through `Exodus::get`: rotating refresh + under the file lock, one retry after a 401 / JSON 403, the shared 1 s + pacing, `AUTHERROR` / `UPSTREAMBLOCKED` / `RATELIMITED` mapping, and no + token in logs, errors or cache keys. +3. **Stockbit-only commands use Stockbit whatever `--provider` says**, like + `stocks intraday`; without a session they answer `AUTHERROR` (exit code as + today). All endpoints below answer `401` without a session. +4. **Pure parsers, typed output.** Stockbit sends numbers as display strings + (`"193,206"`, `"+0.0001"`, `"1.03B"`), dates as `"25 Mar 26"` or + `YYYY-MM-DD`, and placeholders (`""`, `0`, `"0001-01-01 00:00:00"`). Parsers + turn them into integers, decimals, `NaiveDate` and `None`, and are tested + against recorded fixtures (`tests/fixtures/stockbit_exodus_*`). +5. **Units checked live** per endpoint before release (chart volume is lots, + the order book is shares). +6. **Cache per endpoint**: book and quote 5 s, market state 30 s, movements + 1 h, corporate actions 6 h. +7. **Terms**: Stockbit's data is for personal, non-commercial use; the user + docs (`web/src/content/docs/cli/stockbit.md`) say so for every feature. + +## Endpoint inventory + +All on `https://exodus.stockbit.com`, bearer access token, HTTP 200 on +2026-11-03 unless noted. + +| Endpoint | Serves | Plan | +| --- | --- | --- | +| `/company-price-feed/v2/orderbook/companies/{SYM}` | quote, OHLC, foreign flow, depth | shipped (#74) | +| `/company-price-feed/market-time/session` | market state | shipped (#74) | +| `/charts/{SYM}/daily?timeframe=1m\|3m\|1y` | daily candles | shipped (#74) | +| `/charts/{SYM}/daily?timeframe=1w` | hourly candles, 5 sessions | P2 | +| `/corpaction/{type}[?symbol=SYM]` | corporate actions and calendar | **P1** | +| `/insider/company/majorholder` | insider / major-holder movements | **P1** | +| `/insider/shareholding/composition/companies/{SYM}` | holder composition by period | P2 | +| `/marketdetectors/{SYM}` | broker summary, Stockbit's bandar detector | P2 | +| `/analyst-ratings/{SYM}/consensus`, `/analyst-ratings/{SYM}` | estimates, ratings | P3 | +| `/order-trade/running-trade`, `/order-trade/trade-book` | trade tape | P3 | +| `/emitten-metadata/shareholders/{SYM}/chart` | composition chart | not probed: needs a second token from `POST /emitten-metadata/shareholders/token` | +| `/keystats/ratio/v1/{SYM}`, `/findata-view/company/financial` | ratios, statements | skip for now (MSN covers them) | + +### Market state (`market-time/session`) + +`data.detail` has two boards, `regular` and `fca` (full call auction), each +with `session`, `state_name`, `state_start_time`, `state_end_time`, +`time_left`, `is_last_session`, `is_end_of_day`. Observed: + +| Time (WIB) | `regular` | `fca` | +| --- | --- | --- | +| Sat 2026-10-18 20:15 | `STATE_NAME_MARKET_CLOSED`, session 0, end of day | same | +| Tue 2026-11-03 12:35 | `STATE_NAME_BREAK`, session 1, 12:00:00-13:29:59 | `STATE_NAME_BREAK`, session 3, 12:00:00-13:59:59 | +| Tue 2026-11-03 13:30 | `STATE_NAME_SESSION_2`, session 2, 13:30:00-15:49:59 | still `STATE_NAME_BREAK` | +| Tue 2026-11-03 14:00 | `STATE_NAME_SESSION_2` | `STATE_NAME_SESSION_4` | + +The order book and session quotes treat any numbered `STATE_NAME_SESSION_` +as trading (#74; the assumed `STATE_NAME_MARKET_OPEN` never appeared). idx +reads `regular` only, so FCA-board stocks can show the regular board's state +around the break. + +In session the order book's `fbuy`/`fsell`/`fnet` were the previous +session's (equal to IPOT's 2026-11-02 net for BBCA, BBRI, TLKM) with +`has_foreign_bs: false`; idx keeps them only when the flag is true (#74). +Other order-book fields not used yet: `total_bid_offer` (queued lots and +orders on each side), `market_data` (volume and value by board: regular, +negotiated, cash), `iepiev` (indicative equilibrium price and volume, for the +auctions), `corp_action.active`. + +### Charts + +- `timeframe=1d`, `PRICE_CHART_TYPE_CANDLE`: empty `prices` during the break. +- `timeframe=1d`, `PRICE_CHART_TYPE_LINE`: a rolling ~350 minutes of + per-minute closes across two sessions, no OHLC or volume + (`xaxisopt: "intraday"`). Adds nothing over the public `stocks intraday`. +- `timeframe=1w`, candle: hourly bars for 5 sessions, `interval_in_minutes: + 60`, volume in lots. The newest bar is stamped with its last update + (`11:59:00`), not the hour. BBCA's three bars on 2026-11-03 summed to + 101.2M shares against 105.1M in the order book (pre-open auction or the + negotiated market, unconfirmed). + +Hourly history needs a datetime bar (`Ohlc.date` is a `NaiveDate`) and an +hourly `Interval`, across Yahoo, MSN, output, goldens and the MCP schema; that +is its own change. + +## P1: corporate actions + +idx has none today (only the `high-dividend` screen and Yahoo's dividend +yield). They explain price gaps in history (splits, bonuses, rights) and give +a calendar of cum dates. + +### Endpoint + +`GET /corpaction/{type}?symbol=SYM` gives one stock's history (BBCA: 37 cash dividends, cum dates 2009-06-09 to 2026-08-28); `GET /corpaction/{type}` without `symbol` is the +market-wide list, newest cum/event date first, upcoming events included. The +bundle passes `limit` (default 30); `rightissue` honoured it loosely (28 rows +for `limit=5`), `warrant` ignored it (1329 rows for `limit=3`), so idx filters +by date itself. + +| `type` | Response key | Field prefix | Fields that matter | +| --- | --- | --- | --- | +| `dividend` | `dividend` | `dividend_` | `cumdate`, `exdate`, `recdate`, `paydate`, `value` (per share), `currency` | +| `stock_dividend` | `stock_dividend` | — | empty on 2026-11-03; record a row before parsing | +| `bonus` | `bonus` | `sahambonus_`, **`stocksplit_`** | `ratio` (`"6 : 4"`), `stocksplit_{cumdate,exdate,recdate,paymentdate,old,new,factor}` | +| `rightissue` | `rightissue` | `rightissue_` | `cumdate`, `exdate`, `recdate`, `old`, `new`, `ratio`, `price`, `factor`, `trading_start`, `trading_end` | +| `warrant` | `warrant` | `wrant_` | `trading_from`, `trading_end`, `exc_from`, `exc_end`, `exc_price` | +| `stocksplit` | `stocksplit` | `stocksplit_` | `cumdate`, `exdate`, `recdate`, `old`, `new`, `ratio`, `factor` | +| `reversesplit` | **`stock_reverse`** | — | empty on 2026-11-03; record a row before parsing | +| `rups` | `rups` | `rups_` | `date`, `time`, `venue`, `eligible_date` | +| `pubex` | `pubex` | `puexp_` | `date`, `time`, `venue` | +| `ipo` | `ipo` | `ipo_` | `listing_date`, `company_name`, `ipo_price.{minimum,maximum,final}`, `ipo_data_detail` (placeholders common) | +| `tenderoffer` | **`tender`** | `tender_` | `start`, `end`, `paydate`, `price`, `shares`, `percentage` | +| `economic` | — | — | macro calendar, not a corporate action; out of scope | + +Examples from 2026-11-03: PPGL bonus 6:4 ex 2026-11-03; PRDA split 1:5 cum +2026-12-17; MGLV rights 100:15 at 8,880 cum 2026-11-04; BMAS rights 655:104 at +350 cum 2026-11-23, rights trading 2026-11-27 to 12-03; AUTO tender offer at +3,600 until 2026-11-11. + +### Types + +```rust +pub struct CorporateAction { + pub symbol: String, // BBCA.JK + pub kind: ActionKind, // Dividend, StockDividend, Bonus, Rights, Warrant, + // Split, ReverseSplit, Meeting, PublicExpose, Ipo, TenderOffer + pub cum_date: Option, + pub ex_date: Option, + pub record_date: Option, + pub pay_date: Option, + pub event_date: Option, // meeting, expose, listing, tender end + pub detail: ActionDetail, // kind-specific: amount + currency; old:new ratio + // and factor; price; trading/exercise windows; venue +} +``` + +One parser per type maps its prefix into this record; unknown types and empty +lists are not errors. A row whose dates are all placeholders is dropped. + +### Surface + +- `idx stocks actions SYM [--kind dividend,rights,...] [--since DATE]`: one + stock's history, newest first. +- `idx calendar [--kind ...] [--from DATE] [--to DATE]`: market-wide, default + today to +30 days, sorted by the next relevant date. +- MCP: `get_corporate_actions {symbol, kinds?, since?}`, + `get_corporate_calendar {kinds?, from?, to?}`. +- Later: `stocks history` notes ex-dates of splits, bonuses and rights in the + window, so a gap is not read as a crash. + +## P1: shareholder movements + +### Endpoint + +`GET /insider/company/majorholder?symbol=&insider=&date_start=&date_end=&page=`; +all parameters optional. 50 rows a page, `data.is_more` for the next page. +Without `symbol` it is market-wide, newest first: on 2026-11-03 the newest rows +were from 2026-11-02. BBCA's 50 rows span 2024-03-22 to 2026-03-25. + +Each row (`data.movement[]`): `name`, `symbol`, `date` (`"25 Mar 26"`), +`previous` / `current` / `changes` `{value: shares as "193,206", percentage}`, +`action_type` (`ACTION_TYPE_BUY|SELL|TRANSFER`), `nationality` +(`NATIONALITY_TYPE_LOCAL|FOREIGN`), `badges` (`SHAREHOLDER_BADGE_DIREKTUR`, +`..._KOMISARIS`), `price.raw.value`, `value.raw.value` (IDR), +`is_estimated_price`, `purpose` (free text such as "Pembelian", "Investasi"), +`data_source.type` (`SOURCE_TYPE_IDX` for insider disclosures, +`SOURCE_TYPE_KSEI` for 5% holder changes), `broker_detail` (empty so far). + +### Relation to `ownership` + +The KSEI register idx imports is a monthly snapshot of holders above 1%. This +feed is the individual changes, days after the trade, including insiders far +below 1%. It joins the ownership entities by name (the same resolution +`ownership resolve` maintains), but needs no SQLite import: it is live. + +### Signal quality + +Discretionary insider buying, above all by several insiders together, is the +form of this data with predictive power in the literature; selling much less. +The raw feed is noisy: + +- Program-like rows: BBCA's 2026-03-25 rows are every director and + commissioner "buying" at the same 6,982, which reads as a share plan, not + open-market conviction. Flag many holders on one date at one price. +- `TRANSFER` rows and estimated prices (`is_estimated_price`). +- The reporting lag: part of the move can be priced before the row appears. + +So the command shows the rows faithfully, and a separate summary scores them: +net value by symbol, the number of distinct buyers (cluster), value against +average daily value, holders crossing 5% / 10%, and the program flag. Calling +it alpha waits for an event study (feed history back to 2024 per symbol, +Yahoo prices, forward 5/20/60-session returns against IHSG). + +### Surface + +- `idx ownership movements [SYM] [--from DATE] [--to DATE] [--holder NAME] + [--action buy|sell|transfer] [--pages N]`: rows, newest first. +- `idx ownership movements --summary [--from DATE]`: the per-symbol score. +- MCP: `get_shareholder_movements {symbol?, from?, to?, holder?, pages?}`. + +## P2 and P3 + +- **Composition by period** (`/insider/shareholding/composition/companies/{SYM}`, + optional `period_start`, `period_end`, `view`): per `report_date` (latest + 2026-10-30 on 2026-11-03), total shares and each holder's shares, + percentage and previous shares. Fresher than waiting on the IDX register; + could feed `ownership changes` as a source. +- **Market detector** (`/marketdetectors/{SYM}`): `bandar_detector` with + `accdist` labels per top-N, broker counts, average price. A second source + for `stocks broker` / `bandar` beside IPOT (`--source ipot|stockbit`), as + `flow` has `--source ipot|idx`; IPOT answered 502 on 2026-10-31. +- **Hourly candles** (`timeframe=1w`), see "Charts". +- **Analyst consensus**: revenue and operating profit actuals and estimates + by year; ratings per broker. +- **Trade tape**: running trade and trade book; large and only meaningful in + session; wait for `--watch`. + +## Order of work + +1. Close #74: the open-state name in trading hours, fixtures for the observed + states (done 2026-11-03). +2. Corporate actions (parsers, `stocks actions`, `calendar`, MCP, goldens). +3. Shareholder movements, rows first, then `--summary`. +4. Event study for the movement score; P2 by demand. + +## Open questions + +- The `regular` state in session 1 (assumed `STATE_NAME_SESSION_1`), the + pre-open (08:45-09:00) and the closing auction (15:50-16:00). +- When `has_foreign_bs` turns true, and whether the figures are then the + day's. +- `stock_dividend` and `reversesplit` row shapes (both empty on 2026-11-03). +- Whether `/corpaction/{type}` takes a date range (the bundle sends only + `limit` and `symbol`). +- The reporting lag between a movement's `date` and its appearance in the + feed (sample the market-wide first page daily). From 43ff4aa433bd743c19ba0b3bb77a7af945b8defb Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Tue, 3 Nov 2026 14:35:20 +0700 Subject: [PATCH 02/16] feat: corporate actions from the Stockbit session (stocks actions, stocks calendar) `idx stocks actions SYM [--kind ...]`: one stock's cash and stock dividends, bonus shares, rights, warrants, splits and reverse splits, meetings, public exposes and tender offers (`--kind ipo` adds its IPO), newest first. `idx stocks calendar [--from] [--to] [--kind ...]`: the market's actions dated in the range (default today and 30 days ahead), oldest first. MCP: get_corporate_actions, get_corporate_calendar. Stockbit's `/corpaction/{type}` serves one kind per request; each type has its own field prefix and list key, so entitlements are read by field suffix. An action's `date` is the cum date for entitlements, else the event's first day. Dividends keep their decimals. One request per kind, cached 6 hours. AUTHERROR without a session. Fixtures are the 2026-11-03 recordings (market-wide ones trimmed to October-December). Goldens added; help-stocks and completions-bash gain the two subcommands, MCP tools.json the two tools (regenerated with UPDATE_GOLDEN=1). The MCP docs counted 17 tools without stockbit_login; now 20. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- README.md | 8 +- ROADMAP.md | 7 +- crates/idx-cli/src/cli/stocks.rs | 67 ++- crates/idx-cli/src/output/mod.rs | 23 + crates/idx-cli/src/output/table.rs | 185 ++++++++ crates/idx-cli/tests/golden/cases.toml | 33 ++ .../tests/golden/completions-bash.golden | 148 ++++++- .../error-actions-no-session.json.golden | 4 + .../error-actions-no-session.table.golden | 4 + .../golden/error-calendar-range.json.golden | 4 + .../golden/error-calendar-range.table.golden | 4 + .../idx-cli/tests/golden/help-stocks.golden | 2 + .../stockbit-actions-dividends.json.golden | 4 + .../stockbit-actions-dividends.table.golden | 83 ++++ .../tests/golden/stockbit-actions.json.golden | 4 + .../golden/stockbit-actions.table.golden | 43 ++ .../stockbit-calendar-meetings.json.golden | 4 + .../stockbit-calendar-meetings.table.golden | 29 ++ .../golden/stockbit-calendar.json.golden | 4 + .../golden/stockbit-calendar.table.golden | 37 ++ crates/idx-core/src/api/mock.rs | 36 +- crates/idx-core/src/api/mod.rs | 19 + .../idx-core/src/api/stockbit/corpaction.rs | 405 ++++++++++++++++++ crates/idx-core/src/api/stockbit/exodus.rs | 20 + crates/idx-core/src/api/stockbit/mod.rs | 15 +- crates/idx-core/src/client.rs | 4 + crates/idx-core/src/corporate/mod.rs | 108 +++++ crates/idx-core/src/corporate/types.rs | 292 +++++++++++++ crates/idx-core/src/lib.rs | 1 + .../stockbit_exodus_corpaction_bonus.json | 1 + .../stockbit_exodus_corpaction_dividend.json | 1 + ...ckbit_exodus_corpaction_dividend_bbca.json | 1 + .../stockbit_exodus_corpaction_ipo.json | 1 + .../stockbit_exodus_corpaction_pubex.json | 1 + ...stockbit_exodus_corpaction_pubex_bbca.json | 1 + ...ockbit_exodus_corpaction_reversesplit.json | 1 + ...stockbit_exodus_corpaction_rightissue.json | 1 + .../stockbit_exodus_corpaction_rups.json | 1 + .../stockbit_exodus_corpaction_rups_bbca.json | 1 + ...kbit_exodus_corpaction_stock_dividend.json | 1 + ...stockbit_exodus_corpaction_stocksplit.json | 1 + ...bit_exodus_corpaction_stocksplit_bbca.json | 1 + ...tockbit_exodus_corpaction_tenderoffer.json | 1 + .../stockbit_exodus_corpaction_warrant.json | 1 + crates/idx-mcp/src/params.rs | 41 ++ crates/idx-mcp/src/server.rs | 55 ++- crates/idx-mcp/tests/golden/tools.json | 85 ++++ crates/idx-mcp/tests/mcp.rs | 51 ++- docs/ARCHITECTURE.md | 14 + docs/STOCKBIT.md | 20 +- web/src/content/docs/cli/reference.md | 128 ++++++ web/src/content/docs/cli/stockbit.md | 7 +- web/src/content/docs/cli/stocks.md | 22 + web/src/content/docs/mcp/index.md | 6 +- web/src/content/docs/mcp/tools.md | 19 + 55 files changed, 2026 insertions(+), 34 deletions(-) create mode 100644 crates/idx-cli/tests/golden/error-actions-no-session.json.golden create mode 100644 crates/idx-cli/tests/golden/error-actions-no-session.table.golden create mode 100644 crates/idx-cli/tests/golden/error-calendar-range.json.golden create mode 100644 crates/idx-cli/tests/golden/error-calendar-range.table.golden create mode 100644 crates/idx-cli/tests/golden/stockbit-actions-dividends.json.golden create mode 100644 crates/idx-cli/tests/golden/stockbit-actions-dividends.table.golden create mode 100644 crates/idx-cli/tests/golden/stockbit-actions.json.golden create mode 100644 crates/idx-cli/tests/golden/stockbit-actions.table.golden create mode 100644 crates/idx-cli/tests/golden/stockbit-calendar-meetings.json.golden create mode 100644 crates/idx-cli/tests/golden/stockbit-calendar-meetings.table.golden create mode 100644 crates/idx-cli/tests/golden/stockbit-calendar.json.golden create mode 100644 crates/idx-cli/tests/golden/stockbit-calendar.table.golden create mode 100644 crates/idx-core/src/api/stockbit/corpaction.rs create mode 100644 crates/idx-core/src/corporate/mod.rs create mode 100644 crates/idx-core/src/corporate/types.rs create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_bonus.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_dividend.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_dividend_bbca.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_ipo.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_pubex.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_pubex_bbca.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_reversesplit.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rightissue.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rups.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rups_bbca.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stock_dividend.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stocksplit.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stocksplit_bbca.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_tenderoffer.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_warrant.json diff --git a/README.md b/README.md index 5bf505b..8b5281c 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,8 @@ idx ownership changes --from 2026-07-31 --to 2026-08-31 minute) and `--provider stockbit` quotes with the best bid/offer while the market is open, delayed at least 10 minutes. With your own account (`idx stockbit login`): `stocks orderbook` depth, live - quotes and Stockbit daily history. Personal use under Stockbit's terms; see + quotes, Stockbit daily history, and corporate actions (`stocks actions`, + `stocks calendar`: dividends, rights, splits, meetings, IPOs and more). Personal use under Stockbit's terms; see the [Stockbit page](https://idx.rasyidanaf.com/cli/stockbit/) - Local file cache with TTL, and `--offline` mode with stale-cache fallback @@ -165,8 +166,9 @@ change it to `auto` with `idx config set general.output auto`. ## MCP server -`idx-mcp` serves the same data to MCP clients over stdio, as 17 tools: -`get_quotes`, `get_intraday`, `get_orderbook`, `stockbit_status`, `get_price_history`, `screen_stocks`, `get_company`, +`idx-mcp` serves the same data to MCP clients over stdio, as 20 tools: +`get_quotes`, `get_intraday`, `get_orderbook`, `get_corporate_actions`, +`get_corporate_calendar`, `stockbit_status`, `stockbit_login`, `get_price_history`, `screen_stocks`, `get_company`, `analyze_stock`, `compare_stocks`, `get_broker_summary`, `analyze_bandar`, `get_foreign_flow`, `get_shareholders`, `get_investor_holdings`, `search_investors`, `get_ownership_changes`, and `ownership_status`. Live results come wrapped as diff --git a/ROADMAP.md b/ROADMAP.md index 593bcec..88d1ea7 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -14,9 +14,10 @@ history lives in git. - Multi-period financial statements (today `financials` is single-period) - Order book depth without a login: no free source exists (IDX sells delayed depth to vendors); `stocks orderbook` needs the user's Stockbit login. -- Corporate actions (`stocks actions`, `calendar`) and shareholder movements - (`ownership movements`) from the Stockbit session; design and endpoints in - `docs/STOCKBIT.md`. +- Shareholder movements (`ownership movements`) from the Stockbit session; + design and endpoints in `docs/STOCKBIT.md`. Corporate-action follow-ups: + ex-dates of splits, bonuses and rights noted in `stocks history`, and the + `stock_dividend` / `reversesplit` row shapes once Stockbit lists one. - Stockbit login follow-ups: hourly OHLCV from the session's `1w` chart (the `1d` chart is per-minute closes only); confirming session 1 is `STATE_NAME_SESSION_1` (session 2, `BREAK` and `MARKET_CLOSED` were diff --git a/crates/idx-cli/src/cli/stocks.rs b/crates/idx-cli/src/cli/stocks.rs index 84ec04c..718d7bb 100644 --- a/crates/idx-cli/src/cli/stocks.rs +++ b/crates/idx-cli/src/cli/stocks.rs @@ -4,15 +4,17 @@ use clap::{Args, Subcommand}; use crate::config::{HistoryProviderKind, IdxConfig}; use crate::output::{ - render_bandar, render_broker_summary, render_compare, render_earnings, render_financials, - render_foreign_flow, render_fundamental, render_growth, render_history, render_insights, - render_intraday, render_news, render_orderbook, render_profile, render_quotes, render_risk, - render_screener, render_sentiment, render_technical, render_valuation, + render_bandar, render_broker_summary, render_compare, render_corporate_actions, + render_corporate_calendar, render_earnings, render_financials, render_foreign_flow, + render_fundamental, render_growth, render_history, render_insights, render_intraday, + render_news, render_orderbook, render_profile, render_quotes, render_risk, render_screener, + render_sentiment, render_technical, render_valuation, }; use idx_core::analysis::BandarQuery; use idx_core::analysis::bandar::DEFAULT_TOP; use idx_core::api::types::{Interval, Period}; use idx_core::broker::types::{BrokerBoard, BrokerInvestor, BrokerRange}; +use idx_core::corporate::types::{ActionKind, CalendarRange}; use idx_core::error::IdxError; use idx_core::financial::{EarningsFilter, StatementFilter, StatementKind}; use idx_core::flow::types::{FlowRange, FlowSource}; @@ -163,6 +165,42 @@ the output says so.", #[arg(long, default_value_t = 10)] depth: usize, }, + #[command( + about = "Dividends, rights, splits and other corporate actions of a stock (Stockbit login)", + long_about = "One IDX stock's corporate actions from your own Stockbit session (`idx \ +stockbit login`), newest first: cash and stock dividends, bonus shares, rights issues, \ +warrants, splits and reverse splits, shareholders' meetings, public exposes and tender offers \ +(`--kind ipo` adds its IPO). Stockbit serves one kind per request, 1 s apart, so the first \ +call takes about a second per kind; answers are cached for 6 hours.", + after_help = "Examples:\n idx stocks actions BBCA\n idx stocks actions TLKM --kind dividend\n idx -o json stocks actions BBRI --kind dividend,split | jq '.[0]'" + )] + Actions { + /// Single ticker symbol (e.g. BBCA). + symbol: String, + /// Kinds to list (default: all but ipo). + #[arg(long = "kind", value_enum, value_delimiter = ',', num_args = 1..)] + kinds: Vec, + }, + #[command( + about = "Upcoming and recent corporate actions across the market (Stockbit login)", + long_about = "Corporate actions across IDX from your own Stockbit session (`idx stockbit \ +login`), oldest first, dated within --from and --to (default: today and the next 30 days). \ +An action's date is its cum date for dividends, bonuses, rights and splits, else the event's \ +first day. Stockbit lists about a year back and what is announced ahead. One request per \ +kind, 1 s apart; answers are cached for 6 hours.", + after_help = "Examples:\n idx stocks calendar\n idx stocks calendar --kind dividend,rights\n idx stocks calendar --from 2026-12-01 --to 2026-12-31 --kind meeting" + )] + Calendar { + /// First day, YYYY-MM-DD. Default: today. + #[arg(long)] + from: Option, + /// Last day, YYYY-MM-DD. Default: 30 days after --from (at most 366). + #[arg(long)] + to: Option, + /// Kinds to list (default: all). + #[arg(long = "kind", value_enum, value_delimiter = ',', num_args = 1..)] + kinds: Vec, + }, #[command( about = "Get historical OHLC data", after_help = "Examples:\n idx stocks history BBCA --period 3mo\n idx stocks history BBCA --period 1y --interval 1wk" @@ -360,6 +398,27 @@ pub fn handle( book.offers.truncate(*depth); render_orderbook(&book, format, no_color) } + StocksSubcommand::Actions { symbol, kinds } => { + let kinds = if kinds.is_empty() { + ActionKind::STOCK_DEFAULT.to_vec() + } else { + kinds.clone() + }; + let actions = idx.corporate().actions(symbol, &kinds, policy)?; + let resolved = idx_core::api::resolve_symbol(symbol, &config.core.exchange)?; + render_corporate_actions(&resolved, &actions.data, format) + } + StocksSubcommand::Calendar { from, to, kinds } => { + let range = + CalendarRange::from_args(from.as_deref(), to.as_deref(), idx.corporate().today())?; + let kinds = if kinds.is_empty() { + ActionKind::ALL.to_vec() + } else { + kinds.clone() + }; + let actions = idx.corporate().calendar(range, &kinds, policy)?; + render_corporate_calendar(&range, &actions.data, format) + } StocksSubcommand::History { symbol, period, diff --git a/crates/idx-cli/src/output/mod.rs b/crates/idx-cli/src/output/mod.rs index ac13fc6..83dd257 100644 --- a/crates/idx-cli/src/output/mod.rs +++ b/crates/idx-cli/src/output/mod.rs @@ -19,6 +19,7 @@ use idx_core::api::types::{ }; use idx_core::broker::types::BrokerSummary; use idx_core::config::ProviderKind; +use idx_core::corporate::types::{CalendarRange, CorporateAction}; use idx_core::error::IdxError; use idx_core::flow::types::ForeignFlow; @@ -103,6 +104,28 @@ pub fn render_orderbook( } } +pub fn render_corporate_actions( + symbol: &str, + actions: &[CorporateAction], + format: &OutputFormat, +) -> Result<(), IdxError> { + match format { + OutputFormat::Table => table::print_corporate_actions(symbol, actions), + OutputFormat::Json | OutputFormat::Jsonl => json::print_json(actions), + } +} + +pub fn render_corporate_calendar( + range: &CalendarRange, + actions: &[CorporateAction], + format: &OutputFormat, +) -> Result<(), IdxError> { + match format { + OutputFormat::Table => table::print_corporate_calendar(range, actions), + OutputFormat::Json | OutputFormat::Jsonl => json::print_json(actions), + } +} + pub fn render_broker_summary( summary: &BrokerSummary, format: &OutputFormat, diff --git a/crates/idx-cli/src/output/table.rs b/crates/idx-cli/src/output/table.rs index 9773fc8..994c454 100644 --- a/crates/idx-cli/src/output/table.rs +++ b/crates/idx-cli/src/output/table.rs @@ -15,6 +15,7 @@ use idx_core::api::types::{ Intraday, NewsItem, Ohlc, OrderBook, Quote, SentimentData, }; use idx_core::broker::types::{BrokerBoard, BrokerFlow, BrokerInvestor, BrokerKind, BrokerSummary}; +use idx_core::corporate::types::{ActionKind, CalendarRange, CorporateAction, DateRange}; use idx_core::error::IdxError; use idx_core::flow::types::{FlowSource, ForeignFlow}; @@ -1670,6 +1671,190 @@ outside the regular board (negotiated and cash)." ); } +fn action_kind_label(kind: ActionKind) -> &'static str { + match kind { + ActionKind::Dividend => "dividend", + ActionKind::StockDividend => "stock dividend", + ActionKind::Bonus => "bonus", + ActionKind::Rights => "rights", + ActionKind::Warrant => "warrant", + ActionKind::Split => "split", + ActionKind::ReverseSplit => "reverse split", + ActionKind::Meeting => "meeting", + ActionKind::PublicExpose => "public expose", + ActionKind::Ipo => "IPO", + ActionKind::TenderOffer => "tender offer", + } +} + +/// IDR with thousands separators and up to two decimals: `1,191.09`, `3.8`. +fn format_rupiah(value: f64) -> String { + let cents = (value * 100.0).round() as i64; + let (whole, frac) = (cents / 100, (cents % 100).abs()); + match frac { + 0 => format_idr(whole), + f if f % 10 == 0 => format!("{}.{}", format_idr(whole), f / 10), + f => format!("{}.{f:02}", format_idr(whole)), + } +} + +/// What an action gives or asks, in one line. +fn action_detail(action: &CorporateAction) -> String { + let span = |range: Option| range.map(|r| format!("{} to {}", r.start, r.end)); + let price = action.price.map(|p| format!("Rp {}", format_idr(p))); + let mut parts: Vec = Vec::new(); + match action.kind { + ActionKind::Dividend => { + parts.extend( + action + .cash_per_share + .map(|c| format!("Rp {} per share", format_rupiah(c))), + ); + } + ActionKind::StockDividend | ActionKind::Bonus => { + parts.extend( + action + .ratio + .map(|r| format!("{} new per {} held", format_u64(r.new), format_u64(r.old))), + ); + } + ActionKind::Split | ActionKind::ReverseSplit => { + parts.extend( + action + .ratio + .map(|r| format!("{} becomes {}", format_u64(r.old), format_u64(r.new))), + ); + } + ActionKind::Rights => { + parts.extend(action.ratio.map(|r| { + format!( + "{} rights per {} held", + format_u64(r.new), + format_u64(r.old) + ) + })); + parts.extend(price.map(|p| format!("at {p}"))); + parts.extend(span(action.period).map(|s| format!("trading {s}"))); + } + ActionKind::Warrant => { + parts.extend(price.map(|p| format!("exercise at {p}"))); + parts.extend(span(action.exercise).map(|s| format!("exercisable {s}"))); + parts.extend(action.period.map(|r| format!("trades until {}", r.end))); + } + ActionKind::Meeting | ActionKind::PublicExpose => { + parts.extend( + action + .time + .as_deref() + .map(|t| format!("{} WIB", terminal_safe(t))), + ); + parts.extend( + action + .venue + .as_deref() + .map(|v| truncate_chars(&terminal_safe(v), 60)), + ); + } + ActionKind::Ipo => { + parts.extend(price); + parts.extend(action.shares.map(|s| format!("{} shares", format_u64(s)))); + parts.extend(span(action.period).map(|s| format!("offered {s}"))); + } + ActionKind::TenderOffer => { + parts.extend(price); + parts.extend(action.shares.map(|s| { + let share = action + .percentage_bps + .map(|bps| format!(" ({}.{:02}%)", bps / 100, bps % 100)) + .unwrap_or_default(); + format!("for {} shares{share}", format_u64(s)) + })); + parts.extend(span(action.period).map(|s| format!("open {s}"))); + } + } + if parts.is_empty() { + "-".to_string() + } else { + parts.join(", ") + } +} + +const CORPORATE_DATE_NOTE: &str = "DATE is the cum date for dividends, bonuses, rights and \ +splits (buy by that day to be entitled); for other actions, the event's first day."; + +fn opt_date(date: Option) -> String { + date.map(|d| d.to_string()) + .unwrap_or_else(|| "-".to_string()) +} + +pub fn print_corporate_actions(symbol: &str, actions: &[CorporateAction]) -> Result<(), IdxError> { + println!( + "{}", + format!("Corporate actions for {}", terminal_safe(symbol)).bold() + ); + if actions.is_empty() { + println!("None of these kinds on record."); + } else { + let mut table = Table::new(); + table + .load_preset(UTF8_FULL) + .set_content_arrangement(ContentArrangement::Dynamic) + .set_header(vec!["DATE", "KIND", "EX", "RECORD", "PAY", "DETAIL"]); + for action in actions { + table.add_row(vec![ + cell(action.date), + cell(action_kind_label(action.kind)), + cell(opt_date(action.ex_date)), + cell(opt_date(action.record_date)), + cell(opt_date(action.pay_date)), + cell(action_detail(action)), + ]); + } + println!("{table}"); + println!("{CORPORATE_DATE_NOTE}"); + } + println!("{STOCKBIT_SESSION_NOTE}"); + Ok(()) +} + +pub fn print_corporate_calendar( + range: &CalendarRange, + actions: &[CorporateAction], +) -> Result<(), IdxError> { + println!( + "{}", + format!( + "Corporate actions from {} to {} ({})", + range.from, + range.to, + actions.len() + ) + .bold() + ); + if actions.is_empty() { + println!("None of these kinds in that range."); + } else { + let mut table = Table::new(); + table + .load_preset(UTF8_FULL) + .set_content_arrangement(ContentArrangement::Dynamic) + .set_header(vec!["DATE", "SYMBOL", "KIND", "EX", "DETAIL"]); + for action in actions { + table.add_row(vec![ + cell(action.date), + cell(action.symbol.trim_end_matches(".JK")), + cell(action_kind_label(action.kind)), + cell(opt_date(action.ex_date)), + cell(action_detail(action)), + ]); + } + println!("{table}"); + println!("{CORPORATE_DATE_NOTE}"); + } + println!("{STOCKBIT_SESSION_NOTE}"); + Ok(()) +} + #[cfg(test)] mod tests { use super::{ diff --git a/crates/idx-cli/tests/golden/cases.toml b/crates/idx-cli/tests/golden/cases.toml index ded196e..942f618 100644 --- a/crates/idx-cli/tests/golden/cases.toml +++ b/crates/idx-cli/tests/golden/cases.toml @@ -285,6 +285,30 @@ env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0OD name = "stockbit-status-logged-out" args = ["stockbit", "status"] +# Corporate actions: BBCA's recorded dividends, splits, meetings and exposes +# (no fixture for a kind means none, as Stockbit answers); the calendar reads +# the market-wide recordings of 2026-11-03. + +[[case]] +name = "stockbit-actions" +args = ["stocks", "actions", "BBCA", "--kind", "split,meeting,expose"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln" } + +[[case]] +name = "stockbit-actions-dividends" +args = ["stocks", "actions", "BBCA", "--kind", "dividend"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln" } + +[[case]] +name = "stockbit-calendar" +args = ["stocks", "calendar", "--to", "2026-11-12", "--kind", "dividend,bonus,rights,warrant,split,ipo,tender"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln", IDX_MOCK_TODAY = "2026-11-03" } + +[[case]] +name = "stockbit-calendar-meetings" +args = ["stocks", "calendar", "--from", "2026-11-05", "--to", "2026-11-06", "--kind", "meeting,expose"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln", IDX_MOCK_TODAY = "2026-11-03" } + # --- stocks: broker summaries (IPOT) and foreign flow (IDX) -------------------- [[case]] @@ -392,6 +416,15 @@ args = ["--provider", "stockbit", "stocks", "fundamental", "BBCA"] name = "error-orderbook-no-session" args = ["stocks", "orderbook", "BBCA"] +[[case]] +name = "error-actions-no-session" +args = ["stocks", "actions", "BBCA"] + +[[case]] +name = "error-calendar-range" +args = ["stocks", "calendar", "--from", "2026-11-10", "--to", "2026-11-01"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln", IDX_MOCK_TODAY = "2026-11-03" } + [[case]] name = "error-stockbit-history-window" args = ["stocks", "history", "BBCA", "--period", "5y", "--history-provider", "stockbit"] diff --git a/crates/idx-cli/tests/golden/completions-bash.golden b/crates/idx-cli/tests/golden/completions-bash.golden index bd541ff..603c3e0 100644 --- a/crates/idx-cli/tests/golden/completions-bash.golden +++ b/crates/idx-cli/tests/golden/completions-bash.golden @@ -189,12 +189,18 @@ _idx() { idx__help__stockbit,status) cmd="idx__help__stockbit__status" ;; + idx__help__stocks,actions) + cmd="idx__help__stocks__actions" + ;; idx__help__stocks,bandar) cmd="idx__help__stocks__bandar" ;; idx__help__stocks,broker) cmd="idx__help__stocks__broker" ;; + idx__help__stocks,calendar) + cmd="idx__help__stocks__calendar" + ;; idx__help__stocks,compare) cmd="idx__help__stocks__compare" ;; @@ -390,12 +396,18 @@ _idx() { idx__stockbit__help,status) cmd="idx__stockbit__help__status" ;; + idx__stocks,actions) + cmd="idx__stocks__actions" + ;; idx__stocks,bandar) cmd="idx__stocks__bandar" ;; idx__stocks,broker) cmd="idx__stocks__broker" ;; + idx__stocks,calendar) + cmd="idx__stocks__calendar" + ;; idx__stocks,compare) cmd="idx__stocks__compare" ;; @@ -453,12 +465,18 @@ _idx() { idx__stocks,valuation) cmd="idx__stocks__valuation" ;; + idx__stocks__help,actions) + cmd="idx__stocks__help__actions" + ;; idx__stocks__help,bandar) cmd="idx__stocks__help__bandar" ;; idx__stocks__help,broker) cmd="idx__stocks__help__broker" ;; + idx__stocks__help,calendar) + cmd="idx__stocks__help__calendar" + ;; idx__stocks__help,compare) cmd="idx__stocks__help__compare" ;; @@ -1371,7 +1389,7 @@ _idx() { return 0 ;; idx__help__stocks) - opts="quote intraday orderbook history technical growth valuation risk fundamental broker bandar flow profile financials earnings sentiment insights news screen compare" + opts="quote intraday orderbook actions calendar history technical growth valuation risk fundamental broker bandar flow profile financials earnings sentiment insights news screen compare" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1384,6 +1402,20 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__help__stocks__actions) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__help__stocks__bandar) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then @@ -1412,6 +1444,20 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__help__stocks__calendar) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__help__stocks__compare) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then @@ -2689,7 +2735,7 @@ _idx() { return 0 ;; idx__stocks) - opts="-o -q -v -h --output --no-color --quiet --verbose --provider --offline --no-cache --help quote intraday orderbook history technical growth valuation risk fundamental broker bandar flow profile financials earnings sentiment insights news screen compare help" + opts="-o -q -v -h --output --no-color --quiet --verbose --provider --offline --no-cache --help quote intraday orderbook actions calendar history technical growth valuation risk fundamental broker bandar flow profile financials earnings sentiment insights news screen compare help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2714,6 +2760,36 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__stocks__actions) + opts="-o -q -v -h --kind --output --no-color --quiet --verbose --provider --offline --no-cache --help " + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --kind) + COMPREPLY=($(compgen -W "dividend stock-dividend bonus rights warrant split reverse-split meeting expose ipo tender" -- "${cur}")) + return 0 + ;; + --output) + COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}")) + return 0 + ;; + -o) + COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}")) + return 0 + ;; + --provider) + COMPREPLY=($(compgen -W "yahoo msn stockbit" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__stocks__bandar) opts="-o -q -v -h --date --from --to --investor --board --top --output --no-color --quiet --verbose --provider --offline --no-cache --help ..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -2810,6 +2886,44 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__stocks__calendar) + opts="-o -q -v -h --from --to --kind --output --no-color --quiet --verbose --provider --offline --no-cache --help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --from) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --to) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --kind) + COMPREPLY=($(compgen -W "dividend stock-dividend bonus rights warrant split reverse-split meeting expose ipo tender" -- "${cur}")) + return 0 + ;; + --output) + COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}")) + return 0 + ;; + -o) + COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}")) + return 0 + ;; + --provider) + COMPREPLY=($(compgen -W "yahoo msn stockbit" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__stocks__compare) opts="-o -q -v -h --output --no-color --quiet --verbose --provider --offline --no-cache --help ..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -2987,7 +3101,7 @@ _idx() { return 0 ;; idx__stocks__help) - opts="quote intraday orderbook history technical growth valuation risk fundamental broker bandar flow profile financials earnings sentiment insights news screen compare help" + opts="quote intraday orderbook actions calendar history technical growth valuation risk fundamental broker bandar flow profile financials earnings sentiment insights news screen compare help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3000,6 +3114,20 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__stocks__help__actions) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__stocks__help__bandar) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then @@ -3028,6 +3156,20 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__stocks__help__calendar) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__stocks__help__compare) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then diff --git a/crates/idx-cli/tests/golden/error-actions-no-session.json.golden b/crates/idx-cli/tests/golden/error-actions-no-session.json.golden new file mode 100644 index 0000000..d38ac26 --- /dev/null +++ b/crates/idx-cli/tests/golden/error-actions-no-session.json.golden @@ -0,0 +1,4 @@ +exit: 4 +--- stdout +--- stderr +{"code":"AUTHERROR","error":true,"message":"auth error: no Stockbit session; run `idx stockbit login` (or set IDX_STOCKBIT_REFRESH_TOKEN)"} diff --git a/crates/idx-cli/tests/golden/error-actions-no-session.table.golden b/crates/idx-cli/tests/golden/error-actions-no-session.table.golden new file mode 100644 index 0000000..e1fcda0 --- /dev/null +++ b/crates/idx-cli/tests/golden/error-actions-no-session.table.golden @@ -0,0 +1,4 @@ +exit: 4 +--- stdout +--- stderr +Error: auth error: no Stockbit session; run `idx stockbit login` (or set IDX_STOCKBIT_REFRESH_TOKEN) diff --git a/crates/idx-cli/tests/golden/error-calendar-range.json.golden b/crates/idx-cli/tests/golden/error-calendar-range.json.golden new file mode 100644 index 0000000..e6c9ad9 --- /dev/null +++ b/crates/idx-cli/tests/golden/error-calendar-range.json.golden @@ -0,0 +1,4 @@ +exit: 2 +--- stdout +--- stderr +{"code":"INVALIDINPUT","error":true,"message":"invalid input: to (2026-11-01) is before from (2026-11-10)"} diff --git a/crates/idx-cli/tests/golden/error-calendar-range.table.golden b/crates/idx-cli/tests/golden/error-calendar-range.table.golden new file mode 100644 index 0000000..3fc65af --- /dev/null +++ b/crates/idx-cli/tests/golden/error-calendar-range.table.golden @@ -0,0 +1,4 @@ +exit: 2 +--- stdout +--- stderr +Error: invalid input: to (2026-11-01) is before from (2026-11-10) diff --git a/crates/idx-cli/tests/golden/help-stocks.golden b/crates/idx-cli/tests/golden/help-stocks.golden index 5970553..e004151 100644 --- a/crates/idx-cli/tests/golden/help-stocks.golden +++ b/crates/idx-cli/tests/golden/help-stocks.golden @@ -8,6 +8,8 @@ Commands: quote Get real-time stock quotes intraday Today's session price by the minute (Stockbit) orderbook Order book depth and foreign flow (Stockbit login) + actions Dividends, rights, splits and other corporate actions of a stock (Stockbit login) + calendar Upcoming and recent corporate actions across the market (Stockbit login) history Get historical OHLC data technical Run technical analysis on a stock growth Run growth analysis on a stock diff --git a/crates/idx-cli/tests/golden/stockbit-actions-dividends.json.golden b/crates/idx-cli/tests/golden/stockbit-actions-dividends.json.golden new file mode 100644 index 0000000..3b6bd49 --- /dev/null +++ b/crates/idx-cli/tests/golden/stockbit-actions-dividends.json.golden @@ -0,0 +1,4 @@ +exit: 0 +--- stdout +[{"symbol":"BBCA.JK","kind":"dividend","date":"2026-08-28","cum_date":"2026-08-28","ex_date":"2026-08-31","record_date":"2026-09-01","pay_date":"2026-09-16","cash_per_share":25.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2026-06-15","cum_date":"2026-06-15","ex_date":"2026-06-17","record_date":"2026-06-18","pay_date":"2026-06-26","cash_per_share":20.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2026-03-27","cum_date":"2026-03-27","ex_date":"2026-03-30","record_date":"2026-03-31","pay_date":"2026-04-08","cash_per_share":281.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2025-12-02","cum_date":"2025-12-02","ex_date":"2025-12-03","record_date":"2025-12-04","pay_date":"2025-12-22","cash_per_share":55.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2025-03-20","cum_date":"2025-03-20","ex_date":"2025-03-21","record_date":"2025-03-24","pay_date":"2025-04-11","cash_per_share":250.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2024-11-20","cum_date":"2024-11-20","ex_date":"2024-11-21","record_date":"2024-11-22","pay_date":"2024-12-11","cash_per_share":50.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2024-03-22","cum_date":"2024-03-22","ex_date":"2024-03-25","record_date":"2024-03-26","pay_date":"2024-04-04","cash_per_share":227.5},{"symbol":"BBCA.JK","kind":"dividend","date":"2023-12-01","cum_date":"2023-12-01","ex_date":"2023-12-04","record_date":"2023-12-05","pay_date":"2023-12-20","cash_per_share":42.5},{"symbol":"BBCA.JK","kind":"dividend","date":"2023-03-28","cum_date":"2023-03-28","ex_date":"2023-03-29","record_date":"2023-03-30","pay_date":"2023-04-14","cash_per_share":170.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2022-12-01","cum_date":"2022-12-01","ex_date":"2022-12-02","record_date":"2022-12-05","pay_date":"2022-12-20","cash_per_share":35.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2022-03-25","cum_date":"2022-03-25","ex_date":"2022-03-28","record_date":"2022-03-29","pay_date":"2022-04-19","cash_per_share":120.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2021-11-16","cum_date":"2021-11-16","ex_date":"2021-11-17","record_date":"2021-11-18","pay_date":"2021-12-07","cash_per_share":25.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2021-04-07","cum_date":"2021-04-07","ex_date":"2021-04-08","record_date":"2021-04-09","pay_date":"2021-04-28","cash_per_share":432.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2020-12-07","cum_date":"2020-12-07","ex_date":"2020-12-08","record_date":"2020-12-10","pay_date":"2020-12-22","cash_per_share":98.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2020-04-20","cum_date":"2020-04-20","ex_date":"2020-04-21","record_date":"2020-04-22","pay_date":"2020-05-11","cash_per_share":455.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2019-12-05","cum_date":"2019-12-05","ex_date":"2019-12-06","record_date":"2019-12-09","pay_date":"2019-12-20","cash_per_share":100.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2019-04-23","cum_date":"2019-04-23","ex_date":"2019-04-24","record_date":"2019-04-25","pay_date":"2019-04-30","cash_per_share":255.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2018-11-30","cum_date":"2018-11-30","ex_date":"2018-12-03","record_date":"2018-12-04","pay_date":"2018-12-21","cash_per_share":85.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2018-04-12","cum_date":"2018-04-12","ex_date":"2018-04-13","record_date":"2018-04-17","pay_date":"2018-04-30","cash_per_share":175.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2017-11-28","cum_date":"2017-11-28","ex_date":"2017-11-29","record_date":"2017-12-04","pay_date":"2017-12-20","cash_per_share":80.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2017-04-13","cum_date":"2017-04-13","ex_date":"2017-04-17","record_date":"2017-04-20","pay_date":"2017-04-28","cash_per_share":130.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2016-11-30","cum_date":"2016-11-30","ex_date":"2016-12-01","record_date":"2016-12-05","pay_date":"2016-12-22","cash_per_share":70.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2016-04-14","cum_date":"2016-04-14","ex_date":"2016-04-15","record_date":"2016-04-19","pay_date":"2016-04-29","cash_per_share":105.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2015-11-12","cum_date":"2015-11-12","ex_date":"2015-11-13","record_date":"2015-11-17","pay_date":"2015-12-09","cash_per_share":55.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2015-04-16","cum_date":"2015-04-16","ex_date":"2015-04-17","record_date":"2015-04-21","pay_date":"2015-05-13","cash_per_share":98.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2014-12-04","cum_date":"2014-12-04","ex_date":"2014-12-05","record_date":"2014-12-09","pay_date":"2014-12-23","cash_per_share":50.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2014-04-29","cum_date":"2014-04-29","ex_date":"2014-04-30","record_date":"2014-05-05","pay_date":"2014-05-20","cash_per_share":75.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2013-11-28","cum_date":"2013-11-28","ex_date":"2013-11-29","record_date":"2013-12-03","pay_date":"2013-12-17","cash_per_share":45.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2013-05-28","cum_date":"2013-05-28","ex_date":"2013-05-29","record_date":"2013-05-31","pay_date":"2013-06-17","cash_per_share":71.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2012-12-03","cum_date":"2012-12-03","ex_date":"2012-12-04","record_date":"2012-12-06","pay_date":"2012-12-20","cash_per_share":43.5},{"symbol":"BBCA.JK","kind":"dividend","date":"2012-06-08","cum_date":"2012-06-08","ex_date":"2012-06-11","record_date":"2012-06-13","pay_date":"2012-06-27","cash_per_share":70.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2011-12-06","cum_date":"2011-12-06","ex_date":"2011-12-07","record_date":"2011-12-09","pay_date":"2011-12-23","cash_per_share":43.5},{"symbol":"BBCA.JK","kind":"dividend","date":"2011-06-06","cum_date":"2011-06-06","ex_date":"2011-06-07","record_date":"2011-06-09","pay_date":"2011-06-23","cash_per_share":70.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2010-11-19","cum_date":"2010-11-19","ex_date":"2010-11-22","record_date":"2010-11-24","pay_date":"2010-12-09","cash_per_share":42.5},{"symbol":"BBCA.JK","kind":"dividend","date":"2010-05-31","cum_date":"2010-05-31","ex_date":"2010-06-01","record_date":"2010-06-03","pay_date":"2010-06-17","cash_per_share":70.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2009-11-12","cum_date":"2009-11-12","ex_date":"2009-11-13","record_date":"2009-11-17","pay_date":"2009-12-02","cash_per_share":40.0},{"symbol":"BBCA.JK","kind":"dividend","date":"2009-06-09","cum_date":"2009-06-09","ex_date":"2009-06-10","record_date":"2009-06-12","pay_date":"2009-06-26","cash_per_share":65.0}] +--- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-actions-dividends.table.golden b/crates/idx-cli/tests/golden/stockbit-actions-dividends.table.golden new file mode 100644 index 0000000..85b4d46 --- /dev/null +++ b/crates/idx-cli/tests/golden/stockbit-actions-dividends.table.golden @@ -0,0 +1,83 @@ +exit: 0 +--- stdout +Corporate actions for BBCA.JK +┌────────────┬──────────┬────────────┬────────────┬────────────┬────────────────────┐ +│ DATE ┆ KIND ┆ EX ┆ RECORD ┆ PAY ┆ DETAIL │ +╞════════════╪══════════╪════════════╪════════════╪════════════╪════════════════════╡ +│ 2026-08-28 ┆ dividend ┆ 2026-08-31 ┆ 2026-09-01 ┆ 2026-09-16 ┆ Rp 25 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-06-15 ┆ dividend ┆ 2026-06-17 ┆ 2026-06-18 ┆ 2026-06-26 ┆ Rp 20 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-27 ┆ dividend ┆ 2026-03-30 ┆ 2026-03-31 ┆ 2026-04-08 ┆ Rp 281 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2025-12-02 ┆ dividend ┆ 2025-12-03 ┆ 2025-12-04 ┆ 2025-12-22 ┆ Rp 55 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2025-03-20 ┆ dividend ┆ 2025-03-21 ┆ 2025-03-24 ┆ 2025-04-11 ┆ Rp 250 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2024-11-20 ┆ dividend ┆ 2024-11-21 ┆ 2024-11-22 ┆ 2024-12-11 ┆ Rp 50 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2024-03-22 ┆ dividend ┆ 2024-03-25 ┆ 2024-03-26 ┆ 2024-04-04 ┆ Rp 227.5 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2023-12-01 ┆ dividend ┆ 2023-12-04 ┆ 2023-12-05 ┆ 2023-12-20 ┆ Rp 42.5 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2023-03-28 ┆ dividend ┆ 2023-03-29 ┆ 2023-03-30 ┆ 2023-04-14 ┆ Rp 170 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2022-12-01 ┆ dividend ┆ 2022-12-02 ┆ 2022-12-05 ┆ 2022-12-20 ┆ Rp 35 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2022-03-25 ┆ dividend ┆ 2022-03-28 ┆ 2022-03-29 ┆ 2022-04-19 ┆ Rp 120 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2021-11-16 ┆ dividend ┆ 2021-11-17 ┆ 2021-11-18 ┆ 2021-12-07 ┆ Rp 25 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2021-04-07 ┆ dividend ┆ 2021-04-08 ┆ 2021-04-09 ┆ 2021-04-28 ┆ Rp 432 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2020-12-07 ┆ dividend ┆ 2020-12-08 ┆ 2020-12-10 ┆ 2020-12-22 ┆ Rp 98 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2020-04-20 ┆ dividend ┆ 2020-04-21 ┆ 2020-04-22 ┆ 2020-05-11 ┆ Rp 455 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2019-12-05 ┆ dividend ┆ 2019-12-06 ┆ 2019-12-09 ┆ 2019-12-20 ┆ Rp 100 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2019-04-23 ┆ dividend ┆ 2019-04-24 ┆ 2019-04-25 ┆ 2019-04-30 ┆ Rp 255 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2018-11-30 ┆ dividend ┆ 2018-12-03 ┆ 2018-12-04 ┆ 2018-12-21 ┆ Rp 85 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2018-04-12 ┆ dividend ┆ 2018-04-13 ┆ 2018-04-17 ┆ 2018-04-30 ┆ Rp 175 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2017-11-28 ┆ dividend ┆ 2017-11-29 ┆ 2017-12-04 ┆ 2017-12-20 ┆ Rp 80 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2017-04-13 ┆ dividend ┆ 2017-04-17 ┆ 2017-04-20 ┆ 2017-04-28 ┆ Rp 130 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2016-11-30 ┆ dividend ┆ 2016-12-01 ┆ 2016-12-05 ┆ 2016-12-22 ┆ Rp 70 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2016-04-14 ┆ dividend ┆ 2016-04-15 ┆ 2016-04-19 ┆ 2016-04-29 ┆ Rp 105 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2015-11-12 ┆ dividend ┆ 2015-11-13 ┆ 2015-11-17 ┆ 2015-12-09 ┆ Rp 55 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2015-04-16 ┆ dividend ┆ 2015-04-17 ┆ 2015-04-21 ┆ 2015-05-13 ┆ Rp 98 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2014-12-04 ┆ dividend ┆ 2014-12-05 ┆ 2014-12-09 ┆ 2014-12-23 ┆ Rp 50 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2014-04-29 ┆ dividend ┆ 2014-04-30 ┆ 2014-05-05 ┆ 2014-05-20 ┆ Rp 75 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2013-11-28 ┆ dividend ┆ 2013-11-29 ┆ 2013-12-03 ┆ 2013-12-17 ┆ Rp 45 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2013-05-28 ┆ dividend ┆ 2013-05-29 ┆ 2013-05-31 ┆ 2013-06-17 ┆ Rp 71 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2012-12-03 ┆ dividend ┆ 2012-12-04 ┆ 2012-12-06 ┆ 2012-12-20 ┆ Rp 43.5 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2012-06-08 ┆ dividend ┆ 2012-06-11 ┆ 2012-06-13 ┆ 2012-06-27 ┆ Rp 70 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2011-12-06 ┆ dividend ┆ 2011-12-07 ┆ 2011-12-09 ┆ 2011-12-23 ┆ Rp 43.5 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2011-06-06 ┆ dividend ┆ 2011-06-07 ┆ 2011-06-09 ┆ 2011-06-23 ┆ Rp 70 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2010-11-19 ┆ dividend ┆ 2010-11-22 ┆ 2010-11-24 ┆ 2010-12-09 ┆ Rp 42.5 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2010-05-31 ┆ dividend ┆ 2010-06-01 ┆ 2010-06-03 ┆ 2010-06-17 ┆ Rp 70 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2009-11-12 ┆ dividend ┆ 2009-11-13 ┆ 2009-11-17 ┆ 2009-12-02 ┆ Rp 40 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2009-06-09 ┆ dividend ┆ 2009-06-10 ┆ 2009-06-12 ┆ 2009-06-26 ┆ Rp 65 per share │ +└────────────┴──────────┴────────────┴────────────┴────────────┴────────────────────┘ +DATE is the cum date for dividends, bonuses, rights and splits (buy by that day to be entitled); for other actions, the event's first day. +Source: your Stockbit session; for personal, non-commercial use (Stockbit's terms). +--- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-actions.json.golden b/crates/idx-cli/tests/golden/stockbit-actions.json.golden new file mode 100644 index 0000000..d5f9ad6 --- /dev/null +++ b/crates/idx-cli/tests/golden/stockbit-actions.json.golden @@ -0,0 +1,4 @@ +exit: 0 +--- stdout +[{"symbol":"BBCA.JK","kind":"public_expose","date":"2026-09-09","time":"16:00","venue":"Public Expose Live 2026 yang tercantum pada website idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2026-03-12","record_date":"2026-02-09","time":"14:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta 10310"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2025-09-11","time":"16:00","venue":"Public Expose Live 2025 yang tercantum pada website idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2025-03-12","record_date":"2025-02-07","time":"09:30","venue":"Menara BCA, Grand Indonesia, Jl. M.H. Thamrin No. 1, Jakarta, 10310"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2024-08-28","time":"15:00","venue":"Public Expose Live 2024 Informasi Jadwal Pubex Live 2024 dan pendaftaran peserta di website www.idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2024-03-14","record_date":"2024-02-07","time":"09:30","venue":"Menara BCA Grand Indonesia Lt 18.Jl. MH Thamrin No 1 Jakarta Selatan"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2023-11-29","time":"10:00","venue":"Public Expose Live 2023"},{"symbol":"BBCA.JK","kind":"meeting","date":"2023-03-16","record_date":"2023-02-13","time":"09:30","venue":"Menara BCA"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2022-09-14","time":"10:00","venue":"Public Expose Live 2022"},{"symbol":"BBCA.JK","kind":"meeting","date":"2022-03-17","record_date":"2022-02-14","time":"09:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta"},{"symbol":"BBCA.JK","kind":"split","date":"2021-10-12","cum_date":"2021-10-12","ex_date":"2021-10-13","record_date":"2021-10-14","ratio":{"old":1,"new":5},"factor":5.0},{"symbol":"BBCA.JK","kind":"meeting","date":"2021-09-23","record_date":"2021-08-27","time":"10:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2021-09-08","time":"15:00","venue":"Public Expose Live 2021"},{"symbol":"BBCA.JK","kind":"meeting","date":"2021-03-29","record_date":"2021-02-24","time":"09:00","venue":"Menara BCA, Grand Indonesia, Lt 19. Jl. M.H Thamrin No 1. Jakarta"},{"symbol":"BBCA.JK","kind":"meeting","date":"2020-07-30","record_date":"2020-07-03","time":"10:00","venue":"Menara BCA Grand Indonesia, Lt. 19. Jl. M.H. Thamrin No. 1. Jakarta"},{"symbol":"BBCA.JK","kind":"split","date":"2008-01-25","cum_date":"2008-01-25","ex_date":"2008-01-28","record_date":"2008-01-30","ratio":{"old":1,"new":2},"factor":2.0},{"symbol":"BBCA.JK","kind":"split","date":"2004-06-07","cum_date":"2004-06-07","ex_date":"2004-06-08","record_date":"2004-06-10","ratio":{"old":1,"new":2},"factor":2.0}] +--- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-actions.table.golden b/crates/idx-cli/tests/golden/stockbit-actions.table.golden new file mode 100644 index 0000000..c7ac018 --- /dev/null +++ b/crates/idx-cli/tests/golden/stockbit-actions.table.golden @@ -0,0 +1,43 @@ +exit: 0 +--- stdout +Corporate actions for BBCA.JK +┌────────────┬───────────────┬────────────┬────────────┬─────┬────────────────────────────────────────────────────────────────────────────┐ +│ DATE ┆ KIND ┆ EX ┆ RECORD ┆ PAY ┆ DETAIL │ +╞════════════╪═══════════════╪════════════╪════════════╪═════╪════════════════════════════════════════════════════════════════════════════╡ +│ 2026-09-09 ┆ public expose ┆ - ┆ - ┆ - ┆ 16:00 WIB, Public Expose Live 2026 yang tercantum pada website idx.co.i... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-12 ┆ meeting ┆ - ┆ 2026-02-09 ┆ - ┆ 14:00 WIB, Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta 1... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2025-09-11 ┆ public expose ┆ - ┆ - ┆ - ┆ 16:00 WIB, Public Expose Live 2025 yang tercantum pada website idx.co.i... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2025-03-12 ┆ meeting ┆ - ┆ 2025-02-07 ┆ - ┆ 09:30 WIB, Menara BCA, Grand Indonesia, Jl. M.H. Thamrin No. 1, Jakarta... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2024-08-28 ┆ public expose ┆ - ┆ - ┆ - ┆ 15:00 WIB, Public Expose Live 2024 Informasi Jadwal Pubex Live 2024 dan... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2024-03-14 ┆ meeting ┆ - ┆ 2024-02-07 ┆ - ┆ 09:30 WIB, Menara BCA Grand Indonesia Lt 18.Jl. MH Thamrin No 1 Jakarta... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2023-11-29 ┆ public expose ┆ - ┆ - ┆ - ┆ 10:00 WIB, Public Expose Live 2023 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2023-03-16 ┆ meeting ┆ - ┆ 2023-02-13 ┆ - ┆ 09:30 WIB, Menara BCA │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2022-09-14 ┆ public expose ┆ - ┆ - ┆ - ┆ 10:00 WIB, Public Expose Live 2022 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2022-03-17 ┆ meeting ┆ - ┆ 2022-02-14 ┆ - ┆ 09:00 WIB, Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2021-10-12 ┆ split ┆ 2021-10-13 ┆ 2021-10-14 ┆ - ┆ 1 becomes 5 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2021-09-23 ┆ meeting ┆ - ┆ 2021-08-27 ┆ - ┆ 10:00 WIB, Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2021-09-08 ┆ public expose ┆ - ┆ - ┆ - ┆ 15:00 WIB, Public Expose Live 2021 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2021-03-29 ┆ meeting ┆ - ┆ 2021-02-24 ┆ - ┆ 09:00 WIB, Menara BCA, Grand Indonesia, Lt 19. Jl. M.H Thamrin No 1. Ja... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2020-07-30 ┆ meeting ┆ - ┆ 2020-07-03 ┆ - ┆ 10:00 WIB, Menara BCA Grand Indonesia, Lt. 19. Jl. M.H. Thamrin No. 1. ... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2008-01-25 ┆ split ┆ 2008-01-28 ┆ 2008-01-30 ┆ - ┆ 1 becomes 2 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2004-06-07 ┆ split ┆ 2004-06-08 ┆ 2004-06-10 ┆ - ┆ 1 becomes 2 │ +└────────────┴───────────────┴────────────┴────────────┴─────┴────────────────────────────────────────────────────────────────────────────┘ +DATE is the cum date for dividends, bonuses, rights and splits (buy by that day to be entitled); for other actions, the event's first day. +Source: your Stockbit session; for personal, non-commercial use (Stockbit's terms). +--- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-calendar-meetings.json.golden b/crates/idx-cli/tests/golden/stockbit-calendar-meetings.json.golden new file mode 100644 index 0000000..28caa37 --- /dev/null +++ b/crates/idx-cli/tests/golden/stockbit-calendar-meetings.json.golden @@ -0,0 +1,4 @@ +exit: 0 +--- stdout +[{"symbol":"AUTO.JK","kind":"public_expose","date":"2026-11-05","time":"10:00","venue":"Zoom Webinar"},{"symbol":"BATA.JK","kind":"meeting","date":"2026-11-05","record_date":"2026-10-09","time":"14:00","venue":"Gedung Ventura, lantai 7. Jl. Raden Ajeng Kartini No.26, Cilandak Barat, Jakarta Selatan"},{"symbol":"AMAG.JK","kind":"public_expose","date":"2026-11-06","time":"15:00","venue":"Virtual Zoom Webinar, di PT Asuransi Multi Artha Guna Tbk, Gedung TCC Batavia Tower One, Jalan KH Mas Mansyur Kav 126, Jakarta Pusat"},{"symbol":"BRIS.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"10:00","venue":"Jakarta Pusat, melalui fasilitas Electronic General Meeting System KSEI (eASY.KSEI) dalam tautan https//akses.ksei.co.id"},{"symbol":"GIAA.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"14:00","venue":"Secara elektronik melalui sistem eASY.KSEI (https//akses.ksei.co.id/)"},{"symbol":"INPS.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-07","time":"14:00","venue":"Gedung Inprase, Jl. Sunter Garden Raya Blok D8 No. 3G-3H, Sunter Agung, Tanjung Priok, Jakarta Utara, DKI Jakarta 14350"},{"symbol":"KDTN.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"14:00","venue":"PT Puri Sentul Permai Tbk diumumkan dan sesuai iklan)"},{"symbol":"MTFN.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"10:00","venue":"Kantor Taman E3.3, Unit D3A, Lantai 5, Jl. DR. Ide Anak Agung Gde Agung, Kuningan Jakarta Selatan"},{"symbol":"MTFN.JK","kind":"public_expose","date":"2026-11-06","time":"11:00","venue":"Kantor Taman E3.3, Unit D3A, Lantai 5 Jl. DR. Ide Anak Agung Gde Agung, Kuningan Jakarta Selatan"},{"symbol":"ULTJ.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-08-31","time":"10:00","venue":"Kantor Perseroan, Jalan Raya Cimareme No 131 Bandung Barat, Jawa Barat Indonesia"}] +--- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-calendar-meetings.table.golden b/crates/idx-cli/tests/golden/stockbit-calendar-meetings.table.golden new file mode 100644 index 0000000..e48c3b5 --- /dev/null +++ b/crates/idx-cli/tests/golden/stockbit-calendar-meetings.table.golden @@ -0,0 +1,29 @@ +exit: 0 +--- stdout +Corporate actions from 2026-11-05 to 2026-11-06 (10) +┌────────────┬────────┬───────────────┬────┬────────────────────────────────────────────────────────────────────────────┐ +│ DATE ┆ SYMBOL ┆ KIND ┆ EX ┆ DETAIL │ +╞════════════╪════════╪═══════════════╪════╪════════════════════════════════════════════════════════════════════════════╡ +│ 2026-11-05 ┆ AUTO ┆ public expose ┆ - ┆ 10:00 WIB, Zoom Webinar │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-05 ┆ BATA ┆ meeting ┆ - ┆ 14:00 WIB, Gedung Ventura, lantai 7. Jl. Raden Ajeng Kartini No.26, Cil... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ AMAG ┆ public expose ┆ - ┆ 15:00 WIB, Virtual Zoom Webinar, di PT Asuransi Multi Artha Guna Tbk, G... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ BRIS ┆ meeting ┆ - ┆ 10:00 WIB, Jakarta Pusat, melalui fasilitas Electronic General Meeting ... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ GIAA ┆ meeting ┆ - ┆ 14:00 WIB, Secara elektronik melalui sistem eASY.KSEI (https//akses.kse... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ INPS ┆ meeting ┆ - ┆ 14:00 WIB, Gedung Inprase, Jl. Sunter Garden Raya Blok D8 No. 3G-3H, Su... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ KDTN ┆ meeting ┆ - ┆ 14:00 WIB, PT Puri Sentul Permai Tbk diumumkan dan sesuai iklan) │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ MTFN ┆ meeting ┆ - ┆ 10:00 WIB, Kantor Taman E3.3, Unit D3A, Lantai 5, Jl. DR. Ide Anak Agun... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ MTFN ┆ public expose ┆ - ┆ 11:00 WIB, Kantor Taman E3.3, Unit D3A, Lantai 5 Jl. DR. Ide Anak Agung... │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ ULTJ ┆ meeting ┆ - ┆ 10:00 WIB, Kantor Perseroan, Jalan Raya Cimareme No 131 Bandung Barat, ... │ +└────────────┴────────┴───────────────┴────┴────────────────────────────────────────────────────────────────────────────┘ +DATE is the cum date for dividends, bonuses, rights and splits (buy by that day to be entitled); for other actions, the event's first day. +Source: your Stockbit session; for personal, non-commercial use (Stockbit's terms). +--- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-calendar.json.golden b/crates/idx-cli/tests/golden/stockbit-calendar.json.golden new file mode 100644 index 0000000..7455de0 --- /dev/null +++ b/crates/idx-cli/tests/golden/stockbit-calendar.json.golden @@ -0,0 +1,4 @@ +exit: 0 +--- stdout +[{"symbol":"MGLV.JK","kind":"rights","date":"2026-11-04","cum_date":"2026-11-04","ex_date":"2026-11-05","record_date":"2026-11-06","ratio":{"old":100,"new":15},"factor":1.15,"price":8880,"period":{"start":"2026-11-10","end":"2026-11-23"}},{"symbol":"JPFA.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-12","cash_per_share":90.0},{"symbol":"PTPS.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-18","cash_per_share":2.0},{"symbol":"UNTR.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-23","cash_per_share":430.0},{"symbol":"CNMA.JK","kind":"dividend","date":"2026-11-06","cum_date":"2026-11-06","ex_date":"2026-11-09","record_date":"2026-11-10","pay_date":"2026-11-19","cash_per_share":4.0},{"symbol":"SMSM.JK","kind":"dividend","date":"2026-11-09","cum_date":"2026-11-09","ex_date":"2026-11-10","record_date":"2026-11-11","pay_date":"2026-11-26","cash_per_share":45.0},{"symbol":"AVIA.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-19","cash_per_share":12.0},{"symbol":"BWPT.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-25","cash_per_share":1.0},{"symbol":"ITMG.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-18","cash_per_share":1191.09},{"symbol":"MEDC.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-12-02","cash_per_share":21.65},{"symbol":"SSMS.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-12-02","cash_per_share":52.49},{"symbol":"TAPG.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-27","cash_per_share":70.0},{"symbol":"IFII.JK","kind":"dividend","date":"2026-11-11","cum_date":"2026-11-11","ex_date":"2026-11-12","record_date":"2026-11-13","pay_date":"2026-11-26","cash_per_share":5.0},{"symbol":"MIDI.JK","kind":"dividend","date":"2026-11-11","cum_date":"2026-11-11","ex_date":"2026-11-12","record_date":"2026-11-13","pay_date":"2026-12-01","cash_per_share":3.8}] +--- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-calendar.table.golden b/crates/idx-cli/tests/golden/stockbit-calendar.table.golden new file mode 100644 index 0000000..7eb5aba --- /dev/null +++ b/crates/idx-cli/tests/golden/stockbit-calendar.table.golden @@ -0,0 +1,37 @@ +exit: 0 +--- stdout +Corporate actions from 2026-11-03 to 2026-11-12 (14) +┌────────────┬────────┬──────────┬────────────┬───────────────────────────────────────────────────────────────────────┐ +│ DATE ┆ SYMBOL ┆ KIND ┆ EX ┆ DETAIL │ +╞════════════╪════════╪══════════╪════════════╪═══════════════════════════════════════════════════════════════════════╡ +│ 2026-11-04 ┆ MGLV ┆ rights ┆ 2026-11-05 ┆ 15 rights per 100 held, at Rp 8,880, trading 2026-11-10 to 2026-11-23 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-05 ┆ JPFA ┆ dividend ┆ 2026-11-06 ┆ Rp 90 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-05 ┆ PTPS ┆ dividend ┆ 2026-11-06 ┆ Rp 2 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-05 ┆ UNTR ┆ dividend ┆ 2026-11-06 ┆ Rp 430 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ CNMA ┆ dividend ┆ 2026-11-09 ┆ Rp 4 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-09 ┆ SMSM ┆ dividend ┆ 2026-11-10 ┆ Rp 45 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ AVIA ┆ dividend ┆ 2026-11-11 ┆ Rp 12 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ BWPT ┆ dividend ┆ 2026-11-11 ┆ Rp 1 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ ITMG ┆ dividend ┆ 2026-11-11 ┆ Rp 1,191.09 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ MEDC ┆ dividend ┆ 2026-11-11 ┆ Rp 21.65 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ SSMS ┆ dividend ┆ 2026-11-11 ┆ Rp 52.49 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ TAPG ┆ dividend ┆ 2026-11-11 ┆ Rp 70 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-11 ┆ IFII ┆ dividend ┆ 2026-11-12 ┆ Rp 5 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-11 ┆ MIDI ┆ dividend ┆ 2026-11-12 ┆ Rp 3.8 per share │ +└────────────┴────────┴──────────┴────────────┴───────────────────────────────────────────────────────────────────────┘ +DATE is the cum date for dividends, bonuses, rights and splits (buy by that day to be entitled); for other actions, the event's first day. +Source: your Stockbit session; for personal, non-commercial use (Stockbit's terms). +--- stderr diff --git a/crates/idx-core/src/api/mock.rs b/crates/idx-core/src/api/mock.rs index f392967..6a76d4d 100644 --- a/crates/idx-core/src/api/mock.rs +++ b/crates/idx-core/src/api/mock.rs @@ -1,14 +1,16 @@ //! Fixture-backed provider for tests, enabled by the `testing` feature and //! `IDX_USE_MOCK_PROVIDER`. Release builds do not contain it. -use super::stockbit::exodus; +use super::stockbit::{corpaction, exodus}; use super::types::{Bar, Fundamentals, Interval, Intraday, OrderBook, Period, Quote}; use super::{ - BrokerSummaryProvider, FundamentalsProvider, HistoryProvider, IntradayProvider, - OrderBookProvider, QuoteProvider, TradingSummaryProvider, idx, ipot, msn, stockbit, yahoo, + BrokerSummaryProvider, CorporateActionProvider, FundamentalsProvider, HistoryProvider, + IntradayProvider, OrderBookProvider, QuoteProvider, TradingSummaryProvider, idx, ipot, msn, + stockbit, yahoo, }; use crate::broker::types::{BrokerBoard, BrokerInvestor, BrokerQuery}; use crate::config::ProviderKind; +use crate::corporate::types::{ActionKind, CorporateAction}; use crate::error::IdxError; pub(crate) fn enabled() -> bool { @@ -224,6 +226,34 @@ impl OrderBookProvider for MockStockbitProvider { } } +/// `stockbit_exodus_corpaction_.json` for the market, +/// `...__.json` for one stock; a stock without a fixture has none +/// of that kind, as Stockbit answers. +impl CorporateActionProvider for MockStockbitProvider { + fn corporate_actions( + &self, + kind: ActionKind, + symbol: Option<&str>, + ) -> Result, IdxError> { + let subject = symbol.unwrap_or("corporate actions"); + let name = match symbol { + Some(symbol) => format!( + "corpaction_{}_{}.json", + corpaction::path_type(kind), + stockbit::stockbit_code(symbol)?.to_ascii_lowercase() + ), + None => format!("corpaction_{}.json", corpaction::path_type(kind)), + }; + let body = match self.exodus(subject, &name) { + Err(IdxError::SymbolNotFound(_)) if symbol.is_some() => { + r#"{"data":{"none":[]}}"#.to_string() + } + other => other?, + }; + corpaction::parse_corporate_actions(kind, &body) + } +} + impl HistoryProvider for MockStockbitProvider { fn history( &self, diff --git a/crates/idx-core/src/api/mod.rs b/crates/idx-core/src/api/mod.rs index ae9cd0f..b3fb07a 100644 --- a/crates/idx-core/src/api/mod.rs +++ b/crates/idx-core/src/api/mod.rs @@ -78,6 +78,17 @@ pub trait OrderBookProvider { fn orderbook(&self, symbol: &str) -> Result; } +/// Corporate actions of one kind: needs the user's Stockbit session. +pub trait CorporateActionProvider { + /// One stock's history (`symbol` resolved, e.g. `BBCA.JK`), or the + /// market's announced and recent actions with `None`. + fn corporate_actions( + &self, + kind: crate::corporate::types::ActionKind, + symbol: Option<&str>, + ) -> Result, IdxError>; +} + pub trait FundamentalsProvider { fn fundamentals(&self, symbol: &str) -> Result; } @@ -345,6 +356,14 @@ pub fn orderbook_provider() -> Box { Box::new(stockbit::StockbitProvider::new()) } +pub fn corporate_action_provider() -> Box { + #[cfg(feature = "testing")] + if mock::enabled() { + return Box::new(mock::MockStockbitProvider); + } + Box::new(stockbit::StockbitProvider::new()) +} + /// Today in WIB, the date IDX trades on. pub(crate) fn today_wib() -> chrono::NaiveDate { #[cfg(feature = "testing")] diff --git a/crates/idx-core/src/api/stockbit/corpaction.rs b/crates/idx-core/src/api/stockbit/corpaction.rs new file mode 100644 index 0000000..7dfb0f1 --- /dev/null +++ b/crates/idx-core/src/api/stockbit/corpaction.rs @@ -0,0 +1,405 @@ +//! Corporate actions from Stockbit's session API: +//! `GET /corpaction/{type}?symbol={CODE}` (one stock's history) or without +//! `symbol` (the market, about a year back and the announced ones ahead; the +//! `limit` the web app sends is not honoured by every type). +//! +//! Each type names its fields with its own prefix (`dividend_`, +//! `rightissue_`, `wrant_`, `rups_`, `puexp_`, `tender_`, ...), bonus rows +//! reuse `stocksplit_*`, and the list sits under a key that is not always the +//! path's (`tenderoffer` → `tender`, `reversesplit` → `stock_reverse`). So +//! the entitlement kinds are read by field suffix (`_cumdate`, `_exdate`, +//! ...), which also covers the two kinds no row was recorded for yet +//! (`stock_dividend`, `reversesplit`, both empty on 2026-11-03). Placeholders +//! (`""`, `0`, `0001-01-01 00:00:00`) read as absent; a row without a symbol +//! or a date is dropped. + +use chrono::{Datelike, NaiveDate}; +use serde_json::{Map, Value}; + +use crate::corporate::types::{ActionKind, CorporateAction, DateRange, Ratio}; +use crate::error::IdxError; + +/// Stockbit's path segment for `kind`. +pub fn path_type(kind: ActionKind) -> &'static str { + match kind { + ActionKind::Dividend => "dividend", + ActionKind::StockDividend => "stock_dividend", + ActionKind::Bonus => "bonus", + ActionKind::Rights => "rightissue", + ActionKind::Warrant => "warrant", + ActionKind::Split => "stocksplit", + ActionKind::ReverseSplit => "reversesplit", + ActionKind::Meeting => "rups", + ActionKind::PublicExpose => "pubex", + ActionKind::Ipo => "ipo", + ActionKind::TenderOffer => "tenderoffer", + } +} + +/// The actions of one `kind` in a `/corpaction/{type}` response, in the +/// response's order. +pub fn parse_corporate_actions( + kind: ActionKind, + body: &str, +) -> Result, IdxError> { + let bad = |what: String| IdxError::ParseError(format!("stockbit corporate actions: {what}")); + let root: Value = serde_json::from_str(body).map_err(|e| bad(e.to_string()))?; + let rows = match root.get("data") { + Some(Value::Object(data)) => match data.values().find_map(Value::as_array) { + Some(rows) => rows.as_slice(), + None if data.values().all(Value::is_null) => &[], + None => return Err(bad("no list in data".to_string())), + }, + Some(Value::Array(rows)) => rows.as_slice(), + Some(Value::Null) => &[], + _ => return Err(bad("no data".to_string())), + }; + Ok(rows + .iter() + .filter_map(Value::as_object) + .filter_map(|row| parse_row(kind, row)) + .collect()) +} + +fn parse_row(kind: ActionKind, row: &Map) -> Option { + let code = text(row.get("company_symbol"))?.to_ascii_uppercase(); + if !code.bytes().all(|b| b.is_ascii_alphanumeric()) { + return None; + } + let symbol = format!("{code}.JK"); + let mut action = if kind.is_entitlement() { + entitlement(kind, symbol, row)? + } else { + event(kind, symbol, row)? + }; + if matches!(kind, ActionKind::Ipo | ActionKind::TenderOffer) { + action.name = text(row.get("company_name")).map(str::to_string); + } + Some(action) +} + +/// Dividends, bonuses, rights and splits: cum/ex/record/pay dates, a ratio +/// and an adjustment factor. +fn entitlement( + kind: ActionKind, + symbol: String, + row: &Map, +) -> Option { + let cum = date(suffixed(row, "cumdate")); + let ex = date(suffixed(row, "exdate")); + let mut action = CorporateAction::new(symbol, kind, cum.or(ex)?); + action.cum_date = cum; + action.ex_date = ex; + action.record_date = date(suffixed(row, "recdate")); + action.pay_date = date(suffixed(row, "paydate")).or_else(|| date(suffixed(row, "paymentdate"))); + action.ratio = ratio(row); + action.factor = number(suffixed(row, "factor")); + match kind { + ActionKind::Dividend => { + action.cash_per_share = number(suffixed(row, "value")).map(|v| round_to(v, 2)); + } + ActionKind::Rights => { + action.price = whole(suffixed(row, "price")); + action.period = range(suffixed(row, "trading_start"), suffixed(row, "trading_end")); + } + _ => {} + } + Some(action) +} + +/// Warrants, meetings, exposes, IPOs and tender offers. +fn event(kind: ActionKind, symbol: String, row: &Map) -> Option { + let get = |key: &str| row.get(key); + let mut action; + match kind { + ActionKind::Warrant => { + let trading = range(get("wrant_trading_from"), get("wrant_trading_end")); + let exercise = range(get("wrant_exc_from"), get("wrant_exc_end")); + let first = date(get("wrant_trading_from")).or(exercise.map(|r| r.start))?; + action = CorporateAction::new(symbol, kind, first); + action.period = trading; + action.exercise = exercise; + action.price = whole(get("wrant_exc_price")); + } + ActionKind::Meeting | ActionKind::PublicExpose => { + let prefix = if kind == ActionKind::Meeting { + "rups" + } else { + "puexp" + }; + let field = |name: &str| row.get(&format!("{prefix}_{name}")); + action = CorporateAction::new(symbol, kind, date(field("date"))?); + action.time = text(field("time")).map(clock); + action.venue = text(field("venue")).map(squeeze); + if kind == ActionKind::Meeting { + action.record_date = date(field("eligible_date")); + } + } + ActionKind::Ipo => { + action = CorporateAction::new(symbol, kind, date(get("ipo_listing_date"))?); + action.price = whole(row.get("ipo_price").and_then(|p| p.get("final"))); + let detail = row.get("ipo_data_detail"); + let detail = |key: &str| detail.and_then(|d| d.get(key)); + action.shares = count(detail("shares")); + action.period = range(detail("offering_start"), detail("offering_end")); + } + ActionKind::TenderOffer => { + let period = range(get("tender_start"), get("tender_end")); + let first = date(get("tender_start")).or(date(get("tender_end")))?; + action = CorporateAction::new(symbol, kind, first); + action.period = period; + action.pay_date = date(get("tender_paydate")); + action.price = whole(get("tender_price")); + action.shares = count(get("tender_shares")); + action.percentage_bps = + number(get("tender_percentage")).map(|p| (p * 100.0).round() as i64); + } + _ => return None, + } + Some(action) +} + +/// The value of the one field named `_`; the shortest name +/// wins should several end so. +fn suffixed<'a>(row: &'a Map, suffix: &str) -> Option<&'a Value> { + let tail = format!("_{suffix}"); + row.iter() + .filter(|(key, _)| key.ends_with(&tail)) + .min_by_key(|(key, _)| key.len()) + .map(|(_, value)| value) +} + +/// `old`/`new` fields, else the `"6 : 4"` text. +fn ratio(row: &Map) -> Option { + let pair = |old: Option, new: Option| { + Some(Ratio { + old: old?, + new: new?, + }) + }; + pair(count(suffixed(row, "old")), count(suffixed(row, "new"))).or_else(|| { + let text = text(suffixed(row, "ratio"))?; + let (old, new) = text.split_once(':')?; + pair( + old.trim().replace(',', "").parse().ok().filter(|n| *n > 0), + new.trim().replace(',', "").parse().ok().filter(|n| *n > 0), + ) + }) +} + +fn text(value: Option<&Value>) -> Option<&str> { + value + .and_then(Value::as_str) + .map(str::trim) + .filter(|s| !s.is_empty()) +} + +/// `YYYY-MM-DD`, optionally followed by a time; year 1 is a placeholder. +fn date(value: Option<&Value>) -> Option { + let text = text(value)?; + let day = text.get(..10)?; + NaiveDate::parse_from_str(day, "%Y-%m-%d") + .ok() + .filter(|d| d.year() >= 1900) +} + +fn range(start: Option<&Value>, end: Option<&Value>) -> Option { + let (start, end) = (date(start)?, date(end)?); + (start <= end).then_some(DateRange { start, end }) +} + +/// A positive number from a JSON number or a display string (`"1,191.09"`, +/// `"Rp 25"`); zero is a placeholder. +fn number(value: Option<&Value>) -> Option { + let n = match value? { + Value::Number(n) => n.as_f64()?, + Value::String(s) => { + let cleaned: String = s + .trim() + .trim_start_matches("Rp") + .chars() + .filter(|c| *c != ',' && !c.is_whitespace()) + .collect(); + cleaned.parse().ok()? + } + _ => return None, + }; + (n.is_finite() && n > 0.0).then_some(n) +} + +fn whole(value: Option<&Value>) -> Option { + number(value).map(|n| n.round() as i64) +} + +fn count(value: Option<&Value>) -> Option { + number(value).map(|n| n.round() as u64) +} + +fn round_to(value: f64, places: i32) -> f64 { + let scale = 10f64.powi(places); + (value * scale).round() / scale +} + +/// `13:00:00` → `13:00`; anything else as given. +fn clock(raw: &str) -> String { + match raw.split(':').collect::>().as_slice() { + [h, m, s] if s.len() == 2 && h.len() <= 2 && m.len() == 2 => format!("{h}:{m}"), + _ => raw.to_string(), + } +} + +fn squeeze(raw: &str) -> String { + raw.split_whitespace().collect::>().join(" ") +} + +#[cfg(test)] +mod tests { + use super::*; + + fn fixture(name: &str) -> String { + std::fs::read_to_string(format!( + "{}/tests/fixtures/stockbit_exodus_corpaction_{name}.json", + env!("CARGO_MANIFEST_DIR") + )) + .unwrap() + } + + fn day(s: &str) -> NaiveDate { + NaiveDate::parse_from_str(s, "%Y-%m-%d").unwrap() + } + + fn find<'a>(actions: &'a [CorporateAction], symbol: &str) -> &'a CorporateAction { + actions.iter().find(|a| a.symbol == symbol).unwrap() + } + + #[test] + fn test_parse_dividends_keep_cents_and_dates() { + let bbca = + parse_corporate_actions(ActionKind::Dividend, &fixture("dividend_bbca")).unwrap(); + assert_eq!(bbca.len(), 37); + let latest = &bbca[0]; + assert_eq!(latest.symbol, "BBCA.JK"); + assert_eq!(latest.date, day("2026-08-28")); + assert_eq!( + (latest.ex_date, latest.record_date, latest.pay_date), + ( + Some(day("2026-08-31")), + Some(day("2026-09-01")), + Some(day("2026-09-16")) + ) + ); + assert_eq!(latest.cash_per_share, Some(25.0)); + assert_eq!(latest.ratio, None); + + let market = parse_corporate_actions(ActionKind::Dividend, &fixture("dividend")).unwrap(); + assert_eq!(find(&market, "ITMG.JK").cash_per_share, Some(1191.09)); + } + + #[test] + fn test_parse_bonus_reads_split_named_fields() { + let bonus = parse_corporate_actions(ActionKind::Bonus, &fixture("bonus")).unwrap(); + let ppgl = find(&bonus, "PPGL.JK"); + assert_eq!(ppgl.date, day("2026-11-02")); + assert_eq!(ppgl.ex_date, Some(day("2026-11-03"))); + assert_eq!(ppgl.pay_date, Some(day("2026-11-25"))); + assert_eq!(ppgl.ratio, Some(Ratio { old: 6, new: 4 })); + assert_eq!(ppgl.factor, Some(1.6667)); + } + + #[test] + fn test_parse_rights_and_split() { + let rights = parse_corporate_actions(ActionKind::Rights, &fixture("rightissue")).unwrap(); + let bmas = find(&rights, "BMAS.JK"); + assert_eq!(bmas.date, day("2026-11-23")); + assert_eq!(bmas.ratio, Some(Ratio { old: 655, new: 104 })); + assert_eq!(bmas.price, Some(350)); + assert_eq!( + bmas.period, + Some(DateRange { + start: day("2026-11-27"), + end: day("2026-12-03") + }) + ); + let split = + parse_corporate_actions(ActionKind::Split, &fixture("stocksplit_bbca")).unwrap(); + assert_eq!(split[0].date, day("2021-10-12")); + assert_eq!(split[0].ratio, Some(Ratio { old: 1, new: 5 })); + assert_eq!(split[0].factor, Some(5.0)); + } + + #[test] + fn test_parse_events() { + let warrants = parse_corporate_actions(ActionKind::Warrant, &fixture("warrant")).unwrap(); + let brna = find(&warrants, "BRNA.JK"); + assert_eq!(brna.date, day("2026-10-16")); + assert_eq!(brna.price, Some(800)); + assert_eq!(brna.exercise.map(|r| r.end), Some(day("2029-10-15"))); + + let meetings = parse_corporate_actions(ActionKind::Meeting, &fixture("rups")).unwrap(); + let arti = find(&meetings, "ARTI.JK"); + assert_eq!(arti.date, day("2026-12-09")); + assert_eq!(arti.time.as_deref(), Some("10:30")); + assert_eq!(arti.record_date, Some(day("2026-11-12"))); + + let exposes = parse_corporate_actions(ActionKind::PublicExpose, &fixture("pubex")).unwrap(); + assert_eq!(find(&exposes, "MEJA.JK").time.as_deref(), Some("13:00")); + + let tenders = + parse_corporate_actions(ActionKind::TenderOffer, &fixture("tenderoffer")).unwrap(); + let auto = find(&tenders, "AUTO.JK"); + assert_eq!(auto.date, day("2026-10-13")); + assert_eq!(auto.price, Some(3600)); + assert_eq!(auto.shares, Some(238_442_293)); + assert_eq!(auto.percentage_bps, Some(495)); + assert_eq!(auto.pay_date, Some(day("2026-11-18"))); + assert_eq!(auto.name.as_deref(), Some("Astra Otoparts Tbk.")); + } + + #[test] + fn test_parse_ipo_drops_placeholders() { + let ipos = parse_corporate_actions(ActionKind::Ipo, &fixture("ipo")).unwrap(); + let rans = find(&ipos, "RANS.JK"); + assert_eq!(rans.price, Some(170)); + assert_eq!(rans.shares, Some(2_525_000_000)); + assert_eq!(rans.period.map(|r| r.start), Some(day("2026-07-02"))); + // An ETF listed without offer terms: no price, no period. + let xkgs = find(&ipos, "XKGS.JK"); + assert_eq!((xkgs.price, xkgs.period, xkgs.shares), (None, None, None)); + } + + #[test] + fn test_parse_empty_lists_and_odd_keys() { + for (kind, body) in [ + ( + ActionKind::StockDividend, + r#"{"data":{"stock_dividend":[]}}"#, + ), + (ActionKind::ReverseSplit, r#"{"data":{"stock_reverse":[]}}"#), + (ActionKind::Dividend, r#"{"data":null}"#), + ] { + assert!(parse_corporate_actions(kind, body).unwrap().is_empty()); + } + assert!(parse_corporate_actions(ActionKind::Dividend, r#"{"message":"x"}"#).is_err()); + // A reverse split named like a split, read by suffix. + let body = r#"{"data":{"stock_reverse":[{"company_symbol":"ABCD", + "reverse_cumdate":"2026-12-01","reverse_exdate":"2026-12-02", + "reverse_old":"10","reverse_new":"1","reverse_factor":"0.1"}]}}"#; + let rows = parse_corporate_actions(ActionKind::ReverseSplit, body).unwrap(); + assert_eq!(rows[0].ratio, Some(Ratio { old: 10, new: 1 })); + assert_eq!(rows[0].factor, Some(0.1)); + } + + #[test] + fn test_parse_numbers_and_placeholders() { + assert_eq!(number(Some(&Value::from("1,191.09"))), Some(1191.09)); + assert_eq!(number(Some(&Value::from("Rp 25"))), Some(25.0)); + assert_eq!(number(Some(&Value::from(0))), None); + assert_eq!(date(Some(&Value::from("0001-01-01 00:00:00"))), None); + assert_eq!( + date(Some(&Value::from("2026-07-02 00:00:00"))), + Some(day("2026-07-02")) + ); + assert_eq!(clock("09:00:00"), "09:00"); + assert_eq!(clock("10:30"), "10:30"); + } +} diff --git a/crates/idx-core/src/api/stockbit/exodus.rs b/crates/idx-core/src/api/stockbit/exodus.rs index c2030ff..ddd0fca 100644 --- a/crates/idx-core/src/api/stockbit/exodus.rs +++ b/crates/idx-core/src/api/stockbit/exodus.rs @@ -25,9 +25,11 @@ use chrono::{Months, NaiveDate}; use serde_json::Value; use super::auth::SessionStore; +use super::corpaction; use super::parse::number; use super::{USER_AGENT, pace, stockbit_code}; use crate::api::types::{BookLevel, Interval, Ohlc, OrderBook, Period, Quote}; +use crate::corporate::types::{ActionKind, CorporateAction}; use crate::error::IdxError; const BASE_URL: &str = "https://exodus.stockbit.com"; @@ -120,6 +122,24 @@ impl Exodus { daily_for_period(&body, period) } + /// Corporate actions of `kind`: one stock's (`resolved`) or the market's. + pub(crate) fn corporate_actions( + &self, + kind: ActionKind, + resolved: Option<&str>, + ) -> Result, IdxError> { + let path = format!("/corpaction/{}", corpaction::path_type(kind)); + let (path, subject) = match resolved { + Some(resolved) => ( + format!("{path}?symbol={}", stockbit_code(resolved)?), + resolved.to_string(), + ), + None => (path, "corporate actions".to_string()), + }; + let body = self.get(&path, &subject)?; + corpaction::parse_corporate_actions(kind, &body) + } + /// The market's state, read at most every `MARKET_STATE_TTL` per process. /// Unknown on any failure, which hides bid/offer. fn market_status(&self) -> Option { diff --git a/crates/idx-core/src/api/stockbit/mod.rs b/crates/idx-core/src/api/stockbit/mod.rs index 59262c0..a00abf1 100644 --- a/crates/idx-core/src/api/stockbit/mod.rs +++ b/crates/idx-core/src/api/stockbit/mod.rs @@ -17,6 +17,7 @@ pub mod auth; pub mod browser; +pub mod corpaction; pub mod exodus; pub mod loopback; mod parse; @@ -31,8 +32,10 @@ pub use parse::{parse_symbol_page, status_error, stockbit_code}; use super::types::{Bar, Fundamentals, Interval, Intraday, OrderBook, Period, Quote}; use super::{ - FundamentalsProvider, HistoryProvider, IntradayProvider, OrderBookProvider, QuoteProvider, + CorporateActionProvider, FundamentalsProvider, HistoryProvider, IntradayProvider, + OrderBookProvider, QuoteProvider, }; +use crate::corporate::types::{ActionKind, CorporateAction}; use crate::error::IdxError; use auth::SessionStore; use exodus::Exodus; @@ -203,6 +206,16 @@ impl OrderBookProvider for StockbitProvider { } } +impl CorporateActionProvider for StockbitProvider { + fn corporate_actions( + &self, + kind: ActionKind, + symbol: Option<&str>, + ) -> Result, IdxError> { + self.require_session()?.corporate_actions(kind, symbol) + } +} + impl HistoryProvider for StockbitProvider { fn history( &self, diff --git a/crates/idx-core/src/client.rs b/crates/idx-core/src/client.rs index f1551ce..aef1c39 100644 --- a/crates/idx-core/src/client.rs +++ b/crates/idx-core/src/client.rs @@ -94,6 +94,10 @@ impl Idx { crate::flow::Flow { idx: self } } + pub fn corporate(&self) -> crate::corporate::Corporate<'_> { + crate::corporate::Corporate { idx: self } + } + pub fn financial(&self) -> crate::financial::Financial<'_> { crate::financial::Financial { idx: self } } diff --git a/crates/idx-core/src/corporate/mod.rs b/crates/idx-core/src/corporate/mod.rs new file mode 100644 index 0000000..4ddfe01 --- /dev/null +++ b/crates/idx-core/src/corporate/mod.rs @@ -0,0 +1,108 @@ +//! Corporate actions (cash and stock dividends, bonus shares, rights issues, +//! warrants, splits, shareholders' meetings, public exposes, IPOs, tender +//! offers) from the user's Stockbit session: one stock's history, or the +//! market's calendar. Stockbit serves one kind per request, so a query costs +//! one request per kind (paced 1 s apart), each cached for 6 hours. + +pub mod types; + +use chrono::{NaiveDate, Utc}; + +use crate::api::{corporate_action_provider, stockbit, today_wib}; +use crate::client::{CachePolicy, CacheSpec, Fetched, Idx, cached_fetch}; +use crate::error::IdxError; +use types::{ActionKind, CalendarRange, CorporateAction}; + +/// Announcements change a few times a day at most. +const TTL_SECS: u64 = 6 * 3600; +const BUCKET: &str = "stockbit-corpaction"; + +pub struct Corporate<'a> { + pub(crate) idx: &'a Idx, +} + +impl Corporate<'_> { + /// Today in WIB. + pub fn today(&self) -> NaiveDate { + today_wib() + } + + /// One IDX stock's corporate actions of `kinds`, newest first. + pub fn actions( + &self, + symbol: &str, + kinds: &[ActionKind], + policy: CachePolicy, + ) -> Result>, IdxError> { + let (resolved, _) = self.idx.idx_code(symbol, "corporate actions")?; + let mut fetched = self.fetch(kinds, Some(&resolved), policy)?; + fetched + .data + .sort_by(|a, b| b.date.cmp(&a.date).then(a.kind.cmp(&b.kind))); + Ok(fetched) + } + + /// The market's corporate actions of `kinds` dated within `range` (see + /// `CorporateAction::date`), oldest first. + pub fn calendar( + &self, + range: CalendarRange, + kinds: &[ActionKind], + policy: CachePolicy, + ) -> Result>, IdxError> { + let fetched = self.fetch(kinds, None, policy)?; + Ok(fetched.map(|mut actions| { + actions.retain(|a| range.contains(a.date)); + actions.sort_by(|a, b| (a.date, &a.symbol, a.kind).cmp(&(b.date, &b.symbol, b.kind))); + actions + })) + } + + /// Every kind in turn, through the cache; the result is as old as its + /// oldest part and stale if any part is. + fn fetch( + &self, + kinds: &[ActionKind], + resolved: Option<&str>, + policy: CachePolicy, + ) -> Result>, IdxError> { + if kinds.is_empty() { + return Err(IdxError::InvalidInput( + "name at least one kind of corporate action".to_string(), + )); + } + let provider = corporate_action_provider(); + let subject = resolved.unwrap_or("corporate actions"); + let mut merged = Fetched { + data: Vec::new(), + source: stockbit::SOURCE, + fetched_at: Utc::now(), + stale: false, + }; + let mut seen = Vec::with_capacity(kinds.len()); + for &kind in kinds { + if seen.contains(&kind) { + continue; + } + seen.push(kind); + let key = format!("{}:{}", kind.as_str(), resolved.unwrap_or("market")); + let part = cached_fetch( + &self.idx.cache, + CacheSpec { + bucket: BUCKET, + key: &key, + ttl_secs: TTL_SECS, + subject, + source: stockbit::SOURCE, + }, + policy, + || provider.corporate_actions(kind, resolved), + Ok, + )?; + merged.fetched_at = merged.fetched_at.min(part.fetched_at); + merged.stale |= part.stale; + merged.data.extend(part.data); + } + Ok(merged) + } +} diff --git a/crates/idx-core/src/corporate/types.rs b/crates/idx-core/src/corporate/types.rs new file mode 100644 index 0000000..97984e3 --- /dev/null +++ b/crates/idx-core/src/corporate/types.rs @@ -0,0 +1,292 @@ +use chrono::{Duration, NaiveDate}; +use serde::{Deserialize, Serialize}; + +use crate::error::IdxError; + +/// The kinds of corporate action Stockbit lists, one request each. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +#[cfg_attr(feature = "clap", derive(clap::ValueEnum))] +#[serde(rename_all = "snake_case")] +pub enum ActionKind { + /// Cash dividend. + Dividend, + #[cfg_attr(feature = "clap", value(name = "stock-dividend"))] + StockDividend, + /// Bonus shares. + Bonus, + /// Rights issue (HMETD). + Rights, + Warrant, + /// Stock split. + Split, + #[cfg_attr(feature = "clap", value(name = "reverse-split"))] + ReverseSplit, + /// Shareholders' meeting (RUPS). + Meeting, + /// Public expose. + #[cfg_attr(feature = "clap", value(name = "expose"))] + PublicExpose, + Ipo, + #[cfg_attr(feature = "clap", value(name = "tender"))] + TenderOffer, +} + +impl ActionKind { + pub const ALL: [Self; 11] = [ + Self::Dividend, + Self::StockDividend, + Self::Bonus, + Self::Rights, + Self::Warrant, + Self::Split, + Self::ReverseSplit, + Self::Meeting, + Self::PublicExpose, + Self::Ipo, + Self::TenderOffer, + ]; + + /// What one stock's history covers by default: everything but its IPO. + pub const STOCK_DEFAULT: [Self; 10] = [ + Self::Dividend, + Self::StockDividend, + Self::Bonus, + Self::Rights, + Self::Warrant, + Self::Split, + Self::ReverseSplit, + Self::Meeting, + Self::PublicExpose, + Self::TenderOffer, + ]; + + /// The CLI's name (`--kind`), also used in MCP inputs. + pub fn as_str(self) -> &'static str { + match self { + Self::Dividend => "dividend", + Self::StockDividend => "stock-dividend", + Self::Bonus => "bonus", + Self::Rights => "rights", + Self::Warrant => "warrant", + Self::Split => "split", + Self::ReverseSplit => "reverse-split", + Self::Meeting => "meeting", + Self::PublicExpose => "expose", + Self::Ipo => "ipo", + Self::TenderOffer => "tender", + } + } + + /// Whether the action entitles holders on a cum date (and so moves the + /// price on the ex date). + pub fn is_entitlement(self) -> bool { + matches!( + self, + Self::Dividend + | Self::StockDividend + | Self::Bonus + | Self::Rights + | Self::Split + | Self::ReverseSplit + ) + } +} + +impl std::str::FromStr for ActionKind { + type Err = IdxError; + + fn from_str(value: &str) -> Result { + Self::ALL + .into_iter() + .find(|kind| kind.as_str() == value) + .ok_or_else(|| { + let names: Vec<_> = Self::ALL.iter().map(|k| k.as_str()).collect(); + IdxError::InvalidInput(format!( + "invalid kind '{value}' (expected one of: {})", + names.join(", ") + )) + }) + } +} + +/// `old : new` as Stockbit states it: a 1:5 split turns 1 share into 5; a +/// 655:104 rights issue gives 104 rights per 655 shares held; a 6:4 bonus +/// gives 4 bonus shares per 6 held. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub struct Ratio { + pub old: u64, + pub new: u64, +} + +/// Inclusive dates. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub struct DateRange { + pub start: NaiveDate, + pub end: NaiveDate, +} + +/// One corporate action of one stock. Which fields are present depends on +/// `kind`; absent ones are left out of JSON. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct CorporateAction { + /// `BBCA.JK`. + pub symbol: String, + pub kind: ActionKind, + /// Where the action sits on a calendar: the cum date for entitlements + /// (the last day to buy and be entitled), else the meeting or expose + /// day, the listing day, a warrant's first trading day, or a tender + /// offer's first day. + pub date: NaiveDate, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cum_date: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ex_date: Option, + /// Recording date; for a meeting, the date that decides who may attend. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub record_date: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pay_date: Option, + /// Cash dividend per share, IDR as Stockbit gives it (up to 2 decimals, + /// e.g. 3.8). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cash_per_share: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ratio: Option, + /// Stockbit's price adjustment factor: 5 for a 1:5 split, 1.6667 for a + /// 6:4 bonus. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub factor: Option, + /// Whole IDR: the rights exercise price, a warrant's exercise price, the + /// tender offer price or the final IPO price. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub price: Option, + /// When rights or warrants trade, a tender offer runs, or an IPO is + /// offered. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub period: Option, + /// When warrants can be exercised. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub exercise: Option, + /// Shares offered (IPO) or sought (tender offer). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub shares: Option, + /// Share of the company a tender offer seeks, basis points. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub percentage_bps: Option, + /// Meeting or expose time, as Stockbit writes it (WIB). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub time: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub venue: Option, + /// The issuer's name, when Stockbit gives it (IPO, tender offer). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl CorporateAction { + pub fn new(symbol: String, kind: ActionKind, date: NaiveDate) -> Self { + Self { + symbol, + kind, + date, + cum_date: None, + ex_date: None, + record_date: None, + pay_date: None, + cash_per_share: None, + ratio: None, + factor: None, + price: None, + period: None, + exercise: None, + shares: None, + percentage_bps: None, + time: None, + venue: None, + name: None, + } + } +} + +/// Default calendar span, days from today. +pub const CALENDAR_DEFAULT_DAYS: i64 = 30; +/// Longest calendar range, days. +pub const CALENDAR_MAX_DAYS: i64 = 366; + +/// The dates a market-wide calendar covers, inclusive. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub struct CalendarRange { + pub from: NaiveDate, + pub to: NaiveDate, +} + +impl CalendarRange { + /// `from` defaults to today, `to` to 30 days after `from`. + pub fn from_args( + from: Option<&str>, + to: Option<&str>, + today: NaiveDate, + ) -> Result { + let parse = |name: &str, value: &str| { + NaiveDate::parse_from_str(value.trim(), "%Y-%m-%d").map_err(|_| { + IdxError::InvalidInput(format!("invalid {name} '{value}'; use YYYY-MM-DD")) + }) + }; + let from = from.map(|v| parse("from", v)).transpose()?.unwrap_or(today); + let to = to + .map(|v| parse("to", v)) + .transpose()? + .unwrap_or(from + Duration::days(CALENDAR_DEFAULT_DAYS)); + if to < from { + return Err(IdxError::InvalidInput(format!( + "to ({to}) is before from ({from})" + ))); + } + if (to - from).num_days() > CALENDAR_MAX_DAYS { + return Err(IdxError::InvalidInput(format!( + "a calendar covers at most {CALENDAR_MAX_DAYS} days" + ))); + } + Ok(Self { from, to }) + } + + pub fn contains(&self, date: NaiveDate) -> bool { + (self.from..=self.to).contains(&date) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn day(s: &str) -> NaiveDate { + NaiveDate::parse_from_str(s, "%Y-%m-%d").unwrap() + } + + #[test] + fn test_calendar_range_defaults_and_bounds() { + let today = day("2026-11-03"); + let range = CalendarRange::from_args(None, None, today).unwrap(); + assert_eq!((range.from, range.to), (today, day("2026-12-03"))); + let range = CalendarRange::from_args(Some("2026-11-10"), None, today).unwrap(); + assert_eq!(range.to, day("2026-12-10")); + for (from, to) in [ + (Some("2026-11-10"), Some("2026-11-09")), + (Some("2026-01-01"), Some("2027-06-01")), + (Some("11/10/2026"), None), + ] { + assert!(matches!( + CalendarRange::from_args(from, to, today), + Err(IdxError::InvalidInput(_)) + )); + } + } + + #[test] + fn test_action_kind_names_round_trip() { + for kind in ActionKind::ALL { + assert_eq!(kind.as_str().parse::().unwrap(), kind); + } + assert!("rups".parse::().is_err()); + } +} diff --git a/crates/idx-core/src/lib.rs b/crates/idx-core/src/lib.rs index bd01c1c..cd49711 100644 --- a/crates/idx-core/src/lib.rs +++ b/crates/idx-core/src/lib.rs @@ -8,6 +8,7 @@ pub mod broker; pub mod cache; mod client; pub mod config; +pub mod corporate; pub mod curl_impersonate; pub mod error; pub mod financial; diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_bonus.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_bonus.json new file mode 100644 index 0000000..f673ef1 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_bonus.json @@ -0,0 +1 @@ +{"data":{"bonus":[{"company_id":"1000003000","company_symbol":"PPGL","corp_action_active":true,"sahambonus_id":"7732","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"6 : 4","stocksplit_created":"","stocksplit_cumdate":"2026-11-02","stocksplit_exdate":"2026-11-03","stocksplit_factor":"1.6667","stocksplit_new":"4","stocksplit_old":"6","stocksplit_paymentdate":"2026-11-25","stocksplit_recdate":"2026-11-04","event_note":""},{"company_id":"397","company_symbol":"SPMA","corp_action_active":false,"sahambonus_id":"7730","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"100 : 30","stocksplit_created":"","stocksplit_cumdate":"2026-07-08","stocksplit_exdate":"2026-07-09","stocksplit_factor":"1.3","stocksplit_new":"30","stocksplit_old":"100","stocksplit_paymentdate":"2026-07-30","stocksplit_recdate":"2026-07-10","event_note":""},{"company_id":"457","company_symbol":"WINS","corp_action_active":false,"sahambonus_id":"7731","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"71 : 1","stocksplit_created":"","stocksplit_cumdate":"2026-05-25","stocksplit_exdate":"2026-05-26","stocksplit_factor":"1.0141","stocksplit_new":"1","stocksplit_old":"71","stocksplit_paymentdate":"2026-06-18","stocksplit_recdate":"2026-05-29","event_note":""},{"company_id":"1000004517","company_symbol":"MEJA","corp_action_active":false,"sahambonus_id":"7727","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"6 : 1","stocksplit_created":"","stocksplit_cumdate":"2026-04-16","stocksplit_exdate":"2026-04-17","stocksplit_factor":"1.1667","stocksplit_new":"1","stocksplit_old":"6","stocksplit_paymentdate":"2026-05-08","stocksplit_recdate":"2026-04-20","event_note":""},{"company_id":"1000004196","company_symbol":"CNMA","corp_action_active":false,"sahambonus_id":"7728","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"50 : 1","stocksplit_created":"","stocksplit_cumdate":"2026-04-14","stocksplit_exdate":"2026-04-15","stocksplit_factor":"1.02","stocksplit_new":"1","stocksplit_old":"50","stocksplit_paymentdate":"2026-04-28","stocksplit_recdate":"2026-04-16","event_note":""},{"company_id":"284","company_symbol":"MEGA","corp_action_active":false,"sahambonus_id":"7723","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"1 : 1","stocksplit_created":"","stocksplit_cumdate":"2026-04-09","stocksplit_exdate":"2026-04-10","stocksplit_factor":"2","stocksplit_new":"1","stocksplit_old":"1","stocksplit_paymentdate":"2026-04-30","stocksplit_recdate":"2026-04-13","event_note":""},{"company_id":"1000003506","company_symbol":"WGSH","corp_action_active":false,"sahambonus_id":"7722","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"1 : 1","stocksplit_created":"","stocksplit_cumdate":"2026-04-02","stocksplit_exdate":"2026-04-06","stocksplit_factor":"2","stocksplit_new":"1","stocksplit_old":"1","stocksplit_paymentdate":"2026-04-24","stocksplit_recdate":"2026-04-07","event_note":""},{"company_id":"1000000034","company_symbol":"RISE","corp_action_active":false,"sahambonus_id":"7721","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"25 : 12","stocksplit_created":"","stocksplit_cumdate":"2026-01-19","stocksplit_exdate":"2026-01-20","stocksplit_factor":"1.48","stocksplit_new":"12","stocksplit_old":"25","stocksplit_paymentdate":"2026-02-09","stocksplit_recdate":"2026-01-21","event_note":""},{"company_id":"43","company_symbol":"ASRM","corp_action_active":false,"sahambonus_id":"7720","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"20 : 1","stocksplit_created":"","stocksplit_cumdate":"2025-11-12","stocksplit_exdate":"2025-11-13","stocksplit_factor":"1.0500","stocksplit_new":"1","stocksplit_old":"20","stocksplit_paymentdate":"2025-12-05","stocksplit_recdate":"2025-11-14","event_note":""},{"company_id":"397","company_symbol":"SPMA","corp_action_active":false,"sahambonus_id":"7719","sahambonus_iqp_id":"","sahambonus_lastupdate":"","sahambonus_new_price":0,"sahambonus_new_share":0,"sahambonus_ratio":"100 : 30","stocksplit_created":"","stocksplit_cumdate":"2025-11-07","stocksplit_exdate":"2025-11-10","stocksplit_factor":"1.3000","stocksplit_new":"30","stocksplit_old":"100","stocksplit_paymentdate":"2025-11-25","stocksplit_recdate":"2025-11-11","event_note":""}]},"message":"Successfully retrieved stock bonus data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_dividend.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_dividend.json new file mode 100644 index 0000000..e1d6256 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_dividend.json @@ -0,0 +1 @@ +{"data":{"dividend":[{"company_id":"290","company_symbol":"MIDI","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2026-11-11","dividend_datahash":"","dividend_exdate":"2026-11-12","dividend_id":"118120","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-12-01","dividend_recdate":"2026-11-13","dividend_value":"3.8","lastprice":"244","event_note":"","dividend_value_formatted":"Rp 3.8","lastprice_formatted":"244","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"1000002614","company_symbol":"IFII","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2026-11-11","dividend_datahash":"","dividend_exdate":"2026-11-12","dividend_id":"118119","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-26","dividend_recdate":"2026-11-13","dividend_value":"5","lastprice":"198","event_note":"","dividend_value_formatted":"Rp 5","lastprice_formatted":"198","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"224","company_symbol":"ITMG","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-10","dividend_datahash":"","dividend_exdate":"2026-11-11","dividend_id":"118118","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-18","dividend_recdate":"2026-11-12","dividend_value":"1191.09","lastprice":"24725","event_note":"","dividend_value_formatted":"Rp 1191.09","lastprice_formatted":"24,725","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"107","company_symbol":"BWPT","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-10","dividend_datahash":"","dividend_exdate":"2026-11-11","dividend_id":"118117","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-25","dividend_recdate":"2026-11-12","dividend_value":"1","lastprice":"75","event_note":"","dividend_value_formatted":"Rp 1","lastprice_formatted":"75","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"501","company_symbol":"SSMS","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-10","dividend_datahash":"","dividend_exdate":"2026-11-11","dividend_id":"118116","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-12-02","dividend_recdate":"2026-11-12","dividend_value":"52.49","lastprice":"970","event_note":"","dividend_value_formatted":"Rp 52.49","lastprice_formatted":"970","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"283","company_symbol":"MEDC","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-10","dividend_datahash":"","dividend_exdate":"2026-11-11","dividend_id":"118115","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-12-02","dividend_recdate":"2026-11-12","dividend_value":"21.65","lastprice":"1295","event_note":"","dividend_value_formatted":"Rp 21.65","lastprice_formatted":"1,295","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"1000003271","company_symbol":"TAPG","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-10","dividend_datahash":"","dividend_exdate":"2026-11-11","dividend_id":"118114","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-27","dividend_recdate":"2026-11-12","dividend_value":"70","lastprice":"1875","event_note":"","dividend_value_formatted":"Rp 70","lastprice_formatted":"1,875","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"1000003485","company_symbol":"AVIA","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-10","dividend_datahash":"","dividend_exdate":"2026-11-11","dividend_id":"118113","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-19","dividend_recdate":"2026-11-12","dividend_value":"12","lastprice":"296","event_note":"","dividend_value_formatted":"Rp 12","lastprice_formatted":"296","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"394","company_symbol":"SMSM","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-09","dividend_datahash":"","dividend_exdate":"2026-11-10","dividend_id":"118112","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-26","dividend_recdate":"2026-11-11","dividend_value":"45","lastprice":"1585","event_note":"","dividend_value_formatted":"Rp 45","lastprice_formatted":"1,585","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"1000004196","company_symbol":"CNMA","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-06","dividend_datahash":"","dividend_exdate":"2026-11-09","dividend_id":"118110","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-19","dividend_recdate":"2026-11-10","dividend_value":"4","lastprice":"75","event_note":"","dividend_value_formatted":"Rp 4","lastprice_formatted":"75","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"1000004325","company_symbol":"PTPS","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-05","dividend_datahash":"","dividend_exdate":"2026-11-06","dividend_id":"118111","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-18","dividend_recdate":"2026-11-09","dividend_value":"2","lastprice":"123","event_note":"","dividend_value_formatted":"Rp 2","lastprice_formatted":"123","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"231","company_symbol":"JPFA","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-05","dividend_datahash":"","dividend_exdate":"2026-11-06","dividend_id":"118109","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-12","dividend_recdate":"2026-11-09","dividend_value":"90","lastprice":"1700","event_note":"","dividend_value_formatted":"Rp 90","lastprice_formatted":"1,700","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"447","company_symbol":"UNTR","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-05","dividend_datahash":"","dividend_exdate":"2026-11-06","dividend_id":"118108","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-23","dividend_recdate":"2026-11-09","dividend_value":"430","lastprice":"23225","event_note":"","dividend_value_formatted":"Rp 430","lastprice_formatted":"23,225","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"502","company_symbol":"SIDO","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-11-02","dividend_datahash":"","dividend_exdate":"2026-11-03","dividend_id":"118107","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-20","dividend_recdate":"2026-11-04","dividend_value":"10","lastprice":"318","event_note":"","dividend_value_formatted":"Rp 10","lastprice_formatted":"318","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"441","company_symbol":"TSPC","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-10-30","dividend_datahash":"","dividend_exdate":"2026-11-02","dividend_id":"118106","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-20","dividend_recdate":"2026-11-03","dividend_value":"75","lastprice":"2240","event_note":"","dividend_value_formatted":"Rp 75","lastprice_formatted":"2,240","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"532","company_symbol":"DMAS","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-10-28","dividend_datahash":"","dividend_exdate":"2026-10-29","dividend_id":"118105","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-16","dividend_recdate":"2026-10-30","dividend_value":"29","lastprice":"161","event_note":"","dividend_value_formatted":"Rp 29","lastprice_formatted":"161","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"1000003710","company_symbol":"AXIO","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-10-28","dividend_datahash":"","dividend_exdate":"2026-10-29","dividend_id":"118104","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-19","dividend_recdate":"2026-10-30","dividend_value":"8","lastprice":"123","event_note":"","dividend_value_formatted":"Rp 8","lastprice_formatted":"123","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"1000002303","company_symbol":"XSPI","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-10-28","dividend_datahash":"","dividend_exdate":"2026-10-29","dividend_id":"118103","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-05","dividend_recdate":"2026-10-30","dividend_value":"5.94","lastprice":"426","event_note":"","dividend_value_formatted":"Rp 5.94","lastprice_formatted":"426","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"371","company_symbol":"SCMA","corp_action_active":true,"dividend_created":"","dividend_cumdate":"2026-10-27","dividend_datahash":"","dividend_exdate":"2026-10-28","dividend_id":"118102","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-11-18","dividend_recdate":"2026-10-29","dividend_value":"8.4","lastprice":"126","event_note":"","dividend_value_formatted":"Rp 8.4","lastprice_formatted":"126","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"224","company_symbol":"ITMG","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2026-04-27","dividend_datahash":"","dividend_exdate":"2026-04-28","dividend_id":"117678","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-05-19","dividend_recdate":"2026-04-29","dividend_value":"992","lastprice":"24725","event_note":"","dividend_value_formatted":"Rp 992","lastprice_formatted":"24,725","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"224","company_symbol":"ITMG","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2025-11-12","dividend_datahash":"","dividend_exdate":"2025-11-13","dividend_id":"117592","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2025-11-26","dividend_recdate":"2025-11-14","dividend_value":"738","lastprice":"24725","event_note":"","dividend_value_formatted":"Rp 738","lastprice_formatted":"24,725","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0}],"today":"2026-11-03"},"message":"Successfully retrieved dividend data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_dividend_bbca.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_dividend_bbca.json new file mode 100644 index 0000000..f11d089 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_dividend_bbca.json @@ -0,0 +1 @@ +{"data":{"dividend":[{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2026-08-28","dividend_datahash":"","dividend_exdate":"2026-08-31","dividend_id":"118073","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-09-16","dividend_recdate":"2026-09-01","dividend_value":"25","lastprice":"","event_note":"","dividend_value_formatted":"Rp 25","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2026-06-15","dividend_datahash":"","dividend_exdate":"2026-06-17","dividend_id":"117860","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-06-26","dividend_recdate":"2026-06-18","dividend_value":"20","lastprice":"","event_note":"","dividend_value_formatted":"Rp 20","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2026-03-27","dividend_datahash":"","dividend_exdate":"2026-03-30","dividend_id":"117649","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2026-04-08","dividend_recdate":"2026-03-31","dividend_value":"281","lastprice":"","event_note":"","dividend_value_formatted":"Rp 281","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2025-12-02","dividend_datahash":"","dividend_exdate":"2025-12-03","dividend_id":"117616","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2025-12-22","dividend_recdate":"2025-12-04","dividend_value":"55","lastprice":"","event_note":"","dividend_value_formatted":"Rp 55","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2025-03-20","dividend_datahash":"","dividend_exdate":"2025-03-21","dividend_id":"117119","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2025-04-11","dividend_recdate":"2025-03-24","dividend_value":"250","lastprice":"","event_note":"","dividend_value_formatted":"Rp 250","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2024-11-20","dividend_datahash":"","dividend_exdate":"2024-11-21","dividend_id":"117067","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2024-12-11","dividend_recdate":"2024-11-22","dividend_value":"50","lastprice":"","event_note":"","dividend_value_formatted":"Rp 50","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2024-03-22","dividend_datahash":"","dividend_exdate":"2024-03-25","dividend_id":"114270","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2024-04-04","dividend_recdate":"2024-03-26","dividend_value":"227.5","lastprice":"","event_note":"","dividend_value_formatted":"Rp 227.5","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2023-12-01","dividend_datahash":"","dividend_exdate":"2023-12-04","dividend_id":"114214","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2023-12-20","dividend_recdate":"2023-12-05","dividend_value":"42.5","lastprice":"","event_note":"","dividend_value_formatted":"Rp 42.5","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2023-03-28","dividend_datahash":"","dividend_exdate":"2023-03-29","dividend_id":"113604","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2023-04-14","dividend_recdate":"2023-03-30","dividend_value":"170","lastprice":"","event_note":"","dividend_value_formatted":"Rp 170","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2022-12-01","dividend_datahash":"","dividend_exdate":"2022-12-02","dividend_id":"113554","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2022-12-20","dividend_recdate":"2022-12-05","dividend_value":"35","lastprice":"","event_note":"","dividend_value_formatted":"Rp 35","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2022-03-25","dividend_datahash":"","dividend_exdate":"2022-03-28","dividend_id":"113048","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2022-04-19","dividend_recdate":"2022-03-29","dividend_value":"120","lastprice":"","event_note":"","dividend_value_formatted":"Rp 120","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2021-11-16","dividend_datahash":"","dividend_exdate":"2021-11-17","dividend_id":"96673","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2021-12-07","dividend_recdate":"2021-11-18","dividend_value":"25","lastprice":"","event_note":"","dividend_value_formatted":"Rp 25","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2021-04-07","dividend_datahash":"","dividend_exdate":"2021-04-08","dividend_id":"84523","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2021-04-28","dividend_recdate":"2021-04-09","dividend_value":"432","lastprice":"","event_note":"","dividend_value_formatted":"Rp 432","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2020-12-07","dividend_datahash":"","dividend_exdate":"2020-12-08","dividend_id":"83964","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2020-12-22","dividend_recdate":"2020-12-10","dividend_value":"98","lastprice":"","event_note":"","dividend_value_formatted":"Rp 98","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2020-04-20","dividend_datahash":"","dividend_exdate":"2020-04-21","dividend_id":"68067","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2020-05-11","dividend_recdate":"2020-04-22","dividend_value":"455","lastprice":"","event_note":"","dividend_value_formatted":"Rp 455","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2019-12-05","dividend_datahash":"","dividend_exdate":"2019-12-06","dividend_id":"58204","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2019-12-20","dividend_recdate":"2019-12-09","dividend_value":"100","lastprice":"","event_note":"","dividend_value_formatted":"Rp 100","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2019-04-23","dividend_datahash":"","dividend_exdate":"2019-04-24","dividend_id":"33852","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2019-04-30","dividend_recdate":"2019-04-25","dividend_value":"255","lastprice":"","event_note":"","dividend_value_formatted":"Rp 255","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2018-11-30","dividend_datahash":"","dividend_exdate":"2018-12-03","dividend_id":"23024","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2018-12-21","dividend_recdate":"2018-12-04","dividend_value":"85","lastprice":"","event_note":"","dividend_value_formatted":"Rp 85","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2018-04-12","dividend_datahash":"","dividend_exdate":"2018-04-13","dividend_id":"4874","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2018-04-30","dividend_recdate":"2018-04-17","dividend_value":"175","lastprice":"","event_note":"","dividend_value_formatted":"Rp 175","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2017-11-28","dividend_datahash":"","dividend_exdate":"2017-11-29","dividend_id":"4531","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2017-12-20","dividend_recdate":"2017-12-04","dividend_value":"80","lastprice":"","event_note":"","dividend_value_formatted":"Rp 80","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2017-04-13","dividend_datahash":"","dividend_exdate":"2017-04-17","dividend_id":"2831","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2017-04-28","dividend_recdate":"2017-04-20","dividend_value":"130","lastprice":"","event_note":"","dividend_value_formatted":"Rp 130","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2016-11-30","dividend_datahash":"","dividend_exdate":"2016-12-01","dividend_id":"2599","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2016-12-22","dividend_recdate":"2016-12-05","dividend_value":"70","lastprice":"","event_note":"","dividend_value_formatted":"Rp 70","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2016-04-14","dividend_datahash":"","dividend_exdate":"2016-04-15","dividend_id":"1283","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2016-04-29","dividend_recdate":"2016-04-19","dividend_value":"105","lastprice":"","event_note":"","dividend_value_formatted":"Rp 105","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2015-11-12","dividend_datahash":"","dividend_exdate":"2015-11-13","dividend_id":"1109","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2015-12-09","dividend_recdate":"2015-11-17","dividend_value":"55","lastprice":"","event_note":"","dividend_value_formatted":"Rp 55","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2015-04-16","dividend_datahash":"","dividend_exdate":"2015-04-17","dividend_id":"996","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2015-05-13","dividend_recdate":"2015-04-21","dividend_value":"98","lastprice":"","event_note":"","dividend_value_formatted":"Rp 98","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2014-12-04","dividend_datahash":"","dividend_exdate":"2014-12-05","dividend_id":"11230","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2014-12-23","dividend_recdate":"2014-12-09","dividend_value":"50","lastprice":"","event_note":"","dividend_value_formatted":"Rp 50","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2014-04-29","dividend_datahash":"","dividend_exdate":"2014-04-30","dividend_id":"11019","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2014-05-20","dividend_recdate":"2014-05-05","dividend_value":"75","lastprice":"","event_note":"","dividend_value_formatted":"Rp 75","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2013-11-28","dividend_datahash":"","dividend_exdate":"2013-11-29","dividend_id":"10978","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2013-12-17","dividend_recdate":"2013-12-03","dividend_value":"45","lastprice":"","event_note":"","dividend_value_formatted":"Rp 45","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2013-05-28","dividend_datahash":"","dividend_exdate":"2013-05-29","dividend_id":"10806","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2013-06-17","dividend_recdate":"2013-05-31","dividend_value":"71","lastprice":"","event_note":"","dividend_value_formatted":"Rp 71","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2012-12-03","dividend_datahash":"","dividend_exdate":"2012-12-04","dividend_id":"10744","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2012-12-20","dividend_recdate":"2012-12-06","dividend_value":"43.5","lastprice":"","event_note":"","dividend_value_formatted":"Rp 43.5","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2012-06-08","dividend_datahash":"","dividend_exdate":"2012-06-11","dividend_id":"10604","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2012-06-27","dividend_recdate":"2012-06-13","dividend_value":"70","lastprice":"","event_note":"","dividend_value_formatted":"Rp 70","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2011-12-06","dividend_datahash":"","dividend_exdate":"2011-12-07","dividend_id":"10538","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2011-12-23","dividend_recdate":"2011-12-09","dividend_value":"43.5","lastprice":"","event_note":"","dividend_value_formatted":"Rp 43.5","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2011-06-06","dividend_datahash":"","dividend_exdate":"2011-06-07","dividend_id":"10364","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2011-06-23","dividend_recdate":"2011-06-09","dividend_value":"70","lastprice":"","event_note":"","dividend_value_formatted":"Rp 70","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2010-11-19","dividend_datahash":"","dividend_exdate":"2010-11-22","dividend_id":"10299","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2010-12-09","dividend_recdate":"2010-11-24","dividend_value":"42.5","lastprice":"","event_note":"","dividend_value_formatted":"Rp 42.5","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2010-05-31","dividend_datahash":"","dividend_exdate":"2010-06-01","dividend_id":"10149","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2010-06-17","dividend_recdate":"2010-06-03","dividend_value":"70","lastprice":"","event_note":"","dividend_value_formatted":"Rp 70","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2009-11-12","dividend_datahash":"","dividend_exdate":"2009-11-13","dividend_id":"10104","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2009-12-02","dividend_recdate":"2009-11-17","dividend_value":"40","lastprice":"","event_note":"","dividend_value_formatted":"Rp 40","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"dividend_created":"","dividend_cumdate":"2009-06-09","dividend_datahash":"","dividend_exdate":"2009-06-10","dividend_id":"9986","dividend_iqp_id":"","dividend_lastupdate":"","dividend_lock":0,"dividend_paydate":"2009-06-26","dividend_recdate":"2009-06-12","dividend_value":"65","lastprice":"","event_note":"","dividend_value_formatted":"Rp 65","lastprice_formatted":"","dividend_currency":"CURRENCY_IDR","dividend_fiscal_year":0,"dividend_value_adjusted":0}],"today":"2026-11-03"},"message":"Successfully retrieved dividend data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_ipo.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_ipo.json new file mode 100644 index 0000000..fe606a4 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_ipo.json @@ -0,0 +1 @@ +{"data":{"ipo":[{"ipo_id":"6851","company_symbol":"XKGS","company_name":"Reksa Dana Syariah KIM Gold ETF Sharia","ipo_listing_date":"2026-09-26","ipo_data":"{\"%\":\"0\",\"Allotment Date\":\"\",\"Offering End\":\"0001-01-01 00:00:00\",\"Offering Start\":\"0001-01-01 00:00:00\",\"Price\":\"0\",\"Refund Date\":\"\",\"Shares\":\"\",\"board\":\"\"}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"0","shares":"","percentage":"0","offering_start":"0001-01-01 00:00:00","offering_end":"0001-01-01 00:00:00","allotment_date":"","refund_date":"","price_formatted":"0","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":0}},{"ipo_id":"6847","company_symbol":"XDES","company_name":"Reksa Dana Syariah BRI MI Gold ETF Syariah","ipo_listing_date":"2026-08-10","ipo_data":"{\"%\":\"0\",\"Allotment Date\":\"\",\"Offering End\":\"0001-01-01 00:00:00\",\"Offering Start\":\"0001-01-01 00:00:00\",\"Price\":\"0\",\"Refund Date\":\"\",\"Shares\":\"\",\"board\":\"\"}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"0","shares":"","percentage":"0","offering_start":"0001-01-01 00:00:00","offering_end":"0001-01-01 00:00:00","allotment_date":"","refund_date":"","price_formatted":"0","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":0}},{"ipo_id":"6848","company_symbol":"XMES","company_name":"Reksa Dana Syariah Mandiri ETF Emas","ipo_listing_date":"2026-08-10","ipo_data":"{\"%\":\"0\",\"Allotment Date\":\"\",\"Offering End\":\"0001-01-01 00:00:00\",\"Offering Start\":\"0001-01-01 00:00:00\",\"Price\":\"0\",\"Refund Date\":\"\",\"Shares\":\"\",\"board\":\"\"}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"0","shares":"","percentage":"0","offering_start":"0001-01-01 00:00:00","offering_end":"0001-01-01 00:00:00","allotment_date":"","refund_date":"","price_formatted":"0","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":0}},{"ipo_id":"6849","company_symbol":"XSGO","company_name":"Reksa Dana Syariah Syailendra ETF Sharia Gold","ipo_listing_date":"2026-08-10","ipo_data":"{\"%\":\"0\",\"Allotment Date\":\"\",\"Offering End\":\"0001-01-01 00:00:00\",\"Offering Start\":\"0001-01-01 00:00:00\",\"Price\":\"0\",\"Refund Date\":\"\",\"Shares\":\"\",\"board\":\"\"}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"0","shares":"","percentage":"0","offering_start":"0001-01-01 00:00:00","offering_end":"0001-01-01 00:00:00","allotment_date":"","refund_date":"","price_formatted":"0","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":0}},{"ipo_id":"6850","company_symbol":"XTRA","company_name":"Reksa Dana Syariah Trimegah Syariah ETF Emas","ipo_listing_date":"2026-08-10","ipo_data":"{\"%\":\"0\",\"Allotment Date\":\"\",\"Offering End\":\"0001-01-01 00:00:00\",\"Offering Start\":\"0001-01-01 00:00:00\",\"Price\":\"0\",\"Refund Date\":\"\",\"Shares\":\"\",\"board\":\"\"}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"0","shares":"","percentage":"0","offering_start":"0001-01-01 00:00:00","offering_end":"0001-01-01 00:00:00","allotment_date":"","refund_date":"","price_formatted":"0","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":0}},{"ipo_id":"6834","company_symbol":"RANS","company_name":"PT Rans Entertainmen Indonesia","ipo_listing_date":"2026-07-10","ipo_data":"{\"%\":\"20.02\",\"Allotment Date\":\"\",\"Offering End\":\"2026-07-08 00:00:00\",\"Offering Start\":\"2026-07-02 00:00:00\",\"Price\":\"170\",\"Refund Date\":\"\",\"Shares\":\"2,525,000,000\",\"board\":\"\",\"bureau_administration\":\"PT Adimitra Jasa Korpora\",\"underwriter\":[\"LG - TRIMEGAH SEKURITAS INDONESIA TBK.\"]}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"170","shares":"2,525,000,000","percentage":"20.02","offering_start":"2026-07-02 00:00:00","offering_end":"2026-07-08 00:00:00","allotment_date":"","refund_date":"","price_formatted":"170","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":170}},{"ipo_id":"6826","company_symbol":"PRDL","company_name":"PT Prodia Diagnostic Line","ipo_listing_date":"2026-07-09","ipo_data":"{\"%\":\"30\",\"Allotment Date\":\"\",\"Offering End\":\"2026-07-07 00:00:00\",\"Offering Start\":\"2026-07-01 00:00:00\",\"Price\":\"120\",\"Refund Date\":\"\",\"Shares\":\"522,900,000\",\"board\":\"\",\"bureau_administration\":\"PT Adimitra Jasa Korpora\",\"underwriter\":[\"AZ - SUCOR SEKURITAS\"]}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"120","shares":"522,900,000","percentage":"30","offering_start":"2026-07-01 00:00:00","offering_end":"2026-07-07 00:00:00","allotment_date":"","refund_date":"","price_formatted":"120","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":120}},{"ipo_id":"6828","company_symbol":"EMMI","company_name":"PT Esa Medika Mandiri","ipo_listing_date":"2026-07-08","ipo_data":"{\"%\":\"30\",\"Allotment Date\":\"\",\"Offering End\":\"2026-07-06 00:00:00\",\"Offering Start\":\"2026-07-02 00:00:00\",\"Price\":\"470\",\"Refund Date\":\"\",\"Shares\":\"522,857,000\",\"board\":\"\",\"bureau_administration\":\"PT Datindo Entrycom\",\"underwriter\":[\"OD - BRI DANAREKSA SEKURITAS\",\"RB - INA SEKURITAS INDONESIA\",\"RS - YULIE SEKURITAS INDONESIA TBK.\",\"IN - INVESTINDO NUSANTARA SEKURITAS\"]}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"470","shares":"522,857,000","percentage":"30","offering_start":"2026-07-02 00:00:00","offering_end":"2026-07-06 00:00:00","allotment_date":"","refund_date":"","price_formatted":"470","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":470}},{"ipo_id":"6830","company_symbol":"BACH","company_name":"PT Bach Multi Global","ipo_listing_date":"2026-07-08","ipo_data":"{\"%\":\"15.06\",\"Allotment Date\":\"\",\"Offering End\":\"2026-07-06 00:00:00\",\"Offering Start\":\"2026-07-02 00:00:00\",\"Price\":\"442\",\"Refund Date\":\"\",\"Shares\":\"615,000,000\",\"board\":\"\",\"bureau_administration\":\"PT Adimitra Jasa Korpora\",\"underwriter\":[\"AO - ERDIKHA ELIT SEKURITAS\",\"PO - PILARMAS INVESTINDO SEKURITAS\"]}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"442","shares":"615,000,000","percentage":"15.06","offering_start":"2026-07-02 00:00:00","offering_end":"2026-07-06 00:00:00","allotment_date":"","refund_date":"","price_formatted":"442","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":442}},{"ipo_id":"6824","company_symbol":"JELI","company_name":"PT Niramas Utama","ipo_listing_date":"2026-07-07","ipo_data":"{\"%\":\"21.01\",\"Allotment Date\":\"\",\"Offering End\":\"2026-07-03 00:00:00\",\"Offering Start\":\"2026-07-01 00:00:00\",\"Price\":\"900\",\"Refund Date\":\"\",\"Shares\":\"266,000,000\",\"board\":\"\",\"bureau_administration\":\"PT Adimitra Jasa Korpora\",\"underwriter\":[\"AZ - SUCOR SEKURITAS\"]}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"900","shares":"266,000,000","percentage":"21.01","offering_start":"2026-07-01 00:00:00","offering_end":"2026-07-03 00:00:00","allotment_date":"","refund_date":"","price_formatted":"900","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":900}},{"ipo_id":"6829","company_symbol":"JECX","company_name":"PT Nitrasanata Dharma","ipo_listing_date":"2026-07-07","ipo_data":"{\"%\":\"15\",\"Allotment Date\":\"\",\"Offering End\":\"2026-07-03 00:00:00\",\"Offering Start\":\"2026-07-01 00:00:00\",\"Price\":\"1250\",\"Refund Date\":\"\",\"Shares\":\"487,983,500\",\"board\":\"\",\"bureau_administration\":\"PT Adimitra Jasa Korpora\",\"underwriter\":[\"LG - TRIMEGAH SEKURITAS INDONESIA TBK.\"]}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"1,250","shares":"487,983,500","percentage":"15","offering_start":"2026-07-01 00:00:00","offering_end":"2026-07-03 00:00:00","allotment_date":"","refund_date":"","price_formatted":"1,250","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":1250}},{"ipo_id":"6821","company_symbol":"WBSA","company_name":"PT BSA Logistics Indonesia","ipo_listing_date":"2026-04-10","ipo_data":"{\"%\": \"20.75\", \"Price\": \"168\", \"board\": \"\", \"Shares\": \"1,800,000,000\", \"Refund Date\": \"\", \"underwriter\": [\"OCBC Sekuritas Indonesia\", \"Semesta Indovest Sekuritas\", \"Indo Capital Sekuritas\"], \"Offering End\": \"2026-04-08 00:00:00\", \"Allotment Date\": \"\", \"Offering Start\": \"2026-04-02 00:00:00\", \"bureau_administration\": \"PT Adimitra Jasa Korpora\"}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"168","shares":"1,800,000,000","percentage":"20.75","offering_start":"2026-04-02 00:00:00","offering_end":"2026-04-08 00:00:00","allotment_date":"","refund_date":"","price_formatted":"168","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":168}},{"ipo_id":"6816","company_symbol":"SUPA","company_name":"PT Super Bank Indonesia","ipo_listing_date":"2025-12-17","ipo_data":"{\"%\": \"13\", \"Price\": \"635\", \"board\": \"\", \"Shares\": \"4,406,612,300\", \"Refund Date\": \"\", \"underwriter\": [\"Mandiri Sekuritas\", \"CLSA Sekuritas Indonesia\", \"Trimegah Sekuritas Indonesia Tbk.\", \"Sucor Sekuritas\", \"Bahana Sekuritas\", \"Korea Investment and Sekuritas Indonesia\"], \"Offering End\": \"2025-12-15 00:00:00\", \"Allotment Date\": \"\", \"Offering Start\": \"2025-12-10 00:00:00\", \"bureau_administration\": \"PT Bima Registra\"}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"635","shares":"4,406,612,300","percentage":"13","offering_start":"2025-12-10 00:00:00","offering_end":"2025-12-15 00:00:00","allotment_date":"","refund_date":"","price_formatted":"635","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":635}},{"ipo_id":"6814","company_symbol":"RLCO","company_name":"PT Abadi Lestari Indonesia","ipo_listing_date":"2025-12-08","ipo_data":"{\"%\": \"20\", \"Price\": \"168\", \"board\": \"\", \"Shares\": \"625,000,000\", \"Refund Date\": \"\", \"underwriter\": [\"Samuel Sekuritas Indonesia\"], \"Offering End\": \"2025-12-04 00:00:00\", \"Allotment Date\": \"\", \"Offering Start\": \"2025-12-02 00:00:00\", \"bureau_administration\": \"PT Adimitra Jasa Korpora\"}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"168","shares":"625,000,000","percentage":"20","offering_start":"2025-12-02 00:00:00","offering_end":"2025-12-04 00:00:00","allotment_date":"","refund_date":"","price_formatted":"168","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":168}},{"ipo_id":"6811","company_symbol":"PJHB","company_name":"PT Pelayaran Jaya Hidup Baru","ipo_listing_date":"2025-11-06","ipo_data":"{\"%\":\"25\",\"Allotment Date\":\"\",\"Offering End\":\"2025-11-04 00:00:00\",\"Offering Start\":\"2025-10-31 00:00:00\",\"Price\":\"330\",\"Refund Date\":\"\",\"Shares\":\"480,000,000\",\"board\":\"\",\"bureau_administration\":\"PT Sinartama Gunita\",\"underwriter\":[\"Pilarmas Investindo Sekuritas\"]}","ipo_created":"","ipo_iqp_id":"","ipo_data_detail":{"price":"330","shares":"480,000,000","percentage":"25","offering_start":"2025-10-31 00:00:00","offering_end":"2025-11-04 00:00:00","allotment_date":"","refund_date":"","price_formatted":"330","listing_board":"","underwriter":[],"bureau_administration":""},"corp_action_active":false,"company_id":"0","ipo_price":{"minimum":0,"maximum":0,"final":330}}]},"message":"Successfully retrieved IPO data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_pubex.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_pubex.json new file mode 100644 index 0000000..dab4693 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_pubex.json @@ -0,0 +1 @@ +{"data":{"pubex":[{"company_id":"1000004517","company_symbol":"MEJA","corp_action_active":false,"puexp_date":"2026-11-24","puexp_id":"156830","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"13:00:00","puexp_venue":"Kantor PT Harta Djaya Karya Tbk, Jl. Bintaro Raya No. 8A, Kec. Kebayoran Lama, Jakarta Selatan 12240"},{"company_id":"450","company_symbol":"VIVA","corp_action_active":false,"puexp_date":"2026-11-17","puexp_id":"156841","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"15:30:00","puexp_venue":"The Convergence Indonesia, Lantai 28, Kawasan Rasuna Epicentrum, Jl. HR. Rasuna Said, Karet Kuningan, Setiabudi, Jakarta Selatan, 12940, Indonesia atau Live event melalui aplikasi Zoom https://bit.ly/OnlinePubExVivaMdia2026"},{"company_id":"512","company_symbol":"MDIA","corp_action_active":false,"puexp_date":"2026-11-17","puexp_id":"156840","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"15:30:00","puexp_venue":"The Convergence Indonesia, Lantai 28, Kawasan Rasuna Epicentrum, Jl. HR. Rasuna Said, Karet Kuningan, Setiabudi, Jakarta Selatan, 12940, Indonesia atau Live event melalui aplikasi Zoom https://bit.ly/OnlinePubExVivaMdia2026"},{"company_id":"1000006367","company_symbol":"WBSA","corp_action_active":false,"puexp_date":"2026-11-12","puexp_id":"156836","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"14:00:00","puexp_venue":"Online/Virtual via Google Meet. Registrasi melalui link: https://bit.ly/WBSApubex2026"},{"company_id":"347","company_symbol":"PTRO","corp_action_active":false,"puexp_date":"2026-11-12","puexp_id":"156833","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"10:00:00","puexp_venue":"Zoom webinar dengan tautan registrasi: / zoom webinar with the following registration link: https://bit.ly/PTRO-PE2026"},{"company_id":"811","company_symbol":"INET","corp_action_active":false,"puexp_date":"2026-11-12","puexp_id":"156835","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"14:00:00","puexp_venue":"Sarana Media Elektronik : Para peserta Public Expose dapat menggunakan tautan akses berikut: https://us06web.zoom.us/j/81220631598?pwd=sbmlCyRX6hIhjuye rU96H4Yi04ageE.1 Meeting ID : 812 2063 1598 Passcode : inet26"},{"company_id":"1000003697","company_symbol":"CHEM","corp_action_active":false,"puexp_date":"2026-11-12","puexp_id":"156832","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"10:00:00","puexp_venue":"Jl Industri ubrug 70 Purwakarta Desa Cibinong Jatiluhur Purwakarta, Jawa Barat 41152"},{"company_id":"78","company_symbol":"BLTA","corp_action_active":false,"puexp_date":"2026-11-12","puexp_id":"156831","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"14:00:00","puexp_venue":"Live event melalui aplikasi Zoom"},{"company_id":"482","company_symbol":"ACST","corp_action_active":false,"puexp_date":"2026-11-12","puexp_id":"156837","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"11:00:00","puexp_venue":"Webinar Zoom Meeting"},{"company_id":"1000004015","company_symbol":"MENN","corp_action_active":true,"puexp_date":"2026-11-10","puexp_id":"156828","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"15:00:00","puexp_venue":"ONLINE"},{"company_id":"1000004498","company_symbol":"UNTD","corp_action_active":true,"puexp_date":"2026-11-09","puexp_id":"156794","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"13:00:00","puexp_venue":"United Bike Building, 2nd Floor (Alam Sutera Boulevard Kav. 12A, Pakulonan, Serpong Utara"},{"company_id":"304","company_symbol":"MTLA","corp_action_active":true,"puexp_date":"2026-11-09","puexp_id":"156825","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"14:00:00","puexp_venue":"Zoom Webinar Perseroan"},{"company_id":"1000000084","company_symbol":"CITY","corp_action_active":true,"puexp_date":"2026-11-09","puexp_id":"156826","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"14:00:00","puexp_venue":"Hotel Nawana, Sentul City, Kab Bogor"},{"company_id":"303","company_symbol":"MTFN","corp_action_active":true,"puexp_date":"2026-11-06","puexp_id":"156823","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"11:00:00","puexp_venue":"Kantor Taman E3.3, Unit D3A, Lantai 5 Jl. DR. Ide Anak Agung Gde Agung, Kuningan Jakarta Selatan"},{"company_id":"23","company_symbol":"AMAG","corp_action_active":true,"puexp_date":"2026-11-06","puexp_id":"156827","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"15:00:00","puexp_venue":"Virtual Zoom Webinar, di PT Asuransi Multi Artha Guna Tbk, Gedung TCC Batavia Tower One, Jalan KH Mas Mansyur Kav 126, Jakarta Pusat"},{"company_id":"46","company_symbol":"AUTO","corp_action_active":true,"puexp_date":"2026-11-05","puexp_id":"156821","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"10:00:00","puexp_venue":"Zoom Webinar"},{"company_id":"1000002677","company_symbol":"AMOR","corp_action_active":true,"puexp_date":"2026-11-04","puexp_id":"156820","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"17:00:00","puexp_venue":"Live Event Melalui aplikasi Zoom https://bit.ly/PUBEXASHMORE2026"},{"company_id":"416","company_symbol":"TFCO","corp_action_active":true,"puexp_date":"2026-11-03","puexp_id":"156838","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"14:00:00","puexp_venue":"Online Google Meeting"},{"company_id":"349","company_symbol":"PTSP","corp_action_active":true,"puexp_date":"2026-11-03","puexp_id":"156839","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"10:00:00","puexp_venue":"Sarana media elektronik video conference melalui aplikasi Zoom Link : https://zoom.us/j/6732025385 Meeting ID : 673 202 5385 Passcode : iCLEAN"},{"company_id":"1000000033","company_symbol":"IPCC","corp_action_active":true,"puexp_date":"2026-11-03","puexp_id":"156818","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"14:00:00","puexp_venue":"Ruang Inovation Room PT Indonesia Kendaraan Terminal Tbk, Jalan Sindang Laut No 100 Jakarta Utara"}]},"message":"Successfully retrieved Public Expose data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_pubex_bbca.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_pubex_bbca.json new file mode 100644 index 0000000..e8fe0d1 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_pubex_bbca.json @@ -0,0 +1 @@ +{"data":{"pubex":[{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"puexp_date":"2026-09-09","puexp_id":"156753","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"16:00:00","puexp_venue":"Public Expose Live 2026 yang tercantum pada website idx.co.id"},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"puexp_date":"2025-09-11","puexp_id":"87667","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"16:00:00","puexp_venue":"Public Expose Live 2025 yang tercantum pada website idx.co.id"},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"puexp_date":"2024-08-28","puexp_id":"36803","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"15:00:00","puexp_venue":"Public Expose Live 2024 Informasi Jadwal Pubex Live 2024 dan pendaftaran peserta di website www.idx.co.id"},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"puexp_date":"2023-11-29","puexp_id":"20156","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"10:00:00","puexp_venue":"Public Expose Live 2023"},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"puexp_date":"2022-09-14","puexp_id":"19470","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"10:00:00","puexp_venue":"Public Expose Live 2022"},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"puexp_date":"2021-09-08","puexp_id":"965","puexp_iqp_id":"","puexp_lastupdate":"","puexp_time":"15:00:00","puexp_venue":"Public Expose Live 2021\t\t\t"}]},"message":"Successfully retrieved Public Expose data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_reversesplit.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_reversesplit.json new file mode 100644 index 0000000..2afad37 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_reversesplit.json @@ -0,0 +1 @@ +{"data":{"stock_reverse":[]},"message":"Successfully retrieved reverse split data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rightissue.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rightissue.json new file mode 100644 index 0000000..48b2567 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rightissue.json @@ -0,0 +1 @@ +{"data":{"rightissue":[{"company_id":"492","company_symbol":"BMAS","corp_action_active":false,"rightissue_adj_factor":0,"rightissue_created":"","rightissue_cumdate":"2026-11-23","rightissue_exdate":"2026-11-24","rightissue_factor":"1.15878","rightissue_id":"11572","rightissue_iqp_id":"","rightissue_lastupdate":"","rightissue_lock":0,"rightissue_new":"104","rightissue_new_share":0,"rightissue_old":"655","rightissue_price":350,"rightissue_price_adj":0,"rightissue_price_factor":0,"rightissue_ratio":"655 : 104","rightissue_recdate":"2026-11-25","rightissue_subdate":"","rightissue_trading_end":"2026-12-03","rightissue_trading_start":"2026-11-27","event_note":"","rightissue_price_formatted":"350","rightissue_foreign_percentage":0,"rightissue_local_percentage":0,"rightissue_number_of_securities":0,"rightissue_company_id":"0","rightissue_total":0},{"company_id":"1000003328","company_symbol":"MGLV","corp_action_active":true,"rightissue_adj_factor":0,"rightissue_created":"","rightissue_cumdate":"2026-11-04","rightissue_exdate":"2026-11-05","rightissue_factor":"1.15","rightissue_id":"11583","rightissue_iqp_id":"","rightissue_lastupdate":"","rightissue_lock":0,"rightissue_new":"15","rightissue_new_share":0,"rightissue_old":"100","rightissue_price":8880,"rightissue_price_adj":0,"rightissue_price_factor":0,"rightissue_ratio":"100 : 15","rightissue_recdate":"2026-11-06","rightissue_subdate":"","rightissue_trading_end":"2026-11-23","rightissue_trading_start":"2026-11-10","event_note":"","rightissue_price_formatted":"8,880","rightissue_foreign_percentage":0,"rightissue_local_percentage":0,"rightissue_number_of_securities":0,"rightissue_company_id":"0","rightissue_total":0},{"company_id":"105","company_symbol":"BUVA","corp_action_active":false,"rightissue_adj_factor":0,"rightissue_created":"","rightissue_cumdate":"2026-10-13","rightissue_exdate":"2026-10-14","rightissue_factor":"1.25","rightissue_id":"11582","rightissue_iqp_id":"","rightissue_lastupdate":"","rightissue_lock":0,"rightissue_new":"1","rightissue_new_share":0,"rightissue_old":"4","rightissue_price":250,"rightissue_price_adj":0,"rightissue_price_factor":0,"rightissue_ratio":"4 : 1","rightissue_recdate":"2026-10-15","rightissue_subdate":"","rightissue_trading_end":"2026-10-30","rightissue_trading_start":"2026-10-19","event_note":"","rightissue_price_formatted":"250","rightissue_foreign_percentage":0,"rightissue_local_percentage":0,"rightissue_number_of_securities":0,"rightissue_company_id":"0","rightissue_total":0},{"company_id":"92","company_symbol":"BRNA","corp_action_active":false,"rightissue_adj_factor":0,"rightissue_created":"","rightissue_cumdate":"2026-10-08","rightissue_exdate":"2026-10-09","rightissue_factor":"1.5556","rightissue_id":"11581","rightissue_iqp_id":"","rightissue_lastupdate":"","rightissue_lock":0,"rightissue_new":"5","rightissue_new_share":0,"rightissue_old":"9","rightissue_price":685,"rightissue_price_adj":0,"rightissue_price_factor":0,"rightissue_ratio":"9 : 5","rightissue_recdate":"2026-10-12","rightissue_subdate":"","rightissue_trading_end":"2026-10-21","rightissue_trading_start":"2026-10-14","event_note":"","rightissue_price_formatted":"685","rightissue_foreign_percentage":0,"rightissue_local_percentage":0,"rightissue_number_of_securities":0,"rightissue_company_id":"0","rightissue_total":0},{"company_id":"12","company_symbol":"AHAP","corp_action_active":false,"rightissue_adj_factor":0,"rightissue_created":"","rightissue_cumdate":"2026-10-08","rightissue_exdate":"2026-10-09","rightissue_factor":"1.7143","rightissue_id":"11580","rightissue_iqp_id":"","rightissue_lastupdate":"","rightissue_lock":0,"rightissue_new":"5","rightissue_new_share":0,"rightissue_old":"7","rightissue_price":50,"rightissue_price_adj":0,"rightissue_price_factor":0,"rightissue_ratio":"7 : 5","rightissue_recdate":"2026-10-12","rightissue_subdate":"","rightissue_trading_end":"2026-10-20","rightissue_trading_start":"2026-10-14","event_note":"","rightissue_price_formatted":"50","rightissue_foreign_percentage":0,"rightissue_local_percentage":0,"rightissue_number_of_securities":0,"rightissue_company_id":"0","rightissue_total":0},{"company_id":"1000004126","company_symbol":"VKTR","corp_action_active":false,"rightissue_adj_factor":0,"rightissue_created":"","rightissue_cumdate":"2026-10-06","rightissue_exdate":"2026-10-07","rightissue_factor":"1.3429","rightissue_id":"11578","rightissue_iqp_id":"","rightissue_lastupdate":"","rightissue_lock":0,"rightissue_new":"12","rightissue_new_share":0,"rightissue_old":"35","rightissue_price":200,"rightissue_price_adj":0,"rightissue_price_factor":0,"rightissue_ratio":"35 : 12","rightissue_recdate":"2026-10-08","rightissue_subdate":"","rightissue_trading_end":"2026-10-23","rightissue_trading_start":"2026-10-12","event_note":"","rightissue_price_formatted":"200","rightissue_foreign_percentage":0,"rightissue_local_percentage":0,"rightissue_number_of_securities":0,"rightissue_company_id":"0","rightissue_total":0},{"company_id":"151","company_symbol":"ENRG","corp_action_active":false,"rightissue_adj_factor":0,"rightissue_created":"","rightissue_cumdate":"2026-10-02","rightissue_exdate":"2026-10-05","rightissue_factor":"1.5","rightissue_id":"11577","rightissue_iqp_id":"","rightissue_lastupdate":"","rightissue_lock":0,"rightissue_new":"1","rightissue_new_share":0,"rightissue_old":"2","rightissue_price":310,"rightissue_price_adj":0,"rightissue_price_factor":0,"rightissue_ratio":"2 : 1","rightissue_recdate":"2026-10-06","rightissue_subdate":"","rightissue_trading_end":"2026-10-21","rightissue_trading_start":"2026-10-08","event_note":"","rightissue_price_formatted":"310","rightissue_foreign_percentage":0,"rightissue_local_percentage":0,"rightissue_number_of_securities":0,"rightissue_company_id":"0","rightissue_total":0}]},"message":"Successfully retrieved rights issue data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rups.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rups.json new file mode 100644 index 0000000..8054f90 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rups.json @@ -0,0 +1 @@ +{"data":{"rups":[{"company_id":"35","company_symbol":"ARTI","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-12-09","rups_id":"1461637","rups_time":"10:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Gedung Ratu Prabu 1 Jl. TB. Simatupang Kav. 20 Jakarta.","rups_eligible_date":"2026-11-12","company_name":"","company_icon_url":""},{"company_id":"1000004211","company_symbol":"MSIE","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-20","rups_id":"1461587","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"IPC Room, IPH Schools 2nd Floor, Jl. Raya Kedung Baruk 112-114 Surabaya","rups_eligible_date":"2026-10-26","company_name":"","company_icon_url":""},{"company_id":"32","company_symbol":"ARII","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-20","rups_id":"1461582","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Jl. Kemang Raya No. 43 Jakarta Selatan diumumkan dan sesuai iklan)","rups_eligible_date":"2026-10-26","company_name":"","company_icon_url":""},{"company_id":"38","company_symbol":"ASGR","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-20","rups_id":"1461631","rups_time":"09:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Mandarin Oriental Hotel - Ballroom, di Jl. M.H. Thamrin, RT.1/RW.5, Menteng, Kec. Menteng, Kota Jakarta Pusat, Daerah Kh","rups_eligible_date":"2026-10-26","company_name":"","company_icon_url":""},{"company_id":"624","company_symbol":"MARK","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-19","rups_id":"1461579","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Wing Hotel Kualanamu diumumkan dan sesuai iklan)","rups_eligible_date":"2026-10-23","company_name":"","company_icon_url":""},{"company_id":"644","company_symbol":"GMFI","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-19","rups_id":"1461624","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Ruang Auditorium, Gedung Manajemen Garuda, Lantai Dasar, Garuda City, Area Perkantoran Bandar Udara International Soekar","rups_eligible_date":"2026-10-23","company_name":"","company_icon_url":""},{"company_id":"168","company_symbol":"GDYR","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-19","rups_id":"1461581","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Ruang Edelweis, Hotel Grand Savero, Bogor, Jl. Padjajaran No 27, Bogor.","rups_eligible_date":"2026-10-23","company_name":"","company_icon_url":""},{"company_id":"1000003658","company_symbol":"ASHA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-19","rups_id":"1461580","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Gedung PT Sutioso Bersaudara Lantai 3 Jl Tuna II Blok D 2, RT.20/RW.17, Penjaringan, Kec. Penjaringan, Jkt Utara, Daerah","rups_eligible_date":"2026-10-23","company_name":"","company_icon_url":""},{"company_id":"1000003819","company_symbol":"NINE","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-18","rups_id":"1461577","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"HARRIS Suites Puri Mansion Puri Mansion Estate, Jl. Puri Lkr. Luar, RT.13/RW.2, Duri Kosambi, Kec. Kembangan, Kota Jakar","rups_eligible_date":"2026-10-22","company_name":"","company_icon_url":""},{"company_id":"181","company_symbol":"GTBO","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-18","rups_id":"1461622","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Ballroom Krakatau Permata Kuningan Building Lantai 2 Jl. Kuningan Mulia Kav. 9C, Guntur, Jakarta 12960, Indonesia","rups_eligible_date":"2026-10-22","company_name":"","company_icon_url":""},{"company_id":"1000003334","company_symbol":"TRUE","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-18","rups_id":"1461578","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Kota Tangerang, Banten diumumkan dan sesuai iklan)","rups_eligible_date":"2026-10-22","company_name":"","company_icon_url":""},{"company_id":"1000003365","company_symbol":"FLMC","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-18","rups_id":"1461575","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Artotel Suites Aquila, Jl. Dr Djunjunan No 116 Bandung","rups_eligible_date":"2026-10-22","company_name":"","company_icon_url":""},{"company_id":"207","company_symbol":"INCO","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-18","rups_id":"1461574","rups_time":"09:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Sudirman Hall, Sequis Tower, Level 2, Jl. Jend. Sudirman Kav. 71, Jakarta 12190, Indonesia","rups_eligible_date":"2026-10-22","company_name":"","company_icon_url":""},{"company_id":"390","company_symbol":"SMMA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-17","rups_id":"1461567","rups_time":"16:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"The Grand Mansion, Jalan Borobudur Nomor 10, Pengangsaan , Menteng, Jakarta Pusat 10320","rups_eligible_date":"2026-10-21","company_name":"","company_icon_url":""},{"company_id":"169","company_symbol":"GEMA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-17","rups_id":"1461568","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"SOUTH78 JL BOULEVARD GADING SERPONG BLOK O NO 7-8 MEDANG PEGEDANGAN TANGERANG","rups_eligible_date":"2026-10-21","company_name":"","company_icon_url":""},{"company_id":"450","company_symbol":"VIVA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-17","rups_id":"1461570","rups_time":"13:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"The Convergence Indonesia, Lantai 28, Kawasan Rasuna Epicentrum, Jl. HR. Rasuna Said, Karet Kuningan, Setiabudi, Jakarta","rups_eligible_date":"2026-10-21","company_name":"","company_icon_url":""},{"company_id":"512","company_symbol":"MDIA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-17","rups_id":"1461569","rups_time":"11:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"The Convergence Indonesia, Lantai 28, Kawasan Rasuna Epicentrum, Jl. HR. Rasuna Said, Karet Kuningan, Setiabudi, Jakarta","rups_eligible_date":"2026-10-21","company_name":"","company_icon_url":""},{"company_id":"1000004142","company_symbol":"AMMN","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-17","rups_id":"1461571","rups_time":"10:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Mengakses fasilitas Electronic General Meeting System pada platform eASY.KSEI","rups_eligible_date":"2026-10-21","company_name":"","company_icon_url":""},{"company_id":"385","company_symbol":"SMAR","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-17","rups_id":"1461572","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Ruang Danamas, Plaza Sinar Mas Land, Menara 2, Lantai 39 Jalan MH. Thamrin No. 51, Jakarta Pusat 10350","rups_eligible_date":"2026-10-21","company_name":"","company_icon_url":""},{"company_id":"429","company_symbol":"TOTL","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-16","rups_id":"1461565","rups_time":"09:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"PT Total Bangun Persada Tbk, Jakarta dan secara elektronik melalui eASY.KSEI Kehadiran fisik yaitu hanya untuk profesi p","rups_eligible_date":"2026-10-20","company_name":"","company_icon_url":""},{"company_id":"1000003200","company_symbol":"FAPA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-16","rups_id":"1461563","rups_time":"09:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Gedung Gold Coast, Tower Liberty Lt. 16 A- H, Jl Pantai Indah Kapuk Kelurahan Kamal Muara Kecamatan Penjaringan, Jakarta","rups_eligible_date":"2026-10-20","company_name":"","company_icon_url":""},{"company_id":"111","company_symbol":"CENT","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-13","rups_id":"1461559","rups_time":"15:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Ruang Meeting Perseroan, TCC Batavia Tower One 16th Jl. KH. Mas Mansyur Kav. 126 Jakarta Pusat DKI Jakarta 10220 Indones","rups_eligible_date":"2026-10-19","company_name":"","company_icon_url":""},{"company_id":"7","company_symbol":"ADHI","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-13","rups_id":"1461561","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"ADHI Tower, Jl. M.T. Haryono Kavling 27, Cawang, Jakarta Timur","rups_eligible_date":"2026-10-19","company_name":"","company_icon_url":""},{"company_id":"1000003481","company_symbol":"ADCP","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-13","rups_id":"1461562","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Kantor Pusat ADHI Jalan Raya Pasar Minggu KM 18 Jakarta Selatan 18510","rups_eligible_date":"2026-10-19","company_name":"","company_icon_url":""},{"company_id":"1000003328","company_symbol":"MGLV","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-12","rups_id":"1461557","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Function Hall Pacific Century Place Lantai B1 Room B Jl. Jend. Sudirman Kav. 52-53, Senayan, Kebayoran Baru, Jakarta Sel","rups_eligible_date":"2026-10-16","company_name":"","company_icon_url":""},{"company_id":"1000003422","company_symbol":"IDEA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-12","rups_id":"1461551","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Aleesha Venue, Jl. Warung Sila No. 1, RT.001/RW.005, Cipedak, Kec. Jagakarsa, Kota Jakarta Selatan, Jakarta 12630","rups_eligible_date":"2026-10-16","company_name":"","company_icon_url":""},{"company_id":"1000003821","company_symbol":"KETR","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-12","rups_id":"1461538","rups_time":"09:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Secara Fisik Rosewood Room, Royal Kuningan Hotel Jl. Kuningan Persada No.2, Kelurahan Guntur, Kecamatan Setiabudi, Jaka","rups_eligible_date":"2026-10-08","company_name":"","company_icon_url":""},{"company_id":"1000003894","company_symbol":"BMBL","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-11-11","rups_id":"1461588","rups_time":"09:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Hotel Daima Suites Margonda diumumkan dan sesuai iklan)","rups_eligible_date":"2026-10-15","company_name":"","company_icon_url":""},{"company_id":"1000003621","company_symbol":"WIRG","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-10","rups_id":"1461640","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"WANG Plaza (Hall of Grace 2 Lantai 2) Jalan Panjang Kav. 17, Kedoya Utara, Kebon Jeruk, Jakarta Barat 11520","rups_eligible_date":"2026-10-28","company_name":"","company_icon_url":""},{"company_id":"361","company_symbol":"RIGS","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-10","rups_id":"1461554","rups_time":"09:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Generali Tower, Gran Rubina Business Park 19th Floor Unit C, Kawasan Rasuna Epicentrum, Jalan H.R. Rasuna Said, Keluraha","rups_eligible_date":"2026-10-14","company_name":"","company_icon_url":""},{"company_id":"1000004066","company_symbol":"DOOH","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-09","rups_id":"1461552","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Ruang Meeting Slipi, Hotel Mercure Batavia Jakarta, Jl. Kali Besar Barat No.44-46, Roa Malaka, Kec. Tambora, Jakarta Bar","rups_eligible_date":"2026-10-13","company_name":"","company_icon_url":""},{"company_id":"1000002301","company_symbol":"ITIC","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-09","rups_id":"1461548","rups_time":"11:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Teak Room 9th Floor at Mercure Hotel Jakarta Pantai Indah Kapuk, PIK Avenue Mall, Pantai Indah Kapuk Boulevard, Jakarta","rups_eligible_date":"2026-10-13","company_name":"","company_icon_url":""},{"company_id":"1000004498","company_symbol":"UNTD","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-09","rups_id":"1461549","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"United Building (Grand Hall Lantai 2), Jalan Boulevard Alam Sutera No. 12 A, Pakulonan, Kec. Serpong Utara, Kota Tangera","rups_eligible_date":"2026-10-13","company_name":"","company_icon_url":""},{"company_id":"447","company_symbol":"UNTR","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-09","rups_id":"1461553","rups_time":"09:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"United Tractors Grand Ballroom, Jl. Raya Bekasi Km 22, Cakung Barat, Kecamatan Cakung, Kota Jakarta Timur, DKI Jakarta 1","rups_eligible_date":"2026-10-13","company_name":"","company_icon_url":""},{"company_id":"1000003820","company_symbol":"KDTN","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-06","rups_id":"1461546","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"PT Puri Sentul Permai Tbk diumumkan dan sesuai iklan)","rups_eligible_date":"2026-10-12","company_name":"","company_icon_url":""},{"company_id":"5035","company_symbol":"INPS","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-06","rups_id":"1461545","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Gedung Inprase, Jl. Sunter Garden Raya Blok D8 No. 3G-3H, Sunter Agung, Tanjung Priok, Jakarta Utara, DKI Jakarta 14350","rups_eligible_date":"2026-10-07","company_name":"","company_icon_url":""},{"company_id":"172","company_symbol":"GIAA","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-06","rups_id":"1461547","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Secara elektronik melalui sistem eASY.KSEI (https//akses.ksei.co.id/)","rups_eligible_date":"2026-10-12","company_name":"","company_icon_url":""},{"company_id":"443","company_symbol":"ULTJ","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-06","rups_id":"1461528","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Kantor Perseroan, Jalan Raya Cimareme No 131 Bandung Barat, Jawa Barat Indonesia","rups_eligible_date":"2026-08-31","company_name":"","company_icon_url":""},{"company_id":"303","company_symbol":"MTFN","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-06","rups_id":"1461544","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Kantor Taman E3.3, Unit D3A, Lantai 5, Jl. DR. Ide Anak Agung Gde Agung, Kuningan Jakarta Selatan","rups_eligible_date":"2026-10-12","company_name":"","company_icon_url":""},{"company_id":"1000000005","company_symbol":"BRIS","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-06","rups_id":"1461596","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Jakarta Pusat, melalui fasilitas Electronic General Meeting System KSEI (eASY.KSEI) dalam tautan https//akses.ksei.co.id","rups_eligible_date":"2026-10-12","company_name":"","company_icon_url":""},{"company_id":"52","company_symbol":"BATA","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-05","rups_id":"1461542","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Gedung Ventura, lantai 7. Jl. Raden Ajeng Kartini No.26, Cilandak Barat, Jakarta Selatan","rups_eligible_date":"2026-10-09","company_name":"","company_icon_url":""},{"company_id":"1000002677","company_symbol":"AMOR","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-04","rups_id":"1461539","rups_time":"16:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Secara online melalui fasilitas Electronic General Meeting System KSEI (eASY.KSEI) dalam tautan https//akses.ksei.co.id","rups_eligible_date":"2026-10-08","company_name":"","company_icon_url":""},{"company_id":"358","company_symbol":"RDTX","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-04","rups_id":"1461537","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"RDTX SQUARE PODIUM LANTAI 2 JL. PROF. DR. SATRIO NO. 164, JAKARTA SELATAN 12930","rups_eligible_date":"2026-10-08","company_name":"","company_icon_url":""},{"company_id":"1000005447","company_symbol":"MINE","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-04","rups_id":"1461583","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"The Function Room (Ruang Anggrek 5) Lantai 3A, North Tower, Sampoerna Strategic Square, Jl. Jenderal Sudirman No.45 - 46","rups_eligible_date":"2026-10-08","company_name":"","company_icon_url":""},{"company_id":"5028","company_symbol":"BOSS","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-04","rups_id":"1461634","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Wisma 77, Tower I, Lt 8, Jl Letjend S Parman, Slipi, Jakarta Barat","rups_eligible_date":"2026-10-02","company_name":"","company_icon_url":""},{"company_id":"1000002176","company_symbol":"MTPS","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-03","rups_id":"1461612","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Meta Epsi Building Jl. Mayjen D.I Panjaitan Kav. 2, Rawa Bunga, Jatinegara - Jakarta Timur 13350","rups_eligible_date":"2026-10-22","company_name":"","company_icon_url":""},{"company_id":"1000002971","company_symbol":"EPAC","corp_action_active":true,"rups_created":"","rups_datahash":"","rups_date":"2026-11-03","rups_id":"1461536","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"IBIS Style Jakarta Tanah Abang, Jl. Fachrudin No. 22, Kp. Bali, Tanah Abang, Jakarta Pusat 10250","rups_eligible_date":"2026-10-07","company_name":"","company_icon_url":""}]},"message":"Successfully retrieved RUPS/Shareholders meeting data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rups_bbca.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rups_bbca.json new file mode 100644 index 0000000..80fbfce --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_rups_bbca.json @@ -0,0 +1 @@ +{"data":{"rups":[{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2026-03-12","rups_id":"1460182","rups_time":"14:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta 10310","rups_eligible_date":"2026-02-09","company_name":"","company_icon_url":""},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2025-03-12","rups_id":"860258","rups_time":"09:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Menara BCA, Grand Indonesia, Jl. M.H. Thamrin No. 1, Jakarta, 10310","rups_eligible_date":"2025-02-07","company_name":"","company_icon_url":""},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2024-03-14","rups_id":"385363","rups_time":"09:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Menara BCA Grand Indonesia Lt 18.Jl. MH Thamrin No 1 Jakarta Selatan","rups_eligible_date":"2024-02-07","company_name":"","company_icon_url":""},{"company_id":"0","company_symbol":"BBCA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2023-03-16","rups_id":"368621","rups_time":"09:30","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Menara BCA","rups_eligible_date":"2023-02-13","company_name":"","company_icon_url":""},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2022-03-17","rups_id":"365637","rups_time":"09:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Menara BCA, Grand Indonesia\nJl. M.H. Thamrin No. 1\nJakarta","rups_eligible_date":"2022-02-14","company_name":"","company_icon_url":""},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2021-09-23","rups_id":"356628","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Menara BCA, Grand Indonesia\nJl. M.H. Thamrin No. 1\nJakarta","rups_eligible_date":"2021-08-27","company_name":"","company_icon_url":""},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2021-03-29","rups_id":"314659","rups_time":"09:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Menara BCA, Grand Indonesia, Lt 19. Jl. M.H Thamrin No 1. Jakarta\t\t\t\t ","rups_eligible_date":"2021-02-24","company_name":"","company_icon_url":""},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"rups_created":"","rups_datahash":"","rups_date":"2020-07-30","rups_id":"314133","rups_time":"10:00","rups_iqp_agenda":"","rups_iqp_id":"","rups_iqp_rec_dt":"","rups_iqp_remark":"","rups_iqp_result":"","rups_iqp_revised_date":"","rups_iqp_type":"","rups_venue":"Menara BCA Grand Indonesia, Lt. 19. Jl. M.H. Thamrin No. 1. Jakarta\t\t\t ","rups_eligible_date":"2020-07-03","company_name":"","company_icon_url":""}]},"message":"Successfully retrieved RUPS/Shareholders meeting data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stock_dividend.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stock_dividend.json new file mode 100644 index 0000000..11eb9e0 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stock_dividend.json @@ -0,0 +1 @@ +{"data":{"stock_dividend":[]},"message":"Successfully retrieved stock dividend data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stocksplit.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stocksplit.json new file mode 100644 index 0000000..a1b3346 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stocksplit.json @@ -0,0 +1 @@ +{"data":{"stocksplit":[{"company_id":"601","company_symbol":"PRDA","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2026-12-17","stocksplit_exdate":"2026-12-18","stocksplit_factor":"5","stocksplit_id":"6100","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"5","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 5","stocksplit_recdate":"2026-12-21","event_note":""},{"company_id":"600","company_symbol":"PBSA","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2026-10-13","stocksplit_exdate":"2026-10-14","stocksplit_factor":"2","stocksplit_id":"6099","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"2","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 2","stocksplit_recdate":"2026-10-15","event_note":""},{"company_id":"488","company_symbol":"MLPT","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2026-07-20","stocksplit_exdate":"2026-07-21","stocksplit_factor":"25","stocksplit_id":"6095","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"25","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 25","stocksplit_recdate":"2026-07-22","event_note":""},{"company_id":"1000003487","company_symbol":"RMKE","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2026-07-16","stocksplit_exdate":"2026-07-17","stocksplit_factor":"5","stocksplit_id":"6094","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"5","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 5","stocksplit_recdate":"2026-07-20","event_note":""},{"company_id":"354","company_symbol":"RAJA","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2026-07-15","stocksplit_exdate":"2026-07-16","stocksplit_factor":"5","stocksplit_id":"6092","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"5","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 5","stocksplit_recdate":"2026-07-17","event_note":""},{"company_id":"1000004216","company_symbol":"CYBR","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2026-05-12","stocksplit_exdate":"2026-05-13","stocksplit_factor":"2","stocksplit_id":"6091","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"2","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 2","stocksplit_recdate":"2026-05-18","event_note":""},{"company_id":"1000004217","company_symbol":"CYBR-W","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2026-05-12","stocksplit_exdate":"2026-05-13","stocksplit_factor":"2","stocksplit_id":"6093","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"2","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 2","stocksplit_recdate":"2026-05-18","event_note":""},{"company_id":"143","company_symbol":"DSSA","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2026-04-08","stocksplit_exdate":"2026-04-09","stocksplit_factor":"25","stocksplit_id":"6089","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"25","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 25","stocksplit_recdate":"2026-04-10","event_note":""}]},"message":"Successfully retrieved stock split data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stocksplit_bbca.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stocksplit_bbca.json new file mode 100644 index 0000000..ecbd334 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_stocksplit_bbca.json @@ -0,0 +1 @@ +{"data":{"stocksplit":[{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2021-10-12","stocksplit_exdate":"2021-10-13","stocksplit_factor":"5","stocksplit_id":"3091","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"5","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 5","stocksplit_recdate":"2021-10-14","event_note":""},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2008-01-25","stocksplit_exdate":"2008-01-28","stocksplit_factor":"2","stocksplit_id":"3","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"2","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 2","stocksplit_recdate":"2008-01-30","event_note":""},{"company_id":"54","company_symbol":"BBCA","corp_action_active":false,"stocksplit_created":"","stocksplit_cumdate":"2004-06-07","stocksplit_exdate":"2004-06-08","stocksplit_factor":"2","stocksplit_id":"1061","stocksplit_iqp_id":"","stocksplit_lastupdate":"","stocksplit_lock":0,"stocksplit_new":"2","stocksplit_new_price":0,"stocksplit_new_share":0,"stocksplit_old":"1","stocksplit_ratio":"1 : 2","stocksplit_recdate":"2004-06-10","event_note":""}]},"message":"Successfully retrieved stock split data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_tenderoffer.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_tenderoffer.json new file mode 100644 index 0000000..8d6c778 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_tenderoffer.json @@ -0,0 +1 @@ +{"data":{"tender":[{"company_id":"46","company_name":"Astra Otoparts Tbk.","company_symbol":"AUTO","corp_action_active":true,"tender_created":"","tender_datahash":"","tender_end":"2026-11-11","tender_id":"434","tender_paydate":"2026-11-18","tender_percentage":"4.95","tender_price":"3600","tender_shares":"238442293","tender_start":"2026-10-13","event_note":"","tender_price_formatted":"3,600"},{"company_id":"1000003921","company_name":"Hassana Boga Sejahtera Tbk.","company_symbol":"NAYZ","corp_action_active":true,"tender_created":"","tender_datahash":"","tender_end":"2026-11-03","tender_id":"433","tender_paydate":"2026-11-10","tender_percentage":"45.84","tender_price":"75","tender_shares":"1169011472","tender_start":"2026-10-05","event_note":"","tender_price_formatted":"75"},{"company_id":"1000004066","company_name":"Era Media Sejahtera Tbk.","company_symbol":"DOOH","corp_action_active":true,"tender_created":"","tender_datahash":"","tender_end":"2026-11-03","tender_id":"432","tender_paydate":"2026-11-09","tender_percentage":"33.91","tender_price":"148","tender_shares":"2624548624","tender_start":"2026-10-05","event_note":"","tender_price_formatted":"148"},{"company_id":"409","company_name":"Solusi Tunas Pratama Tbk.","company_symbol":"SUPR","corp_action_active":true,"tender_created":"","tender_datahash":"","tender_end":"2026-10-21","tender_id":"431","tender_paydate":"2026-11-02","tender_percentage":"74.39","tender_price":"45000","tender_shares":"729102","tender_start":"2026-09-24","event_note":"","tender_price_formatted":"45,000"},{"company_id":"278","company_name":"Mitrabahtera Segara Sejati Tbk.","company_symbol":"MBSS","corp_action_active":false,"tender_created":"","tender_datahash":"","tender_end":"2026-10-08","tender_id":"430","tender_paydate":"2026-10-15","tender_percentage":"17.50","tender_price":"2915","tender_shares":"306259839","tender_start":"2026-09-09","event_note":"","tender_price_formatted":"2,915"},{"company_id":"194","company_name":"Inti Bangun Sejahtera Tbk.","company_symbol":"IBST","corp_action_active":false,"tender_created":"","tender_datahash":"","tender_end":"2026-10-02","tender_id":"429","tender_paydate":"2026-10-14","tender_percentage":"0.05","tender_price":"5400","tender_shares":"650832","tender_start":"2026-09-04","event_note":"","tender_price_formatted":"5,400"}]},"message":"Successfully retrieved tender offer data"} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_warrant.json b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_warrant.json new file mode 100644 index 0000000..04c3ecc --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_corpaction_warrant.json @@ -0,0 +1 @@ +{"data":{"warrant":[{"company_id":"92","company_symbol":"BRNA","corp_action_active":true,"wrant_exc_end":"2029-10-15","wrant_exc_from":"2027-04-16","wrant_exc_price":"800","wrant_id":"3570","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2029-10-10","wrant_trading_from":"2026-10-16","event_note":"","wrant_exc_price_formatted":"800","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007050","company_symbol":"ACESYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"3000","wrant_id":"3586","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"3,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007051","company_symbol":"AKRAYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"8000","wrant_id":"3587","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"8,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007052","company_symbol":"ARTOYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"8000","wrant_id":"3588","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"8,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007053","company_symbol":"ASIIYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"12000","wrant_id":"3589","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"12,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007054","company_symbol":"CUANYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"5000","wrant_id":"3590","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"5,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007055","company_symbol":"DEWAYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"5000","wrant_id":"3591","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"5,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007056","company_symbol":"ELSAYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"5000","wrant_id":"3592","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"5,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007057","company_symbol":"EMTKYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"5000","wrant_id":"3593","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"5,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007058","company_symbol":"ERAAYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"5000","wrant_id":"3594","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"5,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007059","company_symbol":"ESSAYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"5000","wrant_id":"3595","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"5,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007060","company_symbol":"EXCLYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"8000","wrant_id":"3596","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"8,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007061","company_symbol":"HRTAYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"8000","wrant_id":"3597","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"8,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007062","company_symbol":"INKPYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"30000","wrant_id":"3598","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"30,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007063","company_symbol":"JPFAYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"8000","wrant_id":"3599","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"8,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007064","company_symbol":"MAPIYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"8000","wrant_id":"3600","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"8,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007065","company_symbol":"NCKLYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"5000","wrant_id":"3601","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"5,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007066","company_symbol":"PGASYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"5000","wrant_id":"3602","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"5,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007067","company_symbol":"TAPGYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"10000","wrant_id":"3603","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"10,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007068","company_symbol":"TLKMYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"8000","wrant_id":"3604","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"8,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007069","company_symbol":"TPIAYUCK7A","corp_action_active":true,"wrant_exc_end":"2027-05-28","wrant_exc_from":"2026-10-14","wrant_exc_price":"15000","wrant_id":"3605","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-05-25","wrant_trading_from":"2026-10-14","event_note":"","wrant_exc_price_formatted":"15,000","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007032","company_symbol":"ARTOZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"900","wrant_id":"3571","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"900","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007033","company_symbol":"ASIIZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"5094","wrant_id":"3572","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"5,094","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007034","company_symbol":"BRMSZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"700","wrant_id":"3573","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"700","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007035","company_symbol":"BRPTZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"1700","wrant_id":"3574","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"1,700","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007036","company_symbol":"CTRAZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"600","wrant_id":"3575","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"600","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007037","company_symbol":"CUANZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"1100","wrant_id":"3576","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"1,100","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007038","company_symbol":"EMTKZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"300","wrant_id":"3577","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"300","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007039","company_symbol":"ENRGZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"1300","wrant_id":"3578","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"1,300","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007040","company_symbol":"HRUMZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"1050","wrant_id":"3579","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"1,050","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007041","company_symbol":"KIJAZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"190","wrant_id":"3580","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"190","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007042","company_symbol":"MDKAZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"3300","wrant_id":"3581","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"3,300","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007043","company_symbol":"MEDCZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"1700","wrant_id":"3582","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"1,700","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007044","company_symbol":"NCKLZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"1050","wrant_id":"3583","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"1,050","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007045","company_symbol":"TOWRZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"390","wrant_id":"3584","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"390","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"},{"company_id":"1000007046","company_symbol":"WIFIZPCN7A","corp_action_active":true,"wrant_exc_end":"2027-07-30","wrant_exc_from":"2026-10-09","wrant_exc_price":"1600","wrant_id":"3585","wrant_iqp_id":"","wrant_lastupdate":"","wrant_serie":"","wrant_total":"","wrant_trading_end":"2027-07-27","wrant_trading_from":"2026-10-09","event_note":"","wrant_exc_price_formatted":"1,600","wrant_foreign_percentage":0,"wrant_local_percentage":0,"wrant_number_of_securities":0,"wrant_company_id":"0"}]},"message":"Successfully retrieved warrant data"} diff --git a/crates/idx-mcp/src/params.rs b/crates/idx-mcp/src/params.rs index 50c4d42..3142955 100644 --- a/crates/idx-mcp/src/params.rs +++ b/crates/idx-mcp/src/params.rs @@ -4,6 +4,7 @@ use idx_core::analysis::bandar::TIERS; use idx_core::api::types::{Interval, Period}; use idx_core::broker::types::{BrokerBoard, BrokerInvestor}; +use idx_core::corporate::types::ActionKind; use idx_core::flow::types::FlowSource; use idx_core::market::{ScreenFilter, ScreenRegion}; use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema}; @@ -228,6 +229,41 @@ pub struct FlowParams { pub source: Option, } +#[derive(Debug, Deserialize, JsonSchema)] +pub struct CorporateActionsParams { + /// IDX ticker, e.g. "BBCA". + pub symbol: String, + /// Kinds to list (default: every kind but "ipo"). Each kind is one request to Stockbit. + #[serde(default)] + #[schemars(schema_with = "action_kinds_schema")] + pub kinds: Option>, +} + +#[derive(Debug, Deserialize, JsonSchema)] +pub struct CorporateCalendarParams { + /// First day, YYYY-MM-DD (default today). + #[serde(default)] + pub from: Option, + /// Last day, YYYY-MM-DD (default 30 days after `from`; at most 366 days). + #[serde(default)] + pub to: Option, + /// Kinds to list (default: every kind). Each kind is one request to Stockbit. + #[serde(default)] + #[schemars(schema_with = "action_kinds_schema")] + pub kinds: Option>, +} + +/// Parses `kinds`, or `default` when absent. +pub fn action_kinds( + kinds: Option>, + default: &[ActionKind], +) -> Result, idx_core::error::IdxError> { + match kinds { + None => Ok(default.to_vec()), + Some(kinds) => kinds.iter().map(|k| k.parse()).collect(), + } +} + #[derive(Debug, Deserialize, JsonSchema)] pub struct ShareholdersParams { /// IDX ticker, e.g. "BBCA". @@ -305,6 +341,11 @@ fn flow_source_schema(_: &mut SchemaGenerator) -> Schema { string_enum(FlowSource::ALL.map(FlowSource::as_str).to_vec()) } +fn action_kinds_schema(_: &mut SchemaGenerator) -> Schema { + let kinds: Vec<&str> = ActionKind::ALL.iter().map(|k| k.as_str()).collect(); + json_schema!({ "type": "array", "items": { "type": "string", "enum": kinds } }) +} + fn login_method_schema(_: &mut SchemaGenerator) -> Schema { string_enum(LoginMethod::ALL.map(LoginMethod::as_str).to_vec()) } diff --git a/crates/idx-mcp/src/server.rs b/crates/idx-mcp/src/server.rs index 3b9b4a0..bcf375c 100644 --- a/crates/idx-mcp/src/server.rs +++ b/crates/idx-mcp/src/server.rs @@ -10,6 +10,7 @@ use idx_core::analysis::fundamental::FundamentalReport; use idx_core::api::stockbit::{self, signin}; use idx_core::broker::types::BrokerRange; use idx_core::config::CoreConfig; +use idx_core::corporate::types::{ActionKind, CalendarRange}; use idx_core::error::IdxError; use idx_core::financial::{EarningsFilter, StatementFilter}; use idx_core::flow::types::FlowRange; @@ -27,9 +28,9 @@ use tokio::sync::Semaphore; use crate::params::{ AnalysisKind, AnalyzeParams, BandarParams, BrokerParams, ChangesParams, CompanyParams, - CompanySection, EntityParams, FlowParams, HistoryParams, IntradayParams, LoginMethod, - LoginParams, OrderBookParams, ScreenParams, SearchParams, ShareholdersParams, SymbolsParams, - SyncParams, + CompanySection, CorporateActionsParams, CorporateCalendarParams, EntityParams, FlowParams, + HistoryParams, IntradayParams, LoginMethod, LoginParams, OrderBookParams, ScreenParams, + SearchParams, ShareholdersParams, SymbolsParams, SyncParams, action_kinds, }; const SYNC_TOOL: &str = "ownership_sync"; @@ -352,6 +353,54 @@ average price, the close, `change_bps` and `non_regular_bps`." .await } + #[tool( + description = "Corporate actions of one IDX stock from the user's own Stockbit \ +session, newest first: `kind` (dividend, stock-dividend, bonus, rights, warrant, split, \ +reverse-split, meeting, expose, ipo, tender), `date` (the cum date for dividends, bonuses, \ +rights and splits, i.e. the last day to buy and be entitled; else the event's first day), \ +`ex_date`, `record_date`, `pay_date`, and per kind `cash_per_share` (IDR, may have decimals), \ +`ratio` {old, new} (1:5 split = 1 share becomes 5; 655:104 rights = 104 rights per 655 held), \ +`factor` (price adjustment), `price` (rights, warrant exercise, tender or IPO price, IDR), \ +`period` and `exercise` {start, end}, `shares`, `percentage_bps`, `time`, `venue`. Absent \ +fields are omitted. One Stockbit request per kind (about 1 s each on a cold cache, then cached \ +6 hours). AUTHERROR means there is no session: call stockbit_status, then stockbit_login." + )] + async fn get_corporate_actions( + &self, + params: Parameters, + ) -> ToolResult { + let CorporateActionsParams { symbol, kinds } = params.0; + self.live(move |idx| { + let kinds = action_kinds(kinds, &ActionKind::STOCK_DEFAULT)?; + idx.corporate() + .actions(&symbol, &kinds, CachePolicy::Default) + }) + .await + } + + #[tool( + description = "Corporate actions across IDX from the user's own Stockbit session, \ +oldest first, dated from `from` to `to` (default today and the next 30 days): upcoming cum \ +dates, meetings, exposes, rights, warrants, IPOs and tender offers, and the past year. Each \ +item has the same fields as get_corporate_actions, with `symbol`. One Stockbit request per \ +kind (about 1 s each on a cold cache, then cached 6 hours); pass `kinds` to ask for less. \ +AUTHERROR means there is no session: call stockbit_status, then stockbit_login." + )] + async fn get_corporate_calendar( + &self, + params: Parameters, + ) -> ToolResult { + let CorporateCalendarParams { from, to, kinds } = params.0; + self.live(move |idx| { + let corporate = idx.corporate(); + let range = + CalendarRange::from_args(from.as_deref(), to.as_deref(), corporate.today())?; + let kinds = action_kinds(kinds, &ActionKind::ALL)?; + corporate.calendar(range, &kinds, CachePolicy::Default) + }) + .await + } + #[tool( description = "Company data for one IDX ticker: profile, financial statements, \ earnings, analyst sentiment, insights, and news. News items carry `relevance`: \ diff --git a/crates/idx-mcp/tests/golden/tools.json b/crates/idx-mcp/tests/golden/tools.json index 51ce573..b4a8878 100644 --- a/crates/idx-mcp/tests/golden/tools.json +++ b/crates/idx-mcp/tests/golden/tools.json @@ -235,6 +235,91 @@ }, "name": "get_company" }, + { + "description": "Corporate actions of one IDX stock from the user's own Stockbit session, newest first: `kind` (dividend, stock-dividend, bonus, rights, warrant, split, reverse-split, meeting, expose, ipo, tender), `date` (the cum date for dividends, bonuses, rights and splits, i.e. the last day to buy and be entitled; else the event's first day), `ex_date`, `record_date`, `pay_date`, and per kind `cash_per_share` (IDR, may have decimals), `ratio` {old, new} (1:5 split = 1 share becomes 5; 655:104 rights = 104 rights per 655 held), `factor` (price adjustment), `price` (rights, warrant exercise, tender or IPO price, IDR), `period` and `exercise` {start, end}, `shares`, `percentage_bps`, `time`, `venue`. Absent fields are omitted. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours). AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "kinds": { + "default": null, + "description": "Kinds to list (default: every kind but \"ipo\"). Each kind is one request to Stockbit.", + "items": { + "enum": [ + "dividend", + "stock-dividend", + "bonus", + "rights", + "warrant", + "split", + "reverse-split", + "meeting", + "expose", + "ipo", + "tender" + ], + "type": "string" + }, + "type": "array" + }, + "symbol": { + "description": "IDX ticker, e.g. \"BBCA\".", + "type": "string" + } + }, + "required": [ + "symbol" + ], + "type": "object" + }, + "name": "get_corporate_actions" + }, + { + "description": "Corporate actions across IDX from the user's own Stockbit session, oldest first, dated from `from` to `to` (default today and the next 30 days): upcoming cum dates, meetings, exposes, rights, warrants, IPOs and tender offers, and the past year. Each item has the same fields as get_corporate_actions, with `symbol`. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours); pass `kinds` to ask for less. AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "from": { + "default": null, + "description": "First day, YYYY-MM-DD (default today).", + "type": [ + "string", + "null" + ] + }, + "kinds": { + "default": null, + "description": "Kinds to list (default: every kind). Each kind is one request to Stockbit.", + "items": { + "enum": [ + "dividend", + "stock-dividend", + "bonus", + "rights", + "warrant", + "split", + "reverse-split", + "meeting", + "expose", + "ipo", + "tender" + ], + "type": "string" + }, + "type": "array" + }, + "to": { + "default": null, + "description": "Last day, YYYY-MM-DD (default 30 days after `from`; at most 366 days).", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "name": "get_corporate_calendar" + }, { "description": "Foreign investors' buying and selling of one IDX ticker, session by session (oldest first), with range totals; end of day. With `source` \"ipot\" (default): `foreign_buy_value`, `foreign_sell_value` and `foreign_net_value` in IDR across all boards, `value` traded, and `foreign_share_bps` (foreign share of trading); share counts, close and `non_regular_bps` are null, and `rounded` = true means one decimal of precision. With \"idx\": exact foreign share counts on the regular board, values estimated at the session's average price, the close, `change_bps` and `non_regular_bps`.", "inputSchema": { diff --git a/crates/idx-mcp/tests/mcp.rs b/crates/idx-mcp/tests/mcp.rs index 94321e6..5274ffc 100644 --- a/crates/idx-mcp/tests/mcp.rs +++ b/crates/idx-mcp/tests/mcp.rs @@ -9,12 +9,14 @@ use idx_core::config::CoreConfig; use idx_core::investor::{ImportSource, Investor}; use serde_json::{Value, json}; -const TOOLS: [&str; 18] = [ +const TOOLS: [&str; 20] = [ "analyze_bandar", "analyze_stock", "compare_stocks", "get_broker_summary", "get_company", + "get_corporate_actions", + "get_corporate_calendar", "get_foreign_flow", "get_intraday", "get_investor_holdings", @@ -502,6 +504,53 @@ fn the_order_book_needs_a_session_and_status_never_shows_tokens() { } } +#[test] +fn corporate_actions_need_a_session_and_keep_kinds_apart() { + let mut client = Client::start(&[], false); + let (is_error, body) = client.call("get_corporate_actions", json!({"symbol": "BBCA"})); + assert!(is_error, "{body}"); + assert_eq!(body["code"], "AUTHERROR"); + + let mut client = Client::start_with_env( + &[], + false, + &[TEST_SESSION, ("IDX_MOCK_TODAY", "2026-11-03")], + ); + let actions = client.ok( + "get_corporate_actions", + json!({"symbol": "BBCA", "kinds": ["dividend", "split"]}), + ); + assert_fetched(&actions); + assert_eq!(actions["source"], "stockbit"); + let rows = actions["data"].as_array().unwrap(); + assert_eq!(rows.len(), 40, "37 dividends and 3 splits"); + assert_eq!(rows[0]["kind"], "dividend"); + assert_eq!(rows[0]["date"], "2026-08-28"); + assert_eq!(rows[0]["cash_per_share"], 25.0); + assert!(rows[0].get("ratio").is_none(), "absent fields are omitted"); + let split = rows.iter().find(|r| r["kind"] == "split").unwrap(); + assert_eq!(split["ratio"], json!({"old": 1, "new": 5})); + + let calendar = client.ok( + "get_corporate_calendar", + json!({"to": "2026-11-12", "kinds": ["rights", "dividend"]}), + ); + let rows = calendar["data"].as_array().unwrap(); + assert_eq!(rows[0]["symbol"], "MGLV.JK"); + assert_eq!(rows[0]["price"], 8880); + assert!( + rows.windows(2) + .all(|w| w[0]["date"].as_str() <= w[1]["date"].as_str()) + ); + + let (is_error, body) = client.call( + "get_corporate_actions", + json!({"symbol": "BBCA", "kinds": ["rups"]}), + ); + assert!(is_error, "{body}"); + assert_eq!(body["code"], "INVALIDINPUT"); +} + #[test] fn errors_carry_cli_codes() { let mut client = Client::start(&[], false); diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 158163d..0997cd4 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -283,6 +283,19 @@ WIB as the fallback. provider uses Stockbit's daily windows (`5d` to `1y`, trimmed from `1m`, `3m` or `1y`), Yahoo otherwise. Without one, quotes use the public page and the order book is `AUTHERROR`. +- Corporate actions (`corporate/`, `api/stockbit/corpaction.rs`): + `/corpaction/{type}` per kind (`dividend`, `stock_dividend`, `bonus`, + `rightissue`, `warrant`, `stocksplit`, `reversesplit`, `rups`, `pubex`, + `ipo`, `tenderoffer`), with `?symbol=` for one stock's history or without + for the market (about a year back and what is announced ahead). Each type + has its own field prefix and the list key is not always the path's, so + entitlements are read by field suffix (`_cumdate`, `_exdate`, ...). One + request per kind, cached 6 hours under `stockbit-corpaction` + (`:` or `:market`); `stocks actions` / + `get_corporate_actions` sort newest first, `stocks calendar` / + `get_corporate_calendar` filter by `CorporateAction::date` (the cum date + for entitlements) and sort oldest first. Endpoint notes and the wider + design: `docs/STOCKBIT.md`. ### Capability Gating ``` @@ -296,6 +309,7 @@ Factory functions: trading_summary_provider() → Box intraday_provider() → Box orderbook_provider() → Box + corporate_action_provider() → Box ``` `ProviderKind::Stockbit` serves quotes (and, with a session, daily history): diff --git a/docs/STOCKBIT.md b/docs/STOCKBIT.md index c2f14aa..037de85 100644 --- a/docs/STOCKBIT.md +++ b/docs/STOCKBIT.md @@ -44,7 +44,7 @@ All on `https://exodus.stockbit.com`, bearer access token, HTTP 200 on | `/company-price-feed/market-time/session` | market state | shipped (#74) | | `/charts/{SYM}/daily?timeframe=1m\|3m\|1y` | daily candles | shipped (#74) | | `/charts/{SYM}/daily?timeframe=1w` | hourly candles, 5 sessions | P2 | -| `/corpaction/{type}[?symbol=SYM]` | corporate actions and calendar | **P1** | +| `/corpaction/{type}[?symbol=SYM]` | corporate actions and calendar | shipped: `stocks actions`, `stocks calendar` | | `/insider/company/majorholder` | insider / major-holder movements | **P1** | | `/insider/shareholding/composition/companies/{SYM}` | holder composition by period | P2 | | `/marketdetectors/{SYM}` | broker summary, Stockbit's bandar detector | P2 | @@ -95,9 +95,12 @@ Hourly history needs a datetime bar (`Ohlc.date` is a `NaiveDate`) and an hourly `Interval`, across Yahoo, MSN, output, goldens and the MCP schema; that is its own change. -## P1: corporate actions +## P1: corporate actions (shipped) -idx has none today (only the `high-dividend` screen and Yahoo's dividend +Shipped as `idx stocks actions`, `idx stocks calendar` (not a top-level +`calendar`: it sits beside `stocks screen`) and the MCP tools +`get_corporate_actions`, `get_corporate_calendar`; the notes below are the +endpoint as recorded. Before, idx had none (only the `high-dividend` screen and Yahoo's dividend yield). They explain price gaps in history (splits, bonuses, rights) and give a calendar of cum dates. @@ -151,10 +154,10 @@ lists are not errors. A row whose dates are all placeholders is dropped. ### Surface -- `idx stocks actions SYM [--kind dividend,rights,...] [--since DATE]`: one - stock's history, newest first. -- `idx calendar [--kind ...] [--from DATE] [--to DATE]`: market-wide, default - today to +30 days, sorted by the next relevant date. +- `idx stocks actions SYM [--kind dividend,rights,...]`: one stock's + history, newest first; every kind but `ipo` by default. +- `idx stocks calendar [--kind ...] [--from DATE] [--to DATE]`: market-wide, + default today to +30 days, oldest first by `date`. - MCP: `get_corporate_actions {symbol, kinds?, since?}`, `get_corporate_calendar {kinds?, from?, to?}`. - Later: `stocks history` notes ex-dates of splits, bonuses and rights in the @@ -231,7 +234,8 @@ Yahoo prices, forward 5/20/60-session returns against IHSG). 1. Close #74: the open-state name in trading hours, fixtures for the observed states (done 2026-11-03). -2. Corporate actions (parsers, `stocks actions`, `calendar`, MCP, goldens). +2. Corporate actions (parsers, `stocks actions`, `stocks calendar`, MCP, + goldens) (done). 3. Shareholder movements, rows first, then `--summary`. 4. Event study for the movement score; P2 by demand. diff --git a/web/src/content/docs/cli/reference.md b/web/src/content/docs/cli/reference.md index 46a4df4..e02f3a4 100644 --- a/web/src/content/docs/cli/reference.md +++ b/web/src/content/docs/cli/reference.md @@ -68,6 +68,8 @@ Commands: quote Get real-time stock quotes intraday Today's session price by the minute (Stockbit) orderbook Order book depth and foreign flow (Stockbit login) + actions Dividends, rights, splits and other corporate actions of a stock (Stockbit login) + calendar Upcoming and recent corporate actions across the market (Stockbit login) history Get historical OHLC data technical Run technical analysis on a stock growth Run growth analysis on a stock @@ -223,6 +225,132 @@ Examples: idx -o json stocks orderbook TLKM | jq '.offers[0]' ``` +### `idx stocks actions` + +```text +One IDX stock's corporate actions from your own Stockbit session (`idx stockbit login`), newest first: cash and stock dividends, bonus shares, rights issues, warrants, splits and reverse splits, shareholders' meetings, public exposes and tender offers (`--kind ipo` adds its IPO). Stockbit serves one kind per request, 1 s apart, so the first call takes about a second per kind; answers are cached for 6 hours. + +Usage: idx stocks actions [OPTIONS] + +Arguments: + + Single ticker symbol (e.g. BBCA) + +Options: + --kind ... + Kinds to list (default: all but ipo) + + Possible values: + - dividend: Cash dividend + - stock-dividend + - bonus: Bonus shares + - rights: Rights issue (HMETD) + - warrant + - split: Stock split + - reverse-split + - meeting: Shareholders' meeting (RUPS) + - expose: Public expose + - ipo + - tender + + -o, --output + Output format [default: auto = table on a terminal, json when piped] + + [possible values: auto, table, json, jsonl] + + --no-color + Disable colored output + + -q, --quiet + Suppress non-essential output + + -v, --verbose... + Increase verbosity (-v, -vv) + + --provider + Market data provider [default: general.provider, else msn] + + [possible values: yahoo, msn, stockbit] + + --offline + Run without network requests + + --no-cache + Bypass local cache + + -h, --help + Print help (see a summary with '-h') + +Examples: + idx stocks actions BBCA + idx stocks actions TLKM --kind dividend + idx -o json stocks actions BBRI --kind dividend,split | jq '.[0]' +``` + +### `idx stocks calendar` + +```text +Corporate actions across IDX from your own Stockbit session (`idx stockbit login`), oldest first, dated within --from and --to (default: today and the next 30 days). An action's date is its cum date for dividends, bonuses, rights and splits, else the event's first day. Stockbit lists about a year back and what is announced ahead. One request per kind, 1 s apart; answers are cached for 6 hours. + +Usage: idx stocks calendar [OPTIONS] + +Options: + --from + First day, YYYY-MM-DD. Default: today + + -o, --output + Output format [default: auto = table on a terminal, json when piped] + + [possible values: auto, table, json, jsonl] + + --no-color + Disable colored output + + --to + Last day, YYYY-MM-DD. Default: 30 days after --from (at most 366) + + --kind ... + Kinds to list (default: all) + + Possible values: + - dividend: Cash dividend + - stock-dividend + - bonus: Bonus shares + - rights: Rights issue (HMETD) + - warrant + - split: Stock split + - reverse-split + - meeting: Shareholders' meeting (RUPS) + - expose: Public expose + - ipo + - tender + + -q, --quiet + Suppress non-essential output + + -v, --verbose... + Increase verbosity (-v, -vv) + + --provider + Market data provider [default: general.provider, else msn] + + [possible values: yahoo, msn, stockbit] + + --offline + Run without network requests + + --no-cache + Bypass local cache + + -h, --help + Print help (see a summary with '-h') + +Examples: + idx stocks calendar + idx stocks calendar --kind dividend,rights + idx stocks calendar --from 2026-12-01 --to 2026-12-31 --kind meeting +``` + ### `idx stocks history` ```text diff --git a/web/src/content/docs/cli/stockbit.md b/web/src/content/docs/cli/stockbit.md index 4ab02a0..5c54f8f 100644 --- a/web/src/content/docs/cli/stockbit.md +++ b/web/src/content/docs/cli/stockbit.md @@ -75,6 +75,8 @@ idx stockbit login # paste the credentialStorage cookie idx stockbit status # logged in? when do the tokens expire? idx stocks orderbook BBCA # depth, queued orders, foreign flow idx stocks orderbook BBRI --depth 5 +idx stocks actions BBCA # dividends, splits, meetings, ... +idx stocks calendar --kind dividend # cum dates in the next 30 days idx --provider stockbit stocks quote BBCA # live, not delayed idx --provider stockbit stocks history BBCA --period 1y # Stockbit's daily candles idx stockbit logout @@ -198,6 +200,7 @@ What the login adds: | `stocks orderbook` | `AUTHERROR` | every level with lots and queued orders, OHLC, value, trades; foreign buy/sell/net once Stockbit marks them current | | `stocks history` under `--provider stockbit` | Yahoo | Stockbit's daily candles for `5d` to `1y`; Yahoo for other windows | | `stocks intraday` | public page | public page | +| `stocks actions`, `stocks calendar` | `AUTHERROR` | corporate actions: one stock's history, or the market's calendar | The order book is what Stockbit's own app shows. Outside trading it is the book as the market left it, and the output says so. Foreign buy, sell and net @@ -218,7 +221,7 @@ Stockbit. Use this for looking at a stock now and then, not for crawling the market or republishing prices. With your login, automated use is tied to your account: keep it human-paced. -Over MCP, the same data comes from `get_intraday`, `get_orderbook` and -`stockbit_status`, and from `get_quotes` and `get_price_history` when the +Over MCP, the same data comes from `get_intraday`, `get_orderbook`, +`get_corporate_actions`, `get_corporate_calendar` and `stockbit_status`, and from `get_quotes` and `get_price_history` when the server runs with `IDX_PROVIDER=stockbit`. The server never logs in; run `idx stockbit login` in a terminal. diff --git a/web/src/content/docs/cli/stocks.md b/web/src/content/docs/cli/stocks.md index 3a9ecb5..634dfb6 100644 --- a/web/src/content/docs/cli/stocks.md +++ b/web/src/content/docs/cli/stocks.md @@ -46,6 +46,28 @@ value and trades, and foreign buy, sell and net once Stockbit marks them current (not during trading, when they lag a day). Without one it answers `AUTHERROR`. See [Stockbit](/cli/stockbit/#with-your-stockbit-login). +## Corporate actions (Stockbit login) + +```bash +idx stocks actions BBCA # newest first +idx stocks actions TLKM --kind dividend +idx stocks calendar # today and the next 30 days +idx stocks calendar --kind dividend,rights --to 2026-12-31 +``` + +`actions` lists one stock's cash and stock dividends, bonus shares, rights +issues, warrants, splits and reverse splits, shareholders' meetings, public +exposes and tender offers (`--kind ipo` adds its IPO). `calendar` lists them +across the market between `--from` and `--to` (at most 366 days), including +what is announced ahead. An action's date is its cum date for dividends, +bonuses, rights and splits: buy by then to be entitled. For the others it is +the event's first day. Dividends per share keep their decimals (`Rp 3.8`). + +Both need your Stockbit session and answer `AUTHERROR` without one. Stockbit +serves one kind per request, 1 s apart, so a first call with every kind takes +about ten seconds; answers are then cached for 6 hours. `--kind` asks for +less. + ## Company data | Command | What it shows | diff --git a/web/src/content/docs/mcp/index.md b/web/src/content/docs/mcp/index.md index 81e8628..d73870a 100644 --- a/web/src/content/docs/mcp/index.md +++ b/web/src/content/docs/mcp/index.md @@ -5,9 +5,9 @@ description: idx-mcp serves idx's stock and ownership data to AI agents over MCP `idx-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server over stdio. It gives an agent the same data as the `idx` CLI, as -[17 tools](/mcp/tools/) (plus an opt-in `ownership_sync`): quotes, today's -session by the minute, the order book (with a Stockbit login), price -history, screening, company data, analysis, comparison, broker summaries, +[20 tools](/mcp/tools/) (plus an opt-in `ownership_sync`): quotes, today's +session by the minute, the order book and corporate actions (with a Stockbit +login), price history, screening, company data, analysis, comparison, broker summaries, bandarmology, foreign flow, and the KSEI ownership queries. It shares idx's [config, cache and ownership database](/start/config/#files-idx-keeps), diff --git a/web/src/content/docs/mcp/tools.md b/web/src/content/docs/mcp/tools.md index ca4c98a..19e1260 100644 --- a/web/src/content/docs/mcp/tools.md +++ b/web/src/content/docs/mcp/tools.md @@ -63,6 +63,25 @@ Company data for one IDX ticker: profile, financial statements, earnings, analys | `sections` | array of `profile` / `financials` / `earnings` / `sentiment` / `insights` / `news` | no | Sections to fetch (default: all). | | `symbol` | string | yes | IDX ticker, e.g. "BBCA". | +## `get_corporate_actions` + +Corporate actions of one IDX stock from the user's own Stockbit session, newest first: `kind` (dividend, stock-dividend, bonus, rights, warrant, split, reverse-split, meeting, expose, ipo, tender), `date` (the cum date for dividends, bonuses, rights and splits, i.e. the last day to buy and be entitled; else the event's first day), `ex_date`, `record_date`, `pay_date`, and per kind `cash_per_share` (IDR, may have decimals), `ratio` {old, new} (1:5 split = 1 share becomes 5; 655:104 rights = 104 rights per 655 held), `factor` (price adjustment), `price` (rights, warrant exercise, tender or IPO price, IDR), `period` and `exercise` {start, end}, `shares`, `percentage_bps`, `time`, `venue`. Absent fields are omitted. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours). AUTHERROR means there is no session: call stockbit_status, then stockbit_login. + +| Input | Type | Required | Description | +| --- | --- | --- | --- | +| `kinds` | array of `dividend` / `stock-dividend` / `bonus` / `rights` / `warrant` / `split` / `reverse-split` / `meeting` / `expose` / `ipo` / `tender` | no | Kinds to list (default: every kind but "ipo"). Each kind is one request to Stockbit. | +| `symbol` | string | yes | IDX ticker, e.g. "BBCA". | + +## `get_corporate_calendar` + +Corporate actions across IDX from the user's own Stockbit session, oldest first, dated from `from` to `to` (default today and the next 30 days): upcoming cum dates, meetings, exposes, rights, warrants, IPOs and tender offers, and the past year. Each item has the same fields as get_corporate_actions, with `symbol`. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours); pass `kinds` to ask for less. AUTHERROR means there is no session: call stockbit_status, then stockbit_login. + +| Input | Type | Required | Description | +| --- | --- | --- | --- | +| `from` | string | no | First day, YYYY-MM-DD (default today). | +| `kinds` | array of `dividend` / `stock-dividend` / `bonus` / `rights` / `warrant` / `split` / `reverse-split` / `meeting` / `expose` / `ipo` / `tender` | no | Kinds to list (default: every kind). Each kind is one request to Stockbit. | +| `to` | string | no | Last day, YYYY-MM-DD (default 30 days after `from`; at most 366 days). | + ## `get_foreign_flow` Foreign investors' buying and selling of one IDX ticker, session by session (oldest first), with range totals; end of day. With `source` "ipot" (default): `foreign_buy_value`, `foreign_sell_value` and `foreign_net_value` in IDR across all boards, `value` traded, and `foreign_share_bps` (foreign share of trading); share counts, close and `non_regular_bps` are null, and `rounded` = true means one decimal of precision. With "idx": exact foreign share counts on the regular board, values estimated at the session's average price, the close, `change_bps` and `non_regular_bps`. From 73735767bb1a732f77a05f648dcf99f175f05be8 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Tue, 3 Nov 2026 14:37:38 +0700 Subject: [PATCH 03/16] test(smoke): live cases for the Stockbit session (orderbook, actions, calendar) Run only when `idx stockbit status` reports a session. They keep the user's real config directory, which holds the session: an isolated copy would refresh on its own and spend the user's rotating refresh token. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- scripts/live-smoke.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/live-smoke.sh b/scripts/live-smoke.sh index 7281509..026911f 100755 --- a/scripts/live-smoke.sh +++ b/scripts/live-smoke.sh @@ -71,10 +71,14 @@ LOG_DIR="$WORKDIR/logs" COMMON_ENV=("IDX_PROVIDER=msn" "IDX_HISTORY_PROVIDER=auto" "IDX_NO_COLOR=1") # Each binary gets its own config, cache, and data so both really fetch. +# Stockbit session cases keep the user's real config directory, which holds +# the session: a copy would refresh on its own and spend the user's rotating +# refresh token, while the real file is shared under its lock. +REAL_CONFIG=0 side_env() { local home="$WORKDIR/$1" - printf '%s\n' "XDG_CONFIG_HOME=$home/config" "XDG_CACHE_HOME=$home/cache" \ - "XDG_DATA_HOME=$home/data" "${COMMON_ENV[@]}" + (( REAL_CONFIG )) || printf '%s\n' "XDG_CONFIG_HOME=$home/config" + printf '%s\n' "XDG_CACHE_HOME=$home/cache" "XDG_DATA_HOME=$home/data" "${COMMON_ENV[@]}" } # Values of these commands should not move between two back-to-back runs. @@ -128,6 +132,10 @@ contract() { echo '(.highlights | type == "array") and (.risks | type == "array")' ;; "stocks news "*) echo 'type == "array" and all(.[]; (.title | type == "string") and (.url | type == "string"))' ;; + "stocks orderbook "*) + echo '(.symbol | type == "string") and (.price | type == "number") and (.market_status | type == "string") and (.bids | type == "array") and (.offers | type == "array")' ;; + "stocks actions "*|"stocks calendar"*) + echo 'type == "array" and length > 0 and all(.[]; (.symbol | type == "string") and (.kind | type == "string") and (.date | type == "string"))' ;; "stocks broker "*) echo '(.symbol | type == "string") and (.buyers | length > 0) and (.sellers | length > 0) and all(.buyers[]; (.code | type == "string") and (.value | type == "number")) and (.total_value | type == "number")' ;; "stocks bandar "*) @@ -253,6 +261,16 @@ if selected stockbit; then run_new_case intraday "stocks intraday $SYMBOL" run_new_case intraday-index "stocks intraday ^JKSE" run_new_case quote-stockbit "--provider stockbit stocks quote $SYMBOL" + # With the user's own session (`idx stockbit login`), if there is one. + if (( DRY_RUN )) || "${BIN_PATH:-idx}" -o json stockbit status 2>/dev/null | jq -e '.logged_in' >/dev/null; then + REAL_CONFIG=1 + run_new_case orderbook "stocks orderbook $SYMBOL --depth 5" + run_new_case actions "stocks actions $SYMBOL --kind dividend,split" + run_new_case calendar "stocks calendar --kind dividend,rights" + REAL_CONFIG=0 + else + echo " no Stockbit session: orderbook, actions and calendar not run" + fi fi if selected ownership; then From 1b72c3ed6b1b27323a60d4b7ddf0d767643b552f Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Tue, 3 Nov 2026 14:38:04 +0700 Subject: [PATCH 04/16] docs(smoke): the Stockbit session cases and why they share the real config Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- docs/SMOKE.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/SMOKE.md b/docs/SMOKE.md index 63df67c..b87705f 100644 --- a/docs/SMOKE.md +++ b/docs/SMOKE.md @@ -62,9 +62,12 @@ scripts/live-smoke.sh --dry-run `--provider stockbit stocks quote`, on the new binary only. A run outside the session sees `market_status: close` and no bid/offer. These run without a Stockbit login: each side has its own config, and seeding it with a real - refresh token would rotate (and so retire) that token. Check the login - features by hand with your own session: `idx stockbit status`, - `idx stocks orderbook BBCA`, `idx --provider stockbit stocks quote BBCA` and + refresh token would rotate (and so retire) that token. When + `idx stockbit status` reports a session, `stocks orderbook`, `stocks actions` + and `stocks calendar` also run, on the new binary with your real config + directory (the session file is shared under its lock, never copied; cache + and data stay isolated). Check the rest by hand: + `idx --provider stockbit stocks quote BBCA` and `idx --provider stockbit stocks history BBCA --period 1y`. - `ownership`: `discover`, then imports the newest supported report into a temp DB and lists `releases`. IDX sits behind Cloudflare and returns `403` to many From ae0ca0c1096e281753d5f74046ab3eb8c45d3a4b Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Tue, 3 Nov 2026 16:02:26 +0700 Subject: [PATCH 05/16] feat: shareholder movements from the Stockbit session (ownership movements) `idx ownership movements [SYMBOL]` and the MCP tool `get_shareholder_movements` list reported changes in insiders' and major holders' stakes, newest first, from Stockbit's /insider/company/majorholder: IDX insider disclosures (any size, with the trade price) and KSEI changes of holders at 5% and above (Stockbit's estimated price). Stockbit filters by date range, holder id, action and source; each page is 50 rows and one request, up to 10 pages, cached an hour per page under every filter. Rows keep exact signed share counts and the stake in basis points as Stockbit rounds it; unknown action labels are kept as `other` rather than dropped. JSON is {movements, more}; JSONL is one movement per line. The command lives under `ownership` but needs no import, and `ownership` commands now take --offline / --no-cache for it. The per-symbol summary score is the next PR; docs/STOCKBIT.md records the endpoint's parameters and action types as checked on 2026-11-03. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- README.md | 7 +- ROADMAP.md | 6 +- crates/idx-cli/src/cli/ownership.rs | 81 +++- crates/idx-cli/src/main.rs | 4 +- crates/idx-cli/src/output/mod.rs | 16 + crates/idx-cli/src/output/table.rs | 110 +++++ crates/idx-cli/tests/golden/cases.toml | 24 + .../tests/golden/completions-bash.golden | 93 +++- .../golden/error-movements-holder.json.golden | 4 + .../error-movements-holder.table.golden | 4 + .../error-movements-no-session.json.golden | 4 + .../error-movements-no-session.table.golden | 4 + .../tests/golden/help-ownership.golden | 1 + .../ownership-movements-bbca.json.golden | 4 + .../ownership-movements-bbca.table.golden | 26 ++ ...ownership-movements-ksei-sells.json.golden | 4 + ...wnership-movements-ksei-sells.table.golden | 15 + .../golden/ownership-movements.json.golden | 4 + .../golden/ownership-movements.table.golden | 37 ++ crates/idx-core/src/api/mock.rs | 37 +- crates/idx-core/src/api/mod.rs | 19 + crates/idx-core/src/api/stockbit/exodus.rs | 22 +- crates/idx-core/src/api/stockbit/mod.rs | 14 +- crates/idx-core/src/api/stockbit/movement.rs | 328 +++++++++++++ crates/idx-core/src/client.rs | 4 + crates/idx-core/src/lib.rs | 1 + crates/idx-core/src/movements/mod.rs | 124 +++++ crates/idx-core/src/movements/types.rs | 334 ++++++++++++++ .../fixtures/stockbit_exodus_majorholder.json | 416 +++++++++++++++++ .../stockbit_exodus_majorholder_bbca.json | 430 ++++++++++++++++++ .../stockbit_exodus_majorholder_bbca_p2.json | 220 +++++++++ .../stockbit_exodus_majorholder_p2.json | 314 +++++++++++++ crates/idx-mcp/src/params.rs | 41 ++ crates/idx-mcp/src/server.rs | 41 +- crates/idx-mcp/tests/golden/tools.json | 70 +++ crates/idx-mcp/tests/mcp.rs | 51 ++- docs/ARCHITECTURE.md | 8 + docs/STOCKBIT.md | 35 +- web/src/content/docs/cli/ownership.md | 26 ++ web/src/content/docs/cli/reference.md | 74 +++ web/src/content/docs/cli/stockbit.md | 4 +- web/src/content/docs/mcp/index.md | 4 +- web/src/content/docs/mcp/tools.md | 14 + 43 files changed, 3050 insertions(+), 29 deletions(-) create mode 100644 crates/idx-cli/tests/golden/error-movements-holder.json.golden create mode 100644 crates/idx-cli/tests/golden/error-movements-holder.table.golden create mode 100644 crates/idx-cli/tests/golden/error-movements-no-session.json.golden create mode 100644 crates/idx-cli/tests/golden/error-movements-no-session.table.golden create mode 100644 crates/idx-cli/tests/golden/ownership-movements-bbca.json.golden create mode 100644 crates/idx-cli/tests/golden/ownership-movements-bbca.table.golden create mode 100644 crates/idx-cli/tests/golden/ownership-movements-ksei-sells.json.golden create mode 100644 crates/idx-cli/tests/golden/ownership-movements-ksei-sells.table.golden create mode 100644 crates/idx-cli/tests/golden/ownership-movements.json.golden create mode 100644 crates/idx-cli/tests/golden/ownership-movements.table.golden create mode 100644 crates/idx-core/src/api/stockbit/movement.rs create mode 100644 crates/idx-core/src/movements/mod.rs create mode 100644 crates/idx-core/src/movements/types.rs create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_majorholder.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_bbca.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_bbca_p2.json create mode 100644 crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_p2.json diff --git a/README.md b/README.md index 8b5281c..695c8d3 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,8 @@ idx ownership changes --from 2026-07-31 --to 2026-08-31 market is open, delayed at least 10 minutes. With your own account (`idx stockbit login`): `stocks orderbook` depth, live quotes, Stockbit daily history, and corporate actions (`stocks actions`, - `stocks calendar`: dividends, rights, splits, meetings, IPOs and more). Personal use under Stockbit's terms; see + `stocks calendar`: dividends, rights, splits, meetings, IPOs and more), and + insider and major holder buys and sells (`ownership movements`). Personal use under Stockbit's terms; see the [Stockbit page](https://idx.rasyidanaf.com/cli/stockbit/) - Local file cache with TTL, and `--offline` mode with stale-cache fallback @@ -166,9 +167,9 @@ change it to `auto` with `idx config set general.output auto`. ## MCP server -`idx-mcp` serves the same data to MCP clients over stdio, as 20 tools: +`idx-mcp` serves the same data to MCP clients over stdio, as 21 tools: `get_quotes`, `get_intraday`, `get_orderbook`, `get_corporate_actions`, -`get_corporate_calendar`, `stockbit_status`, `stockbit_login`, `get_price_history`, `screen_stocks`, `get_company`, +`get_corporate_calendar`, `get_shareholder_movements`, `stockbit_status`, `stockbit_login`, `get_price_history`, `screen_stocks`, `get_company`, `analyze_stock`, `compare_stocks`, `get_broker_summary`, `analyze_bandar`, `get_foreign_flow`, `get_shareholders`, `get_investor_holdings`, `search_investors`, `get_ownership_changes`, and `ownership_status`. Live results come wrapped as diff --git a/ROADMAP.md b/ROADMAP.md index 88d1ea7..a2929cd 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -14,8 +14,10 @@ history lives in git. - Multi-period financial statements (today `financials` is single-period) - Order book depth without a login: no free source exists (IDX sells delayed depth to vendors); `stocks orderbook` needs the user's Stockbit login. -- Shareholder movements (`ownership movements`) from the Stockbit session; - design and endpoints in `docs/STOCKBIT.md`. Corporate-action follow-ups: +- Shareholder movement follow-ups (`docs/STOCKBIT.md`): `ownership movements + --summary`, a per-symbol score (net value, distinct buyers, share-plan + flag), then an event study before calling any of it a signal; joining + holders to ownership entities by name. Corporate-action follow-ups: ex-dates of splits, bonuses and rights noted in `stocks history`, and the `stock_dividend` / `reversesplit` row shapes once Stockbit lists one. - Stockbit login follow-ups: hourly OHLCV from the session's `1w` chart (the diff --git a/crates/idx-cli/src/cli/ownership.rs b/crates/idx-cli/src/cli/ownership.rs index 125952f..cd2850f 100644 --- a/crates/idx-cli/src/cli/ownership.rs +++ b/crates/idx-cli/src/cli/ownership.rs @@ -13,9 +13,11 @@ use idx_core::error::IdxError; use idx_core::investor::{ ConcentrationRank, HolderSource, ImportSource, Investor, parse_report_family, }; +use idx_core::movements::types::{ActionFilter, MovementQuery, MovementSource}; use idx_core::ownership::graph; use idx_core::ownership::snapshot; use idx_core::ownership::types::{ChangeType, FlowSignal, HolderRow, OwnershipSource}; +use idx_core::{CachePolicy, Idx}; #[derive(Debug, Args)] #[command( @@ -72,6 +74,17 @@ pub enum OwnershipCommand { after_help = "Examples:\n idx ownership releases\n idx ownership changes --from 2026-08-31 --to 2026-09-30" )] Changes(ChangesArgs), + #[command( + about = "Insider and major holder buys and sells, as reported (Stockbit login)", + long_about = "Reported changes in holders' stakes from your own Stockbit session (`idx \ +stockbit login`), newest first: IDX insider disclosures (directors, commissioners and other \ +insiders, any size, with the trade price) and KSEI's changes of holders at 5% and above (Stockbit \ +estimates their price). One stock's, or the whole market's without SYMBOL. Each page is 50 rows \ +and one request; answers are cached for an hour.\n\nThese are filings, not signals: a share \ +plan shows as many insiders buying at one price, and a row appears days after the change.", + after_help = "Examples:\n idx ownership movements BBCA\n idx ownership movements --action sell --source ksei\n idx ownership movements --from 2026-10-01 --to 2026-10-31 --pages 5\n idx ownership movements --holder 1000004481 # one holder's history (HOLDER ID column)" + )] + Movements(MovementsArgs), /// Ownership network graph. Graph(GraphArgs), /// Manual entity resolution workflow. @@ -168,6 +181,30 @@ pub struct ChangesArgs { pub to: String, } +#[derive(Debug, Args)] +pub struct MovementsArgs { + /// Single ticker symbol (e.g. BBCA); omit for the whole market. + pub symbol: Option, + /// First day, YYYY-MM-DD. + #[arg(long)] + pub from: Option, + /// Last day, YYYY-MM-DD. + #[arg(long)] + pub to: Option, + /// One holder's movements, by the id in the HOLDER ID column. + #[arg(long = "holder", value_name = "ID")] + pub holder_id: Option, + /// Only this kind of movement. + #[arg(long, value_enum)] + pub action: Option, + /// Only IDX insider disclosures or KSEI 5% holder changes. + #[arg(long, value_enum)] + pub source: Option, + /// Pages of 50 rows to read (1-10). + #[arg(long, default_value_t = 1)] + pub pages: u32, +} + #[derive(Debug, Args)] pub struct GraphArgs { /// Ticker code or entity name to start from. @@ -209,7 +246,15 @@ pub enum ResolveCommand { }, } -pub fn handle(cmd: &OwnershipCommand, config: &IdxConfig) -> Result<(), IdxError> { +pub fn handle( + cmd: &OwnershipCommand, + config: &IdxConfig, + offline: bool, + no_cache: bool, +) -> Result<(), IdxError> { + if let OwnershipCommand::Movements(args) = cmd { + return handle_movements(args, config, CachePolicy::from_flags(offline, no_cache)?); + } let investor = Investor::new(&config.core); let inv = &investor; match cmd { @@ -223,6 +268,9 @@ pub fn handle(cmd: &OwnershipCommand, config: &IdxConfig) -> Result<(), IdxError OwnershipCommand::Concentration(args) => handle_concentration(inv, args, config), OwnershipCommand::Flow(args) => handle_flow(inv, args, config), OwnershipCommand::Changes(args) => handle_changes(inv, args, config), + OwnershipCommand::Movements(args) => { + handle_movements(args, config, CachePolicy::from_flags(offline, no_cache)?) + } OwnershipCommand::Graph(args) => handle_graph(inv, args, config), OwnershipCommand::Resolve(args) => handle_resolve(inv, args, config), OwnershipCommand::Releases => handle_releases(inv, config), @@ -678,6 +726,37 @@ fn handle_changes( Ok(()) } +fn handle_movements( + args: &MovementsArgs, + config: &IdxConfig, + policy: CachePolicy, +) -> Result<(), IdxError> { + let mut query = MovementQuery::from_args( + args.symbol.as_deref(), + args.from.as_deref(), + args.to.as_deref(), + args.holder_id.as_deref(), + args.pages, + )?; + query.action = args.action; + query.source = args.source; + let idx = Idx::new(config.core.clone())?; + let list = idx.movements().list(&query, policy)?; + let symbol = match &query.symbol { + Some(symbol) => Some(idx_core::api::resolve_symbol( + symbol, + &config.core.exchange, + )?), + None => None, + }; + crate::output::render_shareholder_movements( + symbol.as_deref(), + &list.data, + &config.output, + config.no_color, + ) +} + fn handle_resolve( investor: &Investor, args: &ResolveArgs, diff --git a/crates/idx-cli/src/main.rs b/crates/idx-cli/src/main.rs index bbaab3f..e7da72d 100644 --- a/crates/idx-cli/src/main.rs +++ b/crates/idx-cli/src/main.rs @@ -81,7 +81,9 @@ fn run() -> Result<(), IdxError> { } #[cfg(feature = "ownership")] Commands::Ownership(cmd) => { - if let Err(err) = cli::ownership::handle(&cmd.command, &config) { + if let Err(err) = + cli::ownership::handle(&cmd.command, &config, cli.offline, cli.no_cache) + { emit_error(&err, &config.output); return Err(err); } diff --git a/crates/idx-cli/src/output/mod.rs b/crates/idx-cli/src/output/mod.rs index 83dd257..633acb2 100644 --- a/crates/idx-cli/src/output/mod.rs +++ b/crates/idx-cli/src/output/mod.rs @@ -22,6 +22,7 @@ use idx_core::config::ProviderKind; use idx_core::corporate::types::{CalendarRange, CorporateAction}; use idx_core::error::IdxError; use idx_core::flow::types::ForeignFlow; +use idx_core::movements::types::MovementList; /// Output format requested by the user (flag, `IDX_OUTPUT`, or config file). #[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Eq, Serialize, serde::Deserialize, Default)] @@ -126,6 +127,21 @@ pub fn render_corporate_calendar( } } +/// JSON is `{movements, more}` (`more`: rows remain past the pages read); +/// JSONL is one movement per line. +pub fn render_shareholder_movements( + symbol: Option<&str>, + list: &MovementList, + format: &OutputFormat, + no_color: bool, +) -> Result<(), IdxError> { + match format { + OutputFormat::Table => table::print_shareholder_movements(symbol, list, no_color), + OutputFormat::Json => json::print_json(list), + OutputFormat::Jsonl => json::print_json(&list.movements), + } +} + pub fn render_broker_summary( summary: &BrokerSummary, format: &OutputFormat, diff --git a/crates/idx-cli/src/output/table.rs b/crates/idx-cli/src/output/table.rs index 994c454..35cb88d 100644 --- a/crates/idx-cli/src/output/table.rs +++ b/crates/idx-cli/src/output/table.rs @@ -18,6 +18,9 @@ use idx_core::broker::types::{BrokerBoard, BrokerFlow, BrokerInvestor, BrokerKin use idx_core::corporate::types::{ActionKind, CalendarRange, CorporateAction, DateRange}; use idx_core::error::IdxError; use idx_core::flow::types::{FlowSource, ForeignFlow}; +use idx_core::movements::types::{ + MovementAction, MovementList, MovementSource, ShareholderMovement, +}; pub fn format_idr(value: i64) -> String { let sign = if value.is_negative() { "-" } else { "" }; @@ -1855,6 +1858,113 @@ pub fn print_corporate_calendar( Ok(()) } +fn movement_action_label(action: MovementAction, no_color: bool) -> String { + let label = action.as_str().replace('_', " "); + match action { + _ if no_color => label, + MovementAction::Buy => label.green().to_string(), + MovementAction::Sell => label.red().to_string(), + _ => label, + } +} + +/// Signed exact shares: `+147,933`, `-10,000,000`. +fn format_signed_shares(value: i64) -> String { + let text = format_idr(value); + if value > 0 { format!("+{text}") } else { text } +} + +/// The stake after the change and the change in percentage points: +/// `40.65% (-0.16)`. A stake that rounds to 0 basis points reads `<0.01%`. +fn movement_stake(movement: &ShareholderMovement) -> String { + let after = match movement.percentage_after_bps { + 0 if movement.shares_after > 0 => "<0.01%".to_string(), + bps => format!("{:.2}%", bps as f64 / 100.0), + }; + match movement.percentage_change_bps { + 0 => after, + bps => format!("{after} ({:+.2})", bps as f64 / 100.0), + } +} + +const MOVEMENT_NOTE: &str = "IDX rows are insider disclosures (directors, commissioners and \ +other insiders); KSEI rows are changes of holders at 5% and above. ~ marks Stockbit's estimated \ +price. Rows appear days after the change."; + +pub fn print_shareholder_movements( + symbol: Option<&str>, + list: &MovementList, + no_color: bool, +) -> Result<(), IdxError> { + let title = match symbol { + Some(symbol) => format!("Shareholder movements for {}", terminal_safe(symbol)), + None => "Shareholder movements across IDX".to_string(), + }; + println!("{}", format!("{title} ({})", list.movements.len()).bold()); + if list.movements.is_empty() { + println!("No movements reported for this query."); + } else { + let mut table = Table::new(); + table + .load_preset(UTF8_FULL) + .set_content_arrangement(ContentArrangement::Dynamic) + .set_header(vec![ + "DATE", + "SYMBOL", + "HOLDER", + "ROLE", + "ACTION", + "SHARES", + "STAKE", + "PRICE", + "VALUE", + "SOURCE", + "HOLDER ID", + ]); + for movement in &list.movements { + let estimated = if movement.price_estimated { "~" } else { "" }; + table.add_row(vec![ + cell(movement.date), + cell(&movement.symbol), + cell(&movement.holder), + cell(if movement.roles.is_empty() { + "-".to_string() + } else { + movement.roles.join(", ") + }), + painted(movement_action_label(movement.action, no_color)), + cell(format_signed_shares(movement.shares_change)), + cell(movement_stake(movement)), + cell( + movement + .price + .map(|p| format!("{estimated}{}", format_idr(p))) + .unwrap_or_else(|| "-".to_string()), + ), + cell( + movement + .value + .map(|v| format!("{estimated}{}", format_compact(v))) + .unwrap_or_else(|| "-".to_string()), + ), + cell(match movement.source { + Some(MovementSource::Idx) => "IDX", + Some(MovementSource::Ksei) => "KSEI", + None => "-", + }), + cell(&movement.holder_id), + ]); + } + println!("{table}"); + println!("{MOVEMENT_NOTE}"); + } + if list.more { + println!("More rows exist: raise --pages (up to 10) or narrow --from/--to."); + } + println!("{STOCKBIT_SESSION_NOTE}"); + Ok(()) +} + #[cfg(test)] mod tests { use super::{ diff --git a/crates/idx-cli/tests/golden/cases.toml b/crates/idx-cli/tests/golden/cases.toml index 942f618..af7eced 100644 --- a/crates/idx-cli/tests/golden/cases.toml +++ b/crates/idx-cli/tests/golden/cases.toml @@ -420,6 +420,15 @@ args = ["stocks", "orderbook", "BBCA"] name = "error-actions-no-session" args = ["stocks", "actions", "BBCA"] +[[case]] +name = "error-movements-no-session" +args = ["ownership", "movements", "BBCA"] + +[[case]] +name = "error-movements-holder" +args = ["ownership", "movements", "--holder", "RUDI"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln" } + [[case]] name = "error-calendar-range" args = ["stocks", "calendar", "--from", "2026-11-10", "--to", "2026-11-01"] @@ -432,6 +441,21 @@ env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0OD # --- ownership -------------------------------------------------------------------- +[[case]] +name = "ownership-movements" +args = ["ownership", "movements", "--pages", "2"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln" } + +[[case]] +name = "ownership-movements-bbca" +args = ["ownership", "movements", "BBCA"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln" } + +[[case]] +name = "ownership-movements-ksei-sells" +args = ["ownership", "movements", "--action", "sell", "--source", "ksei", "--pages", "3"] +env = { IDX_STOCKBIT_REFRESH_TOKEN = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln" } + [[case]] name = "ownership-releases-empty" args = ["ownership", "releases"] diff --git a/crates/idx-cli/tests/golden/completions-bash.golden b/crates/idx-cli/tests/golden/completions-bash.golden index 603c3e0..b7506c3 100644 --- a/crates/idx-cli/tests/golden/completions-bash.golden +++ b/crates/idx-cli/tests/golden/completions-bash.golden @@ -156,6 +156,9 @@ _idx() { idx__help__ownership,import) cmd="idx__help__ownership__import" ;; + idx__help__ownership,movements) + cmd="idx__help__ownership__movements" + ;; idx__help__ownership,releases) cmd="idx__help__ownership__releases" ;; @@ -282,6 +285,9 @@ _idx() { idx__ownership,import) cmd="idx__ownership__import" ;; + idx__ownership,movements) + cmd="idx__ownership__movements" + ;; idx__ownership,releases) cmd="idx__ownership__releases" ;; @@ -324,6 +330,9 @@ _idx() { idx__ownership__help,import) cmd="idx__ownership__help__import" ;; + idx__ownership__help,movements) + cmd="idx__ownership__help__movements" + ;; idx__ownership__help,releases) cmd="idx__ownership__help__releases" ;; @@ -1095,7 +1104,7 @@ _idx() { return 0 ;; idx__help__ownership) - opts="discover import sync ticker entity search cross-holders concentration flow changes graph resolve releases" + opts="discover import sync ticker entity search cross-holders concentration flow changes movements graph resolve releases" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1220,6 +1229,20 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__help__ownership__movements) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__help__ownership__releases) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then @@ -1725,7 +1748,7 @@ _idx() { return 0 ;; idx__ownership) - opts="-o -q -v -h --output --no-color --quiet --verbose --provider --offline --no-cache --help discover import sync ticker entity search cross-holders concentration flow changes graph resolve releases help" + opts="-o -q -v -h --output --no-color --quiet --verbose --provider --offline --no-cache --help discover import sync ticker entity search cross-holders concentration flow changes movements graph resolve releases help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1973,7 +1996,7 @@ _idx() { return 0 ;; idx__ownership__help) - opts="discover import sync ticker entity search cross-holders concentration flow changes graph resolve releases help" + opts="discover import sync ticker entity search cross-holders concentration flow changes movements graph resolve releases help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2112,6 +2135,20 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__ownership__help__movements) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__ownership__help__releases) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then @@ -2262,6 +2299,56 @@ _idx() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + idx__ownership__movements) + opts="-o -q -v -h --from --to --holder --action --source --pages --output --no-color --quiet --verbose --provider --offline --no-cache --help [SYMBOL]" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --from) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --to) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --holder) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --action) + COMPREPLY=($(compgen -W "buy sell transfer cross corporate-action" -- "${cur}")) + return 0 + ;; + --source) + COMPREPLY=($(compgen -W "idx ksei" -- "${cur}")) + return 0 + ;; + --pages) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --output) + COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}")) + return 0 + ;; + -o) + COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}")) + return 0 + ;; + --provider) + COMPREPLY=($(compgen -W "yahoo msn stockbit" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; idx__ownership__releases) opts="-o -q -v -h --output --no-color --quiet --verbose --provider --offline --no-cache --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then diff --git a/crates/idx-cli/tests/golden/error-movements-holder.json.golden b/crates/idx-cli/tests/golden/error-movements-holder.json.golden new file mode 100644 index 0000000..782a248 --- /dev/null +++ b/crates/idx-cli/tests/golden/error-movements-holder.json.golden @@ -0,0 +1,4 @@ +exit: 2 +--- stdout +--- stderr +{"code":"INVALIDINPUT","error":true,"message":"invalid input: holder 'RUDI' is not a holder id; ids are digits, shown in the HOLDER ID column and as holder_id in JSON"} diff --git a/crates/idx-cli/tests/golden/error-movements-holder.table.golden b/crates/idx-cli/tests/golden/error-movements-holder.table.golden new file mode 100644 index 0000000..2f44611 --- /dev/null +++ b/crates/idx-cli/tests/golden/error-movements-holder.table.golden @@ -0,0 +1,4 @@ +exit: 2 +--- stdout +--- stderr +Error: invalid input: holder 'RUDI' is not a holder id; ids are digits, shown in the HOLDER ID column and as holder_id in JSON diff --git a/crates/idx-cli/tests/golden/error-movements-no-session.json.golden b/crates/idx-cli/tests/golden/error-movements-no-session.json.golden new file mode 100644 index 0000000..d38ac26 --- /dev/null +++ b/crates/idx-cli/tests/golden/error-movements-no-session.json.golden @@ -0,0 +1,4 @@ +exit: 4 +--- stdout +--- stderr +{"code":"AUTHERROR","error":true,"message":"auth error: no Stockbit session; run `idx stockbit login` (or set IDX_STOCKBIT_REFRESH_TOKEN)"} diff --git a/crates/idx-cli/tests/golden/error-movements-no-session.table.golden b/crates/idx-cli/tests/golden/error-movements-no-session.table.golden new file mode 100644 index 0000000..e1fcda0 --- /dev/null +++ b/crates/idx-cli/tests/golden/error-movements-no-session.table.golden @@ -0,0 +1,4 @@ +exit: 4 +--- stdout +--- stderr +Error: auth error: no Stockbit session; run `idx stockbit login` (or set IDX_STOCKBIT_REFRESH_TOKEN) diff --git a/crates/idx-cli/tests/golden/help-ownership.golden b/crates/idx-cli/tests/golden/help-ownership.golden index 202f0da..406d191 100644 --- a/crates/idx-cli/tests/golden/help-ownership.golden +++ b/crates/idx-cli/tests/golden/help-ownership.golden @@ -20,6 +20,7 @@ Commands: concentration Rank tickers by ownership concentration flow Show Bing institutional flow for a ticker changes Diff two KSEI releases + movements Insider and major holder buys and sells, as reported (Stockbit login) graph Ownership network graph resolve Manual entity resolution workflow releases List imported KSEI releases diff --git a/crates/idx-cli/tests/golden/ownership-movements-bbca.json.golden b/crates/idx-cli/tests/golden/ownership-movements-bbca.json.golden new file mode 100644 index 0000000..fa4664c --- /dev/null +++ b/crates/idx-cli/tests/golden/ownership-movements-bbca.json.golden @@ -0,0 +1,4 @@ +exit: 0 +--- stdout +{"movements":[{"symbol":"BBCA","date":"2026-03-25","holder":"HENDRA TANUMIHARDJA","holder_id":"1000000439","action":"buy","source":"idx","locality":"Local","roles":["director"],"shares_before":193206,"shares_after":341139,"shares_change":147933,"percentage_before_bps":0,"percentage_after_bps":0,"percentage_change_bps":0,"price":6982,"price_estimated":false,"value":1032868206},{"symbol":"BBCA","date":"2026-03-25","holder":"A. WIDODO MULYONO","holder_id":"1000000438","action":"buy","source":"idx","locality":"Local","shares_before":440838,"shares_after":681407,"shares_change":240569,"percentage_before_bps":0,"percentage_after_bps":0,"percentage_change_bps":0,"price":6982,"price_estimated":false,"value":1679652758},{"symbol":"BBCA","date":"2026-03-25","holder":"GREGORY HENDRA LEMBONG","holder_id":"1000000437","action":"buy","source":"idx","locality":"Local","roles":["director"],"shares_before":1531282,"shares_after":2666921,"shares_change":1135639,"percentage_before_bps":0,"percentage_after_bps":0,"percentage_change_bps":0,"price":6982,"price_estimated":false,"value":7929031498},{"symbol":"BBCA","date":"2026-03-25","holder":"SANTOSO","holder_id":"1000000209","action":"buy","source":"idx","locality":"Local","roles":["director"],"shares_before":3269028,"shares_after":3764062,"shares_change":495034,"percentage_before_bps":0,"percentage_after_bps":0,"percentage_change_bps":0,"price":6982,"price_estimated":false,"value":3456327388},{"symbol":"BBCA","date":"2026-03-25","holder":"TONNY KUSNADI","holder_id":"14421","action":"buy","source":"idx","locality":"Local","roles":["commissioner"],"shares_before":7502058,"shares_after":7819950,"shares_change":317892,"percentage_before_bps":1,"percentage_after_bps":1,"percentage_change_bps":0,"price":6982,"price_estimated":false,"value":2219521944},{"symbol":"BBCA","date":"2026-03-25","holder":"FRENGKY CHANDRA KUSUMA","holder_id":"14418","action":"buy","source":"idx","locality":"Local","roles":["director"],"shares_before":2429926,"shares_after":2835916,"shares_change":405990,"percentage_before_bps":0,"percentage_after_bps":0,"percentage_change_bps":0,"price":6982,"price_estimated":false,"value":2834622180},{"symbol":"BBCA","date":"2026-03-25","holder":"HARYANTO TIARA BUDIMAN","holder_id":"14417","action":"buy","source":"idx","locality":"Local","roles":["director"],"shares_before":1057378,"shares_after":1436806,"shares_change":379428,"percentage_before_bps":0,"percentage_after_bps":0,"percentage_change_bps":0,"price":6982,"price_estimated":false,"value":2649166296},{"symbol":"BBCA","date":"2026-03-25","holder":"VERA EVE LIM","holder_id":"14416","action":"buy","source":"idx","locality":"Local","roles":["director"],"shares_before":2731601,"shares_after":3281460,"shares_change":549859,"percentage_before_bps":0,"percentage_after_bps":0,"percentage_change_bps":0,"price":6982,"price_estimated":false,"value":3839115538}],"more":true} +--- stderr diff --git a/crates/idx-cli/tests/golden/ownership-movements-bbca.table.golden b/crates/idx-cli/tests/golden/ownership-movements-bbca.table.golden new file mode 100644 index 0000000..537acfd --- /dev/null +++ b/crates/idx-cli/tests/golden/ownership-movements-bbca.table.golden @@ -0,0 +1,26 @@ +exit: 0 +--- stdout +Shareholder movements for BBCA.JK (8) +┌────────────┬────────┬────────────────────────┬──────────────┬────────┬────────────┬────────┬───────┬───────┬────────┬────────────┐ +│ DATE ┆ SYMBOL ┆ HOLDER ┆ ROLE ┆ ACTION ┆ SHARES ┆ STAKE ┆ PRICE ┆ VALUE ┆ SOURCE ┆ HOLDER ID │ +╞════════════╪════════╪════════════════════════╪══════════════╪════════╪════════════╪════════╪═══════╪═══════╪════════╪════════════╡ +│ 2026-03-25 ┆ BBCA ┆ HENDRA TANUMIHARDJA ┆ director ┆ buy ┆ +147,933 ┆ <0.01% ┆ 6,982 ┆ 1.0B ┆ IDX ┆ 1000000439 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-25 ┆ BBCA ┆ A. WIDODO MULYONO ┆ - ┆ buy ┆ +240,569 ┆ <0.01% ┆ 6,982 ┆ 1.7B ┆ IDX ┆ 1000000438 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-25 ┆ BBCA ┆ GREGORY HENDRA LEMBONG ┆ director ┆ buy ┆ +1,135,639 ┆ <0.01% ┆ 6,982 ┆ 7.9B ┆ IDX ┆ 1000000437 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-25 ┆ BBCA ┆ SANTOSO ┆ director ┆ buy ┆ +495,034 ┆ <0.01% ┆ 6,982 ┆ 3.5B ┆ IDX ┆ 1000000209 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-25 ┆ BBCA ┆ TONNY KUSNADI ┆ commissioner ┆ buy ┆ +317,892 ┆ 0.01% ┆ 6,982 ┆ 2.2B ┆ IDX ┆ 14421 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-25 ┆ BBCA ┆ FRENGKY CHANDRA KUSUMA ┆ director ┆ buy ┆ +405,990 ┆ <0.01% ┆ 6,982 ┆ 2.8B ┆ IDX ┆ 14418 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-25 ┆ BBCA ┆ HARYANTO TIARA BUDIMAN ┆ director ┆ buy ┆ +379,428 ┆ <0.01% ┆ 6,982 ┆ 2.6B ┆ IDX ┆ 14417 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-03-25 ┆ BBCA ┆ VERA EVE LIM ┆ director ┆ buy ┆ +549,859 ┆ <0.01% ┆ 6,982 ┆ 3.8B ┆ IDX ┆ 14416 │ +└────────────┴────────┴────────────────────────┴──────────────┴────────┴────────────┴────────┴───────┴───────┴────────┴────────────┘ +IDX rows are insider disclosures (directors, commissioners and other insiders); KSEI rows are changes of holders at 5% and above. ~ marks Stockbit's estimated price. Rows appear days after the change. +More rows exist: raise --pages (up to 10) or narrow --from/--to. +Source: your Stockbit session; for personal, non-commercial use (Stockbit's terms). +--- stderr diff --git a/crates/idx-cli/tests/golden/ownership-movements-ksei-sells.json.golden b/crates/idx-cli/tests/golden/ownership-movements-ksei-sells.json.golden new file mode 100644 index 0000000..8f0f8c7 --- /dev/null +++ b/crates/idx-cli/tests/golden/ownership-movements-ksei-sells.json.golden @@ -0,0 +1,4 @@ +exit: 0 +--- stdout +{"movements":[{"symbol":"ATLA","date":"2026-10-30","holder":"RUDI R. SUTANTRA","holder_id":"1000004481","action":"sell","source":"ksei","locality":"Local","shares_before":2530254200,"shares_after":2520254200,"shares_change":-10000000,"percentage_before_bps":4081,"percentage_after_bps":4065,"percentage_change_bps":-16,"price":21,"price_estimated":true,"value":210000000},{"symbol":"FUJI","date":"2026-10-15","holder":"JEFRI NEDI","holder_id":"1000006017","action":"sell","source":"ksei","locality":"Local","shares_before":109431600,"shares_after":109251600,"shares_change":-180000,"percentage_before_bps":842,"percentage_after_bps":840,"percentage_change_bps":-1,"price":298,"price_estimated":true,"value":53640000},{"symbol":"ATLA","date":"2026-10-15","holder":"RUDI R. SUTANTRA","holder_id":"1000004481","action":"sell","source":"ksei","locality":"Local","shares_before":2638254200,"shares_after":2610254200,"shares_change":-28000000,"percentage_before_bps":4256,"percentage_after_bps":4210,"percentage_change_bps":-45,"price":29,"price_estimated":true,"value":812000000}],"more":false} +--- stderr diff --git a/crates/idx-cli/tests/golden/ownership-movements-ksei-sells.table.golden b/crates/idx-cli/tests/golden/ownership-movements-ksei-sells.table.golden new file mode 100644 index 0000000..b67a877 --- /dev/null +++ b/crates/idx-cli/tests/golden/ownership-movements-ksei-sells.table.golden @@ -0,0 +1,15 @@ +exit: 0 +--- stdout +Shareholder movements across IDX (3) +┌────────────┬────────┬──────────────────┬──────┬────────┬─────────────┬────────────────┬───────┬─────────┬────────┬────────────┐ +│ DATE ┆ SYMBOL ┆ HOLDER ┆ ROLE ┆ ACTION ┆ SHARES ┆ STAKE ┆ PRICE ┆ VALUE ┆ SOURCE ┆ HOLDER ID │ +╞════════════╪════════╪══════════════════╪══════╪════════╪═════════════╪════════════════╪═══════╪═════════╪════════╪════════════╡ +│ 2026-10-30 ┆ ATLA ┆ RUDI R. SUTANTRA ┆ - ┆ sell ┆ -10,000,000 ┆ 40.65% (-0.16) ┆ ~21 ┆ ~210.0M ┆ KSEI ┆ 1000004481 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-15 ┆ FUJI ┆ JEFRI NEDI ┆ - ┆ sell ┆ -180,000 ┆ 8.40% (-0.01) ┆ ~298 ┆ ~53.6M ┆ KSEI ┆ 1000006017 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-15 ┆ ATLA ┆ RUDI R. SUTANTRA ┆ - ┆ sell ┆ -28,000,000 ┆ 42.10% (-0.45) ┆ ~29 ┆ ~812.0M ┆ KSEI ┆ 1000004481 │ +└────────────┴────────┴──────────────────┴──────┴────────┴─────────────┴────────────────┴───────┴─────────┴────────┴────────────┘ +IDX rows are insider disclosures (directors, commissioners and other insiders); KSEI rows are changes of holders at 5% and above. ~ marks Stockbit's estimated price. Rows appear days after the change. +Source: your Stockbit session; for personal, non-commercial use (Stockbit's terms). +--- stderr diff --git a/crates/idx-cli/tests/golden/ownership-movements.json.golden b/crates/idx-cli/tests/golden/ownership-movements.json.golden new file mode 100644 index 0000000..3e5b499 --- /dev/null +++ b/crates/idx-cli/tests/golden/ownership-movements.json.golden @@ -0,0 +1,4 @@ +exit: 0 +--- stdout +{"movements":[{"symbol":"PEGE","date":"2026-11-02","holder":"OPTIMUS VISION GLOBAL","holder_id":"1000006115","action":"buy","source":"idx","locality":"Foreign","shares_before":249112774,"shares_after":251612774,"shares_change":2500000,"percentage_before_bps":659,"percentage_after_bps":666,"percentage_change_bps":7,"price":120,"price_estimated":false,"value":300000000,"purpose":"Pembelian"},{"symbol":"PEGE","date":"2026-11-02","holder":"OPTIMUS VISION GLOBAL","holder_id":"1000006115","action":"buy","source":"idx","locality":"Foreign","shares_before":246212774,"shares_after":249112774,"shares_change":2900000,"percentage_before_bps":652,"percentage_after_bps":659,"percentage_change_bps":8,"price":122,"price_estimated":false,"value":353800000,"purpose":"Pembelian"},{"symbol":"PEGE","date":"2026-11-02","holder":"OPTIMUS VISION GLOBAL","holder_id":"1000006115","action":"buy","source":"idx","locality":"Foreign","shares_before":242512774,"shares_after":243712774,"shares_change":1200000,"percentage_before_bps":642,"percentage_after_bps":645,"percentage_change_bps":3,"price":123,"price_estimated":false,"value":147600000,"purpose":"Pembelian"},{"symbol":"PEGE","date":"2026-11-02","holder":"OPTIMUS VISION GLOBAL","holder_id":"1000006115","action":"buy","source":"idx","locality":"Foreign","shares_before":241674474,"shares_after":242512774,"shares_change":838300,"percentage_before_bps":640,"percentage_after_bps":642,"percentage_change_bps":2,"price":119,"price_estimated":false,"value":99757700,"purpose":"Pembelian"},{"symbol":"PEGE","date":"2026-11-02","holder":"OPTIMUS VISION GLOBAL","holder_id":"1000006115","action":"buy","source":"idx","locality":"Foreign","shares_before":241650974,"shares_after":241674474,"shares_change":23500,"percentage_before_bps":640,"percentage_after_bps":640,"percentage_change_bps":0,"price":118,"price_estimated":false,"value":2773000,"purpose":"Pembelian"},{"symbol":"ATLA","date":"2026-10-30","holder":"RUDI R. SUTANTRA","holder_id":"1000004481","action":"sell","source":"ksei","locality":"Local","shares_before":2530254200,"shares_after":2520254200,"shares_change":-10000000,"percentage_before_bps":4081,"percentage_after_bps":4065,"percentage_change_bps":-16,"price":21,"price_estimated":true,"value":210000000},{"symbol":"BUVA","date":"2026-10-30","holder":"NUSANTARA UTAMA INVESTAMA","holder_id":"12606","action":"rights_issue","source":"ksei","locality":"Local","shares_before":18508539715,"shares_after":18508539715,"shares_change":0,"percentage_before_bps":6251,"percentage_after_bps":6154,"percentage_change_bps":-97,"price":353,"price_estimated":true},{"symbol":"SGER","date":"2026-10-30","holder":"WELLY THOMAS","holder_id":"14074","action":"transfer","source":"ksei","locality":"Local","shares_before":1285644762,"shares_after":1341269756,"shares_change":55624994,"percentage_before_bps":825,"percentage_after_bps":861,"percentage_change_bps":36,"price":794,"price_estimated":true,"value":44166245236},{"symbol":"ENRG","date":"2026-10-29","holder":"CGS INTERNATIONAL SEKURITAS INDONESIA","holder_id":"13898","action":"cross","source":"idx","locality":"Local","shares_before":3600545611,"shares_after":3100545614,"shares_change":-499999997,"percentage_before_bps":904,"percentage_after_bps":778,"percentage_change_bps":-125,"price":715,"price_estimated":false,"value":357499997855,"purpose":"Reverse REPO"},{"symbol":"ENRG","date":"2026-10-28","holder":"MAYBANK SEKURITAS INDONESIA","holder_id":"12202","action":"cross","source":"idx","locality":"Local","shares_before":2380252500,"shares_after":2442752500,"shares_change":62500000,"percentage_before_bps":597,"percentage_after_bps":613,"percentage_change_bps":16,"price":724,"price_estimated":true,"value":45250000000,"purpose":"Penambahan jaminan saham untuk transaksi repo"},{"symbol":"VISI","date":"2026-10-28","holder":"TRINUGRAHA THOHIR HARMONI","holder_id":"1000000448","action":"private_placement","source":"idx","locality":"Local","shares_before":246000000,"shares_after":270144900,"shares_change":24144900,"percentage_before_bps":770,"percentage_after_bps":845,"percentage_change_bps":76,"price":994,"price_estimated":false,"value":24000030600,"purpose":"PMTHMETD"},{"symbol":"MBSS","date":"2026-10-15","holder":"WIBOWO GROUP CAPITAL","holder_id":"1000005952","action":"tender_offer","source":"idx","locality":"Local","shares_before":1443766800,"shares_after":1576605000,"shares_change":132838200,"percentage_before_bps":8250,"percentage_after_bps":9009,"percentage_change_bps":759,"price":2915,"price_estimated":false,"value":387223353000},{"symbol":"FUJI","date":"2026-10-15","holder":"JEFRI NEDI","holder_id":"1000006017","action":"sell","source":"ksei","locality":"Local","shares_before":109431600,"shares_after":109251600,"shares_change":-180000,"percentage_before_bps":842,"percentage_after_bps":840,"percentage_change_bps":-1,"price":298,"price_estimated":true,"value":53640000},{"symbol":"ATLA","date":"2026-10-15","holder":"RUDI R. SUTANTRA","holder_id":"1000004481","action":"sell","source":"ksei","locality":"Local","shares_before":2638254200,"shares_after":2610254200,"shares_change":-28000000,"percentage_before_bps":4256,"percentage_after_bps":4210,"percentage_change_bps":-45,"price":29,"price_estimated":true,"value":812000000}],"more":false} +--- stderr diff --git a/crates/idx-cli/tests/golden/ownership-movements.table.golden b/crates/idx-cli/tests/golden/ownership-movements.table.golden new file mode 100644 index 0000000..2500f25 --- /dev/null +++ b/crates/idx-cli/tests/golden/ownership-movements.table.golden @@ -0,0 +1,37 @@ +exit: 0 +--- stdout +Shareholder movements across IDX (14) +┌────────────┬────────┬───────────────────────────────────────┬──────┬───────────────────┬──────────────┬────────────────┬───────┬─────────┬────────┬────────────┐ +│ DATE ┆ SYMBOL ┆ HOLDER ┆ ROLE ┆ ACTION ┆ SHARES ┆ STAKE ┆ PRICE ┆ VALUE ┆ SOURCE ┆ HOLDER ID │ +╞════════════╪════════╪═══════════════════════════════════════╪══════╪═══════════════════╪══════════════╪════════════════╪═══════╪═════════╪════════╪════════════╡ +│ 2026-11-02 ┆ PEGE ┆ OPTIMUS VISION GLOBAL ┆ - ┆ buy ┆ +2,500,000 ┆ 6.66% (+0.07) ┆ 120 ┆ 300.0M ┆ IDX ┆ 1000006115 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-02 ┆ PEGE ┆ OPTIMUS VISION GLOBAL ┆ - ┆ buy ┆ +2,900,000 ┆ 6.59% (+0.08) ┆ 122 ┆ 353.8M ┆ IDX ┆ 1000006115 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-02 ┆ PEGE ┆ OPTIMUS VISION GLOBAL ┆ - ┆ buy ┆ +1,200,000 ┆ 6.45% (+0.03) ┆ 123 ┆ 147.6M ┆ IDX ┆ 1000006115 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-02 ┆ PEGE ┆ OPTIMUS VISION GLOBAL ┆ - ┆ buy ┆ +838,300 ┆ 6.42% (+0.02) ┆ 119 ┆ 99.8M ┆ IDX ┆ 1000006115 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-02 ┆ PEGE ┆ OPTIMUS VISION GLOBAL ┆ - ┆ buy ┆ +23,500 ┆ 6.40% ┆ 118 ┆ 2.8M ┆ IDX ┆ 1000006115 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-30 ┆ ATLA ┆ RUDI R. SUTANTRA ┆ - ┆ sell ┆ -10,000,000 ┆ 40.65% (-0.16) ┆ ~21 ┆ ~210.0M ┆ KSEI ┆ 1000004481 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-30 ┆ BUVA ┆ NUSANTARA UTAMA INVESTAMA ┆ - ┆ rights issue ┆ 0 ┆ 61.54% (-0.97) ┆ ~353 ┆ - ┆ KSEI ┆ 12606 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-30 ┆ SGER ┆ WELLY THOMAS ┆ - ┆ transfer ┆ +55,624,994 ┆ 8.61% (+0.36) ┆ ~794 ┆ ~44.2B ┆ KSEI ┆ 14074 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-29 ┆ ENRG ┆ CGS INTERNATIONAL SEKURITAS INDONESIA ┆ - ┆ cross ┆ -499,999,997 ┆ 7.78% (-1.25) ┆ 715 ┆ 357.5B ┆ IDX ┆ 13898 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-28 ┆ ENRG ┆ MAYBANK SEKURITAS INDONESIA ┆ - ┆ cross ┆ +62,500,000 ┆ 6.13% (+0.16) ┆ ~724 ┆ ~45.2B ┆ IDX ┆ 12202 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-28 ┆ VISI ┆ TRINUGRAHA THOHIR HARMONI ┆ - ┆ private placement ┆ +24,144,900 ┆ 8.45% (+0.76) ┆ 994 ┆ 24.0B ┆ IDX ┆ 1000000448 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-15 ┆ MBSS ┆ WIBOWO GROUP CAPITAL ┆ - ┆ tender offer ┆ +132,838,200 ┆ 90.09% (+7.59) ┆ 2,915 ┆ 387.2B ┆ IDX ┆ 1000005952 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-15 ┆ FUJI ┆ JEFRI NEDI ┆ - ┆ sell ┆ -180,000 ┆ 8.40% (-0.01) ┆ ~298 ┆ ~53.6M ┆ KSEI ┆ 1000006017 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-15 ┆ ATLA ┆ RUDI R. SUTANTRA ┆ - ┆ sell ┆ -28,000,000 ┆ 42.10% (-0.45) ┆ ~29 ┆ ~812.0M ┆ KSEI ┆ 1000004481 │ +└────────────┴────────┴───────────────────────────────────────┴──────┴───────────────────┴──────────────┴────────────────┴───────┴─────────┴────────┴────────────┘ +IDX rows are insider disclosures (directors, commissioners and other insiders); KSEI rows are changes of holders at 5% and above. ~ marks Stockbit's estimated price. Rows appear days after the change. +Source: your Stockbit session; for personal, non-commercial use (Stockbit's terms). +--- stderr diff --git a/crates/idx-core/src/api/mock.rs b/crates/idx-core/src/api/mock.rs index 6a76d4d..d21b03a 100644 --- a/crates/idx-core/src/api/mock.rs +++ b/crates/idx-core/src/api/mock.rs @@ -1,17 +1,18 @@ //! Fixture-backed provider for tests, enabled by the `testing` feature and //! `IDX_USE_MOCK_PROVIDER`. Release builds do not contain it. -use super::stockbit::{corpaction, exodus}; +use super::stockbit::{corpaction, exodus, movement}; use super::types::{Bar, Fundamentals, Interval, Intraday, OrderBook, Period, Quote}; use super::{ BrokerSummaryProvider, CorporateActionProvider, FundamentalsProvider, HistoryProvider, - IntradayProvider, OrderBookProvider, QuoteProvider, TradingSummaryProvider, idx, ipot, msn, - stockbit, yahoo, + IntradayProvider, OrderBookProvider, QuoteProvider, ShareholderMovementProvider, + TradingSummaryProvider, idx, ipot, msn, stockbit, yahoo, }; use crate::broker::types::{BrokerBoard, BrokerInvestor, BrokerQuery}; use crate::config::ProviderKind; use crate::corporate::types::{ActionKind, CorporateAction}; use crate::error::IdxError; +use crate::movements::types::{MovementPage, MovementQuery}; pub(crate) fn enabled() -> bool { std::env::var("IDX_USE_MOCK_PROVIDER").is_ok() @@ -254,6 +255,36 @@ impl CorporateActionProvider for MockStockbitProvider { } } +/// `stockbit_exodus_majorholder[_][_p].json` (no suffix for page +/// 1); a missing fixture is an empty page, as Stockbit answers past the end. +/// The query's filters apply to the fixture's rows, as Stockbit applies them. +impl ShareholderMovementProvider for MockStockbitProvider { + fn shareholder_movements( + &self, + query: &MovementQuery, + page: u32, + ) -> Result { + let subject = query.symbol.as_deref().unwrap_or("shareholder movements"); + let mut name = "majorholder".to_string(); + if let Some(symbol) = &query.symbol { + name.push('_'); + name.push_str(&stockbit::stockbit_code(symbol)?.to_ascii_lowercase()); + } + if page > 1 { + name.push_str(&format!("_p{page}")); + } + let body = match self.exodus(subject, &format!("{name}.json")) { + Err(IdxError::SymbolNotFound(_)) if query.symbol.is_some() || page > 1 => { + r#"{"data":{"is_more":false,"movement":[]}}"#.to_string() + } + other => other?, + }; + let mut parsed = movement::parse_movements(&body)?; + parsed.movements.retain(|m| query.admits(m)); + Ok(parsed) + } +} + impl HistoryProvider for MockStockbitProvider { fn history( &self, diff --git a/crates/idx-core/src/api/mod.rs b/crates/idx-core/src/api/mod.rs index b3fb07a..f64cb8e 100644 --- a/crates/idx-core/src/api/mod.rs +++ b/crates/idx-core/src/api/mod.rs @@ -89,6 +89,17 @@ pub trait CorporateActionProvider { ) -> Result, IdxError>; } +/// Shareholder movements: needs the user's Stockbit session. +pub trait ShareholderMovementProvider { + /// Page `page` (from 1) of `query`, whose `symbol` is resolved + /// (`BBCA.JK`) or `None` for the market. + fn shareholder_movements( + &self, + query: &crate::movements::types::MovementQuery, + page: u32, + ) -> Result; +} + pub trait FundamentalsProvider { fn fundamentals(&self, symbol: &str) -> Result; } @@ -364,6 +375,14 @@ pub fn corporate_action_provider() -> Box { Box::new(stockbit::StockbitProvider::new()) } +pub fn shareholder_movement_provider() -> Box { + #[cfg(feature = "testing")] + if mock::enabled() { + return Box::new(mock::MockStockbitProvider); + } + Box::new(stockbit::StockbitProvider::new()) +} + /// Today in WIB, the date IDX trades on. pub(crate) fn today_wib() -> chrono::NaiveDate { #[cfg(feature = "testing")] diff --git a/crates/idx-core/src/api/stockbit/exodus.rs b/crates/idx-core/src/api/stockbit/exodus.rs index ddd0fca..1b3ec3d 100644 --- a/crates/idx-core/src/api/stockbit/exodus.rs +++ b/crates/idx-core/src/api/stockbit/exodus.rs @@ -25,12 +25,13 @@ use chrono::{Months, NaiveDate}; use serde_json::Value; use super::auth::SessionStore; -use super::corpaction; use super::parse::number; use super::{USER_AGENT, pace, stockbit_code}; +use super::{corpaction, movement}; use crate::api::types::{BookLevel, Interval, Ohlc, OrderBook, Period, Quote}; use crate::corporate::types::{ActionKind, CorporateAction}; use crate::error::IdxError; +use crate::movements::types::{MovementPage, MovementQuery}; const BASE_URL: &str = "https://exodus.stockbit.com"; const REFRESH_PATH: &str = "/login/refresh"; @@ -140,6 +141,25 @@ impl Exodus { corpaction::parse_corporate_actions(kind, &body) } + /// Page `page` of shareholder movements: one stock's (`query.symbol`, + /// resolved) or the market's. + pub(crate) fn shareholder_movements( + &self, + query: &MovementQuery, + page: u32, + ) -> Result { + let code = query.symbol.as_deref().map(stockbit_code).transpose()?; + let subject = query + .symbol + .clone() + .unwrap_or_else(|| "shareholder movements".to_string()); + let body = self.get( + &movement::request_path(query, code.as_deref(), page), + &subject, + )?; + movement::parse_movements(&body) + } + /// The market's state, read at most every `MARKET_STATE_TTL` per process. /// Unknown on any failure, which hides bid/offer. fn market_status(&self) -> Option { diff --git a/crates/idx-core/src/api/stockbit/mod.rs b/crates/idx-core/src/api/stockbit/mod.rs index a00abf1..ead4d60 100644 --- a/crates/idx-core/src/api/stockbit/mod.rs +++ b/crates/idx-core/src/api/stockbit/mod.rs @@ -20,6 +20,7 @@ pub mod browser; pub mod corpaction; pub mod exodus; pub mod loopback; +pub mod movement; mod parse; pub mod signin; @@ -33,10 +34,11 @@ pub use parse::{parse_symbol_page, status_error, stockbit_code}; use super::types::{Bar, Fundamentals, Interval, Intraday, OrderBook, Period, Quote}; use super::{ CorporateActionProvider, FundamentalsProvider, HistoryProvider, IntradayProvider, - OrderBookProvider, QuoteProvider, + OrderBookProvider, QuoteProvider, ShareholderMovementProvider, }; use crate::corporate::types::{ActionKind, CorporateAction}; use crate::error::IdxError; +use crate::movements::types::{MovementPage, MovementQuery}; use auth::SessionStore; use exodus::Exodus; @@ -216,6 +218,16 @@ impl CorporateActionProvider for StockbitProvider { } } +impl ShareholderMovementProvider for StockbitProvider { + fn shareholder_movements( + &self, + query: &MovementQuery, + page: u32, + ) -> Result { + self.require_session()?.shareholder_movements(query, page) + } +} + impl HistoryProvider for StockbitProvider { fn history( &self, diff --git a/crates/idx-core/src/api/stockbit/movement.rs b/crates/idx-core/src/api/stockbit/movement.rs new file mode 100644 index 0000000..3453b8c --- /dev/null +++ b/crates/idx-core/src/api/stockbit/movement.rs @@ -0,0 +1,328 @@ +//! Shareholder movements from `GET /insider/company/majorholder`: reported +//! changes in a holder's stake, newest first, 50 rows a page. +//! +//! Two sources share the feed: IDX insider disclosures (directors, +//! commissioners and other insiders, any size; a trade price) and KSEI's +//! daily changes of holders at or above 5% (no price; Stockbit estimates +//! one). Each row (`data.movement[]`) carries `id` (the holder's id, not the +//! row's), `name`, `symbol`, `date` (`"25 Mar 26"`), `previous` / `current` / +//! `changes` (`value`: shares as `"+147,933"`, `percentage`: `"+0.0001"`), +//! `action_type` (`ACTION_TYPE_BUY`, ..._SELL, ..._TRANSFER, ..._CROSS, +//! ..._RIGHT_ISSUE, ..._PRIVATE_PLACEMENT, ..._TENDER_OFFER, ...), +//! `nationality`, `badges`, `price.raw.value`, `value.raw.value`, +//! `is_estimated_price`, `purpose` and `data_source.type`. +//! +//! Query parameters (all optional): `symbol`, `date_start` / `date_end` +//! (YYYY-MM-DD), `insider` (holder id), `action_type`, `source_type`, `page` +//! (from 1). + +use chrono::NaiveDate; +use serde_json::Value; + +use crate::error::IdxError; +use crate::movements::types::{ + ActionFilter, MovementAction, MovementPage, MovementQuery, MovementSource, ShareholderMovement, +}; + +pub const PATH: &str = "/insider/company/majorholder"; + +/// Stockbit's `action_type` value for `filter`. +pub fn action_type(filter: ActionFilter) -> &'static str { + match filter { + ActionFilter::Buy => "ACTION_TYPE_BUY", + ActionFilter::Sell => "ACTION_TYPE_SELL", + ActionFilter::Transfer => "ACTION_TYPE_TRANSFER", + ActionFilter::Cross => "ACTION_TYPE_CROSS", + ActionFilter::CorporateAction => "ACTION_TYPE_CORPACTION", + } +} + +/// Stockbit's `source_type` value for `source`. +pub fn source_type(source: MovementSource) -> &'static str { + match source { + MovementSource::Idx => "SOURCE_TYPE_IDX", + MovementSource::Ksei => "SOURCE_TYPE_KSEI", + } +} + +/// The request path for `page` of `query`; `code` is the bare IDX code. +/// Every value is a date, a digit id, a code or a fixed enum name, so +/// nothing needs escaping. +pub fn request_path(query: &MovementQuery, code: Option<&str>, page: u32) -> String { + let mut path = format!("{PATH}?page={page}"); + if let Some(code) = code { + path.push_str(&format!("&symbol={code}")); + } + if let Some(from) = query.from { + path.push_str(&format!("&date_start={from}")); + } + if let Some(to) = query.to { + path.push_str(&format!("&date_end={to}")); + } + if let Some(id) = &query.holder_id { + path.push_str(&format!("&insider={id}")); + } + if let Some(action) = query.action { + path.push_str(&format!("&action_type={}", action_type(action))); + } + if let Some(source) = query.source { + path.push_str(&format!("&source_type={}", source_type(source))); + } + path +} + +/// One page of the feed. A row without a symbol, holder or readable date is +/// skipped; a body without `data` is a parse error. +pub fn parse_movements(body: &str) -> Result { + let value: Value = serde_json::from_str(body) + .map_err(|e| IdxError::ParseError(format!("Stockbit majorholder: {e}")))?; + let data = value + .get("data") + .filter(|data| data.is_object()) + .ok_or_else(|| IdxError::ParseError("Stockbit majorholder: no data".to_string()))?; + let movements = data + .get("movement") + .and_then(Value::as_array) + .map(|rows| rows.iter().filter_map(parse_row).collect()) + .unwrap_or_default(); + Ok(MovementPage { + movements, + more: data + .get("is_more") + .and_then(Value::as_bool) + .unwrap_or(false), + }) +} + +fn parse_row(row: &Value) -> Option { + let symbol = text(row.get("symbol"))?.to_ascii_uppercase(); + let holder = text(row.get("name"))?.to_string(); + let date = NaiveDate::parse_from_str(text(row.get("date"))?, "%d %b %y").ok()?; + let shares = |key: &str| signed(row.get(key).and_then(|v| v.get("value"))).unwrap_or(0); + let bps = |key: &str| { + percent(row.get(key).and_then(|v| v.get("percentage"))) + .map(|p| (p * 100.0).round() as i64) + .unwrap_or(0) + }; + let raw = |key: &str| { + signed( + row.get(key) + .and_then(|v| v.get("raw")) + .and_then(|v| v.get("value")), + ) + .filter(|n| *n != 0) + }; + Some(ShareholderMovement { + symbol, + date, + holder, + holder_id: text(row.get("id")).unwrap_or_default().to_string(), + action: action(text(row.get("action_type")).unwrap_or_default()), + source: match text(row.get("data_source").and_then(|v| v.get("type"))) { + Some("SOURCE_TYPE_IDX") => Some(MovementSource::Idx), + Some("SOURCE_TYPE_KSEI") => Some(MovementSource::Ksei), + _ => None, + }, + locality: match text(row.get("nationality")) { + Some("NATIONALITY_TYPE_LOCAL") => Some("Local".to_string()), + Some("NATIONALITY_TYPE_FOREIGN") => Some("Foreign".to_string()), + _ => None, + }, + roles: row + .get("badges") + .and_then(Value::as_array) + .map(|badges| { + badges + .iter() + .filter_map(|b| text(Some(b))) + .map(role) + .collect() + }) + .unwrap_or_default(), + shares_before: shares("previous"), + shares_after: shares("current"), + shares_change: shares("changes"), + percentage_before_bps: bps("previous"), + percentage_after_bps: bps("current"), + percentage_change_bps: bps("changes"), + price: raw("price"), + price_estimated: row + .get("is_estimated_price") + .and_then(Value::as_bool) + .unwrap_or(false), + value: raw("value"), + purpose: text(row.get("purpose")) + .filter(|p| *p != "-") + .map(str::to_string), + }) +} + +fn action(raw: &str) -> MovementAction { + match raw.strip_prefix("ACTION_TYPE_").unwrap_or(raw) { + "BUY" => MovementAction::Buy, + "SELL" => MovementAction::Sell, + "TRANSFER" => MovementAction::Transfer, + "CROSS" => MovementAction::Cross, + "RIGHT_ISSUE" => MovementAction::RightsIssue, + "PRIVATE_PLACEMENT" => MovementAction::PrivatePlacement, + "TENDER_OFFER" => MovementAction::TenderOffer, + "BONUS_STOCK" => MovementAction::BonusStock, + "DIVIDEND_STOCK" => MovementAction::StockDividend, + "DIVIDEND_CASH" => MovementAction::CashDividend, + _ => MovementAction::Other, + } +} + +/// `SHAREHOLDER_BADGE_DIREKTUR` -> `director`; an unknown badge keeps its +/// own name, lowercased. +fn role(badge: &str) -> String { + match badge.strip_prefix("SHAREHOLDER_BADGE_").unwrap_or(badge) { + "DIREKTUR" => "director".to_string(), + "KOMISARIS" => "commissioner".to_string(), + other => other.to_ascii_lowercase(), + } +} + +fn text(value: Option<&Value>) -> Option<&str> { + value + .and_then(Value::as_str) + .map(str::trim) + .filter(|s| !s.is_empty()) +} + +/// `"+147,933"`, `"-10,000,000"`, `"6982"` or a JSON number. +fn signed(value: Option<&Value>) -> Option { + match value? { + Value::Number(n) => n.as_i64().or_else(|| n.as_f64().map(|f| f.round() as i64)), + Value::String(s) => s.trim().replace(',', "").parse().ok(), + _ => None, + } +} + +/// `"+0.0001"`, `"-0.16"`, `"54.94"`. +fn percent(value: Option<&Value>) -> Option { + let n = match value? { + Value::Number(n) => n.as_f64()?, + Value::String(s) => s.trim().replace(',', "").parse().ok()?, + _ => return None, + }; + n.is_finite().then_some(n) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn fixture(name: &str) -> String { + std::fs::read_to_string(format!( + "{}/tests/fixtures/stockbit_exodus_{name}.json", + env!("CARGO_MANIFEST_DIR") + )) + .unwrap() + } + + #[test] + fn insider_buy_reads_shares_price_and_roles() { + let page = parse_movements(&fixture("majorholder_bbca")).unwrap(); + assert!(page.more); + let row = page + .movements + .iter() + .find(|m| m.holder == "HENDRA TANUMIHARDJA") + .expect("BBCA director row"); + assert_eq!(row.symbol, "BBCA"); + assert_eq!(row.date, NaiveDate::from_ymd_opt(2026, 3, 25).unwrap()); + assert_eq!(row.action, MovementAction::Buy); + assert_eq!(row.source, Some(MovementSource::Idx)); + assert_eq!(row.roles, ["director"]); + assert_eq!( + (row.shares_before, row.shares_after, row.shares_change), + (193_206, 341_139, 147_933) + ); + // 0.0003% of BBCA rounds to 0 basis points; the shares stay exact. + assert_eq!(row.percentage_after_bps, 0); + assert_eq!(row.price, Some(6982)); + assert_eq!(row.value, Some(1_032_868_206)); + assert!(!row.price_estimated); + assert_eq!(row.locality.as_deref(), Some("Local")); + } + + #[test] + fn ksei_sale_is_negative_with_an_estimated_price() { + let page = parse_movements(&fixture("majorholder")).unwrap(); + let row = page + .movements + .iter() + .find(|m| m.holder == "RUDI R. SUTANTRA") + .expect("ATLA KSEI sale"); + assert_eq!(row.action, MovementAction::Sell); + assert_eq!(row.source, Some(MovementSource::Ksei)); + assert_eq!(row.holder_id, "1000004481"); + assert_eq!(row.shares_change, -10_000_000); + assert_eq!(row.percentage_before_bps, 4081); + assert_eq!(row.percentage_change_bps, -16); + assert!(row.price_estimated); + assert!(row.roles.is_empty()); + assert_eq!(row.purpose, None); + } + + #[test] + fn unknown_labels_are_kept_not_dropped() { + let body = r#"{"data":{"is_more":false,"movement":[ + {"id":"7","name":"X","symbol":"abcd","date":"02 Nov 26", + "action_type":"ACTION_TYPE_SOMETHING_NEW","badges":["SHAREHOLDER_BADGE_CEO"], + "data_source":{"type":"SOURCE_TYPE_NEW"},"purpose":"-", + "previous":{"value":"0","percentage":"0"}, + "current":{"value":"1,000","percentage":"0.01"}, + "changes":{"value":"+1,000","percentage":"+0.01"}, + "price":{"raw":{"value":"0"}},"value":{"raw":{"value":"0"}}}, + {"id":"8","name":"","symbol":"ABCD","date":"02 Nov 26"}, + {"id":"9","name":"Y","symbol":"ABCD","date":"2026-11-02"} + ]}}"#; + let page = parse_movements(body).unwrap(); + assert!(!page.more); + assert_eq!(page.movements.len(), 1); + let row = &page.movements[0]; + assert_eq!(row.symbol, "ABCD"); + assert_eq!(row.action, MovementAction::Other); + assert_eq!(row.source, None); + assert_eq!(row.roles, ["ceo"]); + assert_eq!( + (row.price, row.value, row.purpose.as_deref()), + (None, None, None) + ); + assert_eq!(row.percentage_after_bps, 1); + } + + #[test] + fn empty_and_broken_bodies() { + let empty = parse_movements(r#"{"data":{"is_more":false,"movement":null}}"#).unwrap(); + assert_eq!(empty, MovementPage::default()); + assert!(parse_movements(r#"{"message":"unauthorized"}"#).is_err()); + assert!(parse_movements("").is_err()); + } + + #[test] + fn request_path_carries_every_filter() { + let mut query = MovementQuery::from_args( + None, + Some("2026-10-01"), + Some("2026-10-15"), + Some("14074"), + 1, + ) + .unwrap(); + query.action = Some(ActionFilter::CorporateAction); + query.source = Some(MovementSource::Ksei); + assert_eq!( + request_path(&query, Some("BBCA"), 2), + "/insider/company/majorholder?page=2&symbol=BBCA&date_start=2026-10-01\ + &date_end=2026-10-15&insider=14074&action_type=ACTION_TYPE_CORPACTION\ + &source_type=SOURCE_TYPE_KSEI" + ); + assert_eq!( + request_path(&MovementQuery::default(), None, 1), + "/insider/company/majorholder?page=1" + ); + } +} diff --git a/crates/idx-core/src/client.rs b/crates/idx-core/src/client.rs index aef1c39..57e6333 100644 --- a/crates/idx-core/src/client.rs +++ b/crates/idx-core/src/client.rs @@ -98,6 +98,10 @@ impl Idx { crate::corporate::Corporate { idx: self } } + pub fn movements(&self) -> crate::movements::Movements<'_> { + crate::movements::Movements { idx: self } + } + pub fn financial(&self) -> crate::financial::Financial<'_> { crate::financial::Financial { idx: self } } diff --git a/crates/idx-core/src/lib.rs b/crates/idx-core/src/lib.rs index cd49711..12e1656 100644 --- a/crates/idx-core/src/lib.rs +++ b/crates/idx-core/src/lib.rs @@ -16,6 +16,7 @@ pub mod flow; #[cfg(feature = "ownership")] pub mod investor; pub mod market; +pub mod movements; #[cfg(feature = "ownership")] pub mod ownership; pub mod text; diff --git a/crates/idx-core/src/movements/mod.rs b/crates/idx-core/src/movements/mod.rs new file mode 100644 index 0000000..f35387e --- /dev/null +++ b/crates/idx-core/src/movements/mod.rs @@ -0,0 +1,124 @@ +//! Shareholder movements from the user's Stockbit session: reported changes +//! in insiders' and major holders' stakes (IDX insider disclosures and KSEI's +//! 5% holder changes), one stock's or the market's, newest first. Each page +//! is 50 rows and one request (paced 1 s apart), cached for an hour. +//! +//! These are the reports as filed. Whether they predict anything is not +//! claimed here: share plans read as a cluster of buys at one price, and a +//! row appears days after the trade (see `docs/STOCKBIT.md`). + +pub mod types; + +use chrono::Utc; + +use crate::api::{shareholder_movement_provider, stockbit}; +use crate::client::{CachePolicy, CacheSpec, Fetched, Idx, cached_fetch}; +use crate::error::IdxError; +use types::{MovementList, MovementQuery}; + +/// The feed gains rows through the day; an hour keeps a session's repeated +/// queries cheap without hiding a day's filings for long. +const TTL_SECS: u64 = 3600; +const BUCKET: &str = "stockbit-movements"; + +pub struct Movements<'a> { + pub(crate) idx: &'a Idx, +} + +impl Movements<'_> { + /// Up to `query.pages` pages of the feed, newest first; `more` says + /// whether rows remain past them. The result is as old as its oldest page + /// and stale if any page is. + pub fn list( + &self, + query: &MovementQuery, + policy: CachePolicy, + ) -> Result, IdxError> { + let mut query = query.clone(); + if let Some(symbol) = &query.symbol { + let (resolved, _) = self.idx.idx_code(symbol, "shareholder movements")?; + query.symbol = Some(resolved); + } + let provider = shareholder_movement_provider(); + let subject = query + .symbol + .clone() + .unwrap_or_else(|| "shareholder movements".to_string()); + let mut list = Fetched { + data: MovementList::default(), + source: stockbit::SOURCE, + fetched_at: Utc::now(), + stale: false, + }; + for page in 1..=query.pages.max(1) { + let key = cache_key(&query, page); + let part = cached_fetch( + &self.idx.cache, + CacheSpec { + bucket: BUCKET, + key: &key, + ttl_secs: TTL_SECS, + subject: &subject, + source: stockbit::SOURCE, + }, + policy, + || provider.shareholder_movements(&query, page), + Ok, + )?; + list.fetched_at = list.fetched_at.min(part.fetched_at); + list.stale |= part.stale; + list.data.movements.extend(part.data.movements); + list.data.more = part.data.more; + if !part.data.more { + break; + } + } + Ok(list) + } +} + +/// Every filter and the page, so no two queries share an entry. +fn cache_key(query: &MovementQuery, page: u32) -> String { + let opt = |value: Option| value.unwrap_or_else(|| "-".to_string()); + format!( + "{}:{}:{}:{}:{}:{}:p{page}", + query.symbol.as_deref().unwrap_or("market"), + opt(query.from.map(|d| d.to_string())), + opt(query.to.map(|d| d.to_string())), + query.holder_id.as_deref().unwrap_or("-"), + query.action.map(|a| a.as_str()).unwrap_or("-"), + query.source.map(|s| s.as_str()).unwrap_or("-"), + ) +} + +#[cfg(test)] +mod tests { + use super::*; + use types::{ActionFilter, MovementSource}; + + #[test] + fn cache_keys_differ_by_every_filter() { + let base = MovementQuery::from_args(None, None, None, None, 1).unwrap(); + let mut keys = vec![cache_key(&base, 1), cache_key(&base, 2)]; + let mut q = base.clone(); + q.symbol = Some("BBCA.JK".to_string()); + keys.push(cache_key(&q, 1)); + let mut q = base.clone(); + q.from = chrono::NaiveDate::from_ymd_opt(2026, 10, 1); + keys.push(cache_key(&q, 1)); + let mut q = base.clone(); + q.to = chrono::NaiveDate::from_ymd_opt(2026, 10, 1); + keys.push(cache_key(&q, 1)); + let mut q = base.clone(); + q.holder_id = Some("14074".to_string()); + keys.push(cache_key(&q, 1)); + let mut q = base.clone(); + q.action = Some(ActionFilter::Sell); + keys.push(cache_key(&q, 1)); + let mut q = base; + q.source = Some(MovementSource::Ksei); + keys.push(cache_key(&q, 1)); + let unique: std::collections::HashSet<_> = keys.iter().collect(); + assert_eq!(unique.len(), keys.len(), "{keys:?}"); + } +} diff --git a/crates/idx-core/src/movements/types.rs b/crates/idx-core/src/movements/types.rs new file mode 100644 index 0000000..1d031ce --- /dev/null +++ b/crates/idx-core/src/movements/types.rs @@ -0,0 +1,334 @@ +use chrono::NaiveDate; +use serde::{Deserialize, Serialize}; + +use crate::error::IdxError; + +/// What a holder's row records, as Stockbit labels it. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum MovementAction { + Buy, + Sell, + /// Shares moved between accounts or parties, not a market trade. + Transfer, + /// A crossing: a negotiated trade between two parties. + Cross, + RightsIssue, + PrivatePlacement, + TenderOffer, + BonusStock, + StockDividend, + CashDividend, + /// A label Stockbit added after this release. + Other, +} + +impl MovementAction { + pub fn as_str(self) -> &'static str { + match self { + Self::Buy => "buy", + Self::Sell => "sell", + Self::Transfer => "transfer", + Self::Cross => "cross", + Self::RightsIssue => "rights_issue", + Self::PrivatePlacement => "private_placement", + Self::TenderOffer => "tender_offer", + Self::BonusStock => "bonus_stock", + Self::StockDividend => "stock_dividend", + Self::CashDividend => "cash_dividend", + Self::Other => "other", + } + } + + /// Whether `filter` (Stockbit's `action_type`) selects this action. + pub fn matches(self, filter: ActionFilter) -> bool { + match filter { + ActionFilter::Buy => self == Self::Buy, + ActionFilter::Sell => self == Self::Sell, + ActionFilter::Transfer => self == Self::Transfer, + ActionFilter::Cross => self == Self::Cross, + ActionFilter::CorporateAction => matches!( + self, + Self::RightsIssue + | Self::PrivatePlacement + | Self::TenderOffer + | Self::BonusStock + | Self::StockDividend + | Self::CashDividend + ), + } + } +} + +/// The action filters Stockbit's feed takes (`action_type`). Corporate +/// action covers rights issues, private placements and the like. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "clap", derive(clap::ValueEnum))] +#[serde(rename_all = "kebab-case")] +pub enum ActionFilter { + Buy, + Sell, + Transfer, + Cross, + #[cfg_attr(feature = "clap", value(name = "corporate-action"))] + CorporateAction, +} + +impl ActionFilter { + pub const ALL: [Self; 5] = [ + Self::Buy, + Self::Sell, + Self::Transfer, + Self::Cross, + Self::CorporateAction, + ]; + + /// The CLI's name (`--action`), also used in MCP inputs. + pub fn as_str(self) -> &'static str { + match self { + Self::Buy => "buy", + Self::Sell => "sell", + Self::Transfer => "transfer", + Self::Cross => "cross", + Self::CorporateAction => "corporate-action", + } + } +} + +impl std::str::FromStr for ActionFilter { + type Err = IdxError; + + fn from_str(value: &str) -> Result { + let wanted = value.trim().to_ascii_lowercase().replace('_', "-"); + Self::ALL + .into_iter() + .find(|filter| filter.as_str() == wanted) + .ok_or_else(|| { + IdxError::InvalidInput(format!( + "unknown action '{value}'; use one of: {}", + Self::ALL.map(Self::as_str).join(", ") + )) + }) + } +} + +/// Who reported the change: IDX insider disclosures (directors, +/// commissioners and other insiders, any size), or KSEI's daily changes of +/// holders at or above 5%. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "clap", derive(clap::ValueEnum))] +#[serde(rename_all = "lowercase")] +pub enum MovementSource { + Idx, + Ksei, +} + +impl MovementSource { + pub fn as_str(self) -> &'static str { + match self { + Self::Idx => "idx", + Self::Ksei => "ksei", + } + } +} + +impl std::str::FromStr for MovementSource { + type Err = IdxError; + + fn from_str(value: &str) -> Result { + match value.trim().to_ascii_lowercase().as_str() { + "idx" => Ok(Self::Idx), + "ksei" => Ok(Self::Ksei), + _ => Err(IdxError::InvalidInput(format!( + "unknown source '{value}'; use idx or ksei" + ))), + } + } +} + +/// One reported change in a holder's stake. Share counts are exact; +/// percentages are of the company's shares, in basis points as Stockbit +/// rounds them, so a small insider's stake can read 0. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct ShareholderMovement { + pub symbol: String, + /// The day of the change (the trade or the register date). + pub date: NaiveDate, + pub holder: String, + /// Stockbit's id for the holder; `--holder` takes it. + pub holder_id: String, + pub action: MovementAction, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub source: Option, + /// `Local` or `Foreign`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub locality: Option, + /// Insider roles at the company: `director`, `commissioner`. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub roles: Vec, + pub shares_before: i64, + pub shares_after: i64, + /// Signed: negative for a sale. + pub shares_change: i64, + pub percentage_before_bps: i64, + pub percentage_after_bps: i64, + pub percentage_change_bps: i64, + /// Whole IDR per share. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub price: Option, + /// The price is Stockbit's estimate (KSEI rows report no price). + pub price_estimated: bool, + /// Whole IDR: shares changed times price. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, + /// The stated purpose, free text (`Investasi`, `Divestasi`, ...). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub purpose: Option, +} + +/// One page of Stockbit's feed (50 rows), newest first. +#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +pub struct MovementPage { + pub movements: Vec, + /// Whether a further page exists. + pub more: bool, +} + +/// Most pages one query reads (500 rows). +pub const MAX_PAGES: u32 = 10; + +/// What to list. `symbol` is resolved (`BBCA.JK`) once it reaches a +/// provider; `None` is the whole market. +#[derive(Debug, Clone, Default, PartialEq)] +pub struct MovementQuery { + pub symbol: Option, + pub from: Option, + pub to: Option, + pub holder_id: Option, + pub action: Option, + pub source: Option, + /// Pages to read, 1 to `MAX_PAGES`. + pub pages: u32, +} + +impl MovementQuery { + /// Validates user input: dates as YYYY-MM-DD with `from` not after + /// `to`, a numeric holder id, and 1 to `MAX_PAGES` pages. + pub fn from_args( + symbol: Option<&str>, + from: Option<&str>, + to: Option<&str>, + holder_id: Option<&str>, + pages: u32, + ) -> Result { + let parse = |name: &str, value: &str| { + NaiveDate::parse_from_str(value.trim(), "%Y-%m-%d").map_err(|_| { + IdxError::InvalidInput(format!("invalid {name} '{value}'; use YYYY-MM-DD")) + }) + }; + let from = from.map(|v| parse("from", v)).transpose()?; + let to = to.map(|v| parse("to", v)).transpose()?; + if let (Some(from), Some(to)) = (from, to) + && to < from + { + return Err(IdxError::InvalidInput(format!( + "to ({to}) is before from ({from})" + ))); + } + let holder_id = holder_id.map(str::trim).filter(|id| !id.is_empty()); + if let Some(id) = holder_id + && !id.bytes().all(|b| b.is_ascii_digit()) + { + return Err(IdxError::InvalidInput(format!( + "holder '{id}' is not a holder id; ids are digits, shown in the HOLDER ID \ + column and as holder_id in JSON" + ))); + } + if !(1..=MAX_PAGES).contains(&pages) { + return Err(IdxError::InvalidInput(format!( + "pages must be 1 to {MAX_PAGES}" + ))); + } + Ok(Self { + symbol: symbol + .map(str::trim) + .filter(|s| !s.is_empty()) + .map(str::to_string), + from, + to, + holder_id: holder_id.map(str::to_string), + action: None, + source: None, + pages, + }) + } + + /// Whether `movement` passes the query's filters (what Stockbit applies + /// on its side; the mock provider uses it). + pub fn admits(&self, movement: &ShareholderMovement) -> bool { + self.from.is_none_or(|from| movement.date >= from) + && self.to.is_none_or(|to| movement.date <= to) + && self + .holder_id + .as_ref() + .is_none_or(|id| &movement.holder_id == id) + && self + .action + .is_none_or(|filter| movement.action.matches(filter)) + && self + .source + .is_none_or(|source| movement.source == Some(source)) + } +} + +/// The rows a query read, newest first. +#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +pub struct MovementList { + pub movements: Vec, + /// More rows exist past the pages read (raise `--pages`, or narrow the + /// dates). + pub more: bool, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn query_validates_dates_holder_and_pages() { + let query = + MovementQuery::from_args(Some(" bbca "), Some("2026-10-01"), None, Some("14074"), 2) + .unwrap(); + assert_eq!(query.symbol.as_deref(), Some("bbca")); + assert_eq!(query.from, NaiveDate::from_ymd_opt(2026, 10, 1)); + assert_eq!(query.holder_id.as_deref(), Some("14074")); + + for (from, to, holder, pages) in [ + (Some("01-10-2026"), None, None, 1), + (Some("2026-10-02"), Some("2026-10-01"), None, 1), + (None, None, Some("RUDI"), 1), + (None, None, Some("1&page=9"), 1), + (None, None, None, 0), + (None, None, None, MAX_PAGES + 1), + ] { + assert!( + MovementQuery::from_args(None, from, to, holder, pages).is_err(), + "{from:?} {to:?} {holder:?} {pages}" + ); + } + } + + #[test] + fn action_filter_names_round_trip() { + for filter in ActionFilter::ALL { + assert_eq!(filter.as_str().parse::().unwrap(), filter); + } + assert_eq!( + "corporate_action".parse::().unwrap(), + ActionFilter::CorporateAction + ); + assert!("dividend".parse::().is_err()); + assert!(MovementAction::RightsIssue.matches(ActionFilter::CorporateAction)); + assert!(!MovementAction::Transfer.matches(ActionFilter::CorporateAction)); + } +} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder.json b/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder.json new file mode 100644 index 0000000..1d9fccb --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder.json @@ -0,0 +1,416 @@ +{ + "message": "Successfully majorholder data", + "data": { + "is_more": true, + "movement": [ + { + "id": "1000006115", + "name": "OPTIMUS VISION GLOBAL", + "symbol": "PEGE", + "date": "02 Nov 26", + "previous": { + "value": "249,112,774", + "percentage": "6.59", + "formatted_value": "" + }, + "current": { + "value": "251,612,774", + "percentage": "6.66", + "formatted_value": "" + }, + "changes": { + "value": "+2,500,000", + "percentage": "+0.07", + "formatted_value": "2,500,000" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_FOREIGN", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "120", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "120" + }, + "formatted": "120" + }, + "value": { + "raw": { + "value": "300000000" + }, + "formatted": "300.00M" + }, + "is_estimated_price": false, + "purpose": "Pembelian", + "icon_url": "https://assets.stockbit.com/logos/companies/PEGE.png" + }, + { + "id": "1000006115", + "name": "OPTIMUS VISION GLOBAL", + "symbol": "PEGE", + "date": "02 Nov 26", + "previous": { + "value": "246,212,774", + "percentage": "6.52", + "formatted_value": "" + }, + "current": { + "value": "249,112,774", + "percentage": "6.59", + "formatted_value": "" + }, + "changes": { + "value": "+2,900,000", + "percentage": "+0.08", + "formatted_value": "2,900,000" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_FOREIGN", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "122", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "122" + }, + "formatted": "122" + }, + "value": { + "raw": { + "value": "353800000" + }, + "formatted": "353.80M" + }, + "is_estimated_price": false, + "purpose": "Pembelian", + "icon_url": "https://assets.stockbit.com/logos/companies/PEGE.png" + }, + { + "id": "1000006115", + "name": "OPTIMUS VISION GLOBAL", + "symbol": "PEGE", + "date": "02 Nov 26", + "previous": { + "value": "242,512,774", + "percentage": "6.42", + "formatted_value": "" + }, + "current": { + "value": "243,712,774", + "percentage": "6.45", + "formatted_value": "" + }, + "changes": { + "value": "+1,200,000", + "percentage": "+0.03", + "formatted_value": "1,200,000" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_FOREIGN", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "123", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "123" + }, + "formatted": "123" + }, + "value": { + "raw": { + "value": "147600000" + }, + "formatted": "147.60M" + }, + "is_estimated_price": false, + "purpose": "Pembelian", + "icon_url": "https://assets.stockbit.com/logos/companies/PEGE.png" + }, + { + "id": "1000006115", + "name": "OPTIMUS VISION GLOBAL", + "symbol": "PEGE", + "date": "02 Nov 26", + "previous": { + "value": "241,674,474", + "percentage": "6.40", + "formatted_value": "" + }, + "current": { + "value": "242,512,774", + "percentage": "6.42", + "formatted_value": "" + }, + "changes": { + "value": "+838,300", + "percentage": "+0.02", + "formatted_value": "838,300" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_FOREIGN", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "119", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "119" + }, + "formatted": "119" + }, + "value": { + "raw": { + "value": "99757700" + }, + "formatted": "99.76M" + }, + "is_estimated_price": false, + "purpose": "Pembelian", + "icon_url": "https://assets.stockbit.com/logos/companies/PEGE.png" + }, + { + "id": "1000006115", + "name": "OPTIMUS VISION GLOBAL", + "symbol": "PEGE", + "date": "02 Nov 26", + "previous": { + "value": "241,650,974", + "percentage": "6.40", + "formatted_value": "" + }, + "current": { + "value": "241,674,474", + "percentage": "6.40", + "formatted_value": "" + }, + "changes": { + "value": "+23,500", + "percentage": "+0.0006", + "formatted_value": "23,500" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_FOREIGN", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "118", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "118" + }, + "formatted": "118" + }, + "value": { + "raw": { + "value": "2773000" + }, + "formatted": "2.77M" + }, + "is_estimated_price": false, + "purpose": "Pembelian", + "icon_url": "https://assets.stockbit.com/logos/companies/PEGE.png" + }, + { + "id": "1000004481", + "name": "RUDI R. SUTANTRA", + "symbol": "ATLA", + "date": "30 Oct 26", + "previous": { + "value": "2,530,254,200", + "percentage": "40.81", + "formatted_value": "" + }, + "current": { + "value": "2,520,254,200", + "percentage": "40.65", + "formatted_value": "" + }, + "changes": { + "value": "-10,000,000", + "percentage": "-0.16", + "formatted_value": "10,000,000" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_SELL", + "data_source": { + "label": "Sumber: KSEI", + "type": "SOURCE_TYPE_KSEI" + }, + "price_formatted": "", + "broker_detail": { + "code": "AG", + "group": "BROKER_GROUP_FOREIGN" + }, + "badges": [], + "price": { + "raw": { + "value": "21" + }, + "formatted": "21" + }, + "value": { + "raw": { + "value": "210000000" + }, + "formatted": "210.00M" + }, + "is_estimated_price": true, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/ATLA.png" + }, + { + "id": "12606", + "name": "NUSANTARA UTAMA INVESTAMA", + "symbol": "BUVA", + "date": "30 Oct 26", + "previous": { + "value": "18,508,539,715", + "percentage": "62.51", + "formatted_value": "" + }, + "current": { + "value": "18,508,539,715", + "percentage": "61.54", + "formatted_value": "" + }, + "changes": { + "value": "0", + "percentage": "-0.97", + "formatted_value": "0" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_RIGHT_ISSUE", + "data_source": { + "label": "Sumber: KSEI", + "type": "SOURCE_TYPE_KSEI" + }, + "price_formatted": "", + "broker_detail": { + "code": "YU", + "group": "BROKER_GROUP_FOREIGN" + }, + "badges": [], + "price": { + "raw": { + "value": "353" + }, + "formatted": "353" + }, + "value": { + "raw": { + "value": "0" + }, + "formatted": "-" + }, + "is_estimated_price": true, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BUVA.png?version=1785918174174738481" + }, + { + "id": "14074", + "name": "WELLY THOMAS", + "symbol": "SGER", + "date": "30 Oct 26", + "previous": { + "value": "1,285,644,762", + "percentage": "8.25", + "formatted_value": "" + }, + "current": { + "value": "1,341,269,756", + "percentage": "8.61", + "formatted_value": "" + }, + "changes": { + "value": "+55,624,994", + "percentage": "+0.36", + "formatted_value": "55,624,994" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_TRANSFER", + "data_source": { + "label": "Sumber: KSEI", + "type": "SOURCE_TYPE_KSEI" + }, + "price_formatted": "", + "broker_detail": { + "code": "OD", + "group": "BROKER_GROUP_GOVERNMENT" + }, + "badges": [], + "price": { + "raw": { + "value": "794" + }, + "formatted": "794" + }, + "value": { + "raw": { + "value": "44166245236" + }, + "formatted": "44.17B" + }, + "is_estimated_price": true, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/SGER.png" + } + ] + } +} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_bbca.json b/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_bbca.json new file mode 100644 index 0000000..bf4534c --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_bbca.json @@ -0,0 +1,430 @@ +{ + "message": "Successfully majorholder data", + "data": { + "is_more": true, + "movement": [ + { + "id": "1000000439", + "name": "HENDRA TANUMIHARDJA", + "symbol": "BBCA", + "date": "25 Mar 26", + "previous": { + "value": "193,206", + "percentage": "0.0002", + "formatted_value": "" + }, + "current": { + "value": "341,139", + "percentage": "0.0003", + "formatted_value": "" + }, + "changes": { + "value": "+147,933", + "percentage": "+0.0001", + "formatted_value": "147,933" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "6,982", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "6982" + }, + "formatted": "6,982" + }, + "value": { + "raw": { + "value": "1032868206" + }, + "formatted": "1.03B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "1000000438", + "name": "A. WIDODO MULYONO", + "symbol": "BBCA", + "date": "25 Mar 26", + "previous": { + "value": "440,838", + "percentage": "0.0004", + "formatted_value": "" + }, + "current": { + "value": "681,407", + "percentage": "0.0006", + "formatted_value": "" + }, + "changes": { + "value": "+240,569", + "percentage": "+0.0002", + "formatted_value": "240,569" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "6,982", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "6982" + }, + "formatted": "6,982" + }, + "value": { + "raw": { + "value": "1679652758" + }, + "formatted": "1.68B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "1000000437", + "name": "GREGORY HENDRA LEMBONG", + "symbol": "BBCA", + "date": "25 Mar 26", + "previous": { + "value": "1,531,282", + "percentage": "0.0012", + "formatted_value": "" + }, + "current": { + "value": "2,666,921", + "percentage": "0.0022", + "formatted_value": "" + }, + "changes": { + "value": "+1,135,639", + "percentage": "+0.0010", + "formatted_value": "1,135,639" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "6,982", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "6982" + }, + "formatted": "6,982" + }, + "value": { + "raw": { + "value": "7929031498" + }, + "formatted": "7.93B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "1000000209", + "name": "SANTOSO", + "symbol": "BBCA", + "date": "25 Mar 26", + "previous": { + "value": "3,269,028", + "percentage": "0.0027", + "formatted_value": "" + }, + "current": { + "value": "3,764,062", + "percentage": "0.0031", + "formatted_value": "" + }, + "changes": { + "value": "+495,034", + "percentage": "+0.0004", + "formatted_value": "495,034" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "6,982", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "6982" + }, + "formatted": "6,982" + }, + "value": { + "raw": { + "value": "3456327388" + }, + "formatted": "3.46B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "14421", + "name": "TONNY KUSNADI", + "symbol": "BBCA", + "date": "25 Mar 26", + "previous": { + "value": "7,502,058", + "percentage": "0.0061", + "formatted_value": "" + }, + "current": { + "value": "7,819,950", + "percentage": "0.0063", + "formatted_value": "" + }, + "changes": { + "value": "+317,892", + "percentage": "+0.0002", + "formatted_value": "317,892" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "6,982", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_KOMISARIS" + ], + "price": { + "raw": { + "value": "6982" + }, + "formatted": "6,982" + }, + "value": { + "raw": { + "value": "2219521944" + }, + "formatted": "2.22B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "14418", + "name": "FRENGKY CHANDRA KUSUMA", + "symbol": "BBCA", + "date": "25 Mar 26", + "previous": { + "value": "2,429,926", + "percentage": "0.0020", + "formatted_value": "" + }, + "current": { + "value": "2,835,916", + "percentage": "0.0023", + "formatted_value": "" + }, + "changes": { + "value": "+405,990", + "percentage": "+0.0003", + "formatted_value": "405,990" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "6,982", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "6982" + }, + "formatted": "6,982" + }, + "value": { + "raw": { + "value": "2834622180" + }, + "formatted": "2.83B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "14417", + "name": "HARYANTO TIARA BUDIMAN", + "symbol": "BBCA", + "date": "25 Mar 26", + "previous": { + "value": "1,057,378", + "percentage": "0.0009", + "formatted_value": "" + }, + "current": { + "value": "1,436,806", + "percentage": "0.0012", + "formatted_value": "" + }, + "changes": { + "value": "+379,428", + "percentage": "+0.0003", + "formatted_value": "379,428" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "6,982", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "6982" + }, + "formatted": "6,982" + }, + "value": { + "raw": { + "value": "2649166296" + }, + "formatted": "2.65B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "14416", + "name": "VERA EVE LIM", + "symbol": "BBCA", + "date": "25 Mar 26", + "previous": { + "value": "2,731,601", + "percentage": "0.0022", + "formatted_value": "" + }, + "current": { + "value": "3,281,460", + "percentage": "0.0027", + "formatted_value": "" + }, + "changes": { + "value": "+549,859", + "percentage": "+0.0005", + "formatted_value": "549,859" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "6,982", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "6982" + }, + "formatted": "6,982" + }, + "value": { + "raw": { + "value": "3839115538" + }, + "formatted": "3.84B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + } + ] + } +} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_bbca_p2.json b/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_bbca_p2.json new file mode 100644 index 0000000..d4bc7d3 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_bbca_p2.json @@ -0,0 +1,220 @@ +{ + "message": "Successfully majorholder data", + "data": { + "is_more": false, + "movement": [ + { + "id": "14418", + "name": "FRENGKY CHANDRA KUSUMA", + "symbol": "BBCA", + "date": "22 Mar 24", + "previous": { + "value": "1,891,049", + "percentage": "0.0015", + "formatted_value": "" + }, + "current": { + "value": "2,107,984", + "percentage": "0.0017", + "formatted_value": "" + }, + "changes": { + "value": "+216,935", + "percentage": "+0.0002", + "formatted_value": "216,935" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "10,108", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "10108" + }, + "formatted": "10,108" + }, + "value": { + "raw": { + "value": "2192778980" + }, + "formatted": "2.19B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "14417", + "name": "HARYANTO TIARA BUDIMAN", + "symbol": "BBCA", + "date": "22 Mar 24", + "previous": { + "value": "561,695", + "percentage": "0.0005", + "formatted_value": "" + }, + "current": { + "value": "776,099", + "percentage": "0.0006", + "formatted_value": "" + }, + "changes": { + "value": "+214,404", + "percentage": "+0.0001", + "formatted_value": "214,404" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "10,108", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "10108" + }, + "formatted": "10,108" + }, + "value": { + "raw": { + "value": "2167195632" + }, + "formatted": "2.17B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "14416", + "name": "VERA EVE LIM", + "symbol": "BBCA", + "date": "22 Mar 24", + "previous": { + "value": "1,912,261", + "percentage": "0.0016", + "formatted_value": "" + }, + "current": { + "value": "2,212,324", + "percentage": "0.0018", + "formatted_value": "" + }, + "changes": { + "value": "+300,063", + "percentage": "+0.0002", + "formatted_value": "300,063" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "10,108", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "10108" + }, + "formatted": "10,108" + }, + "value": { + "raw": { + "value": "3033036804" + }, + "formatted": "3.03B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + }, + { + "id": "14415", + "name": "LIANAWATY SUWONO", + "symbol": "BBCA", + "date": "22 Mar 24", + "previous": { + "value": "2,012,880", + "percentage": "0.0016", + "formatted_value": "" + }, + "current": { + "value": "2,264,685", + "percentage": "0.0018", + "formatted_value": "" + }, + "changes": { + "value": "+251,805", + "percentage": "+0.0002", + "formatted_value": "251,805" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_BUY", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "10,108", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [ + "SHAREHOLDER_BADGE_DIREKTUR" + ], + "price": { + "raw": { + "value": "10108" + }, + "formatted": "10,108" + }, + "value": { + "raw": { + "value": "2545244940" + }, + "formatted": "2.55B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/BBCA.png" + } + ] + } +} diff --git a/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_p2.json b/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_p2.json new file mode 100644 index 0000000..6571c36 --- /dev/null +++ b/crates/idx-core/tests/fixtures/stockbit_exodus_majorholder_p2.json @@ -0,0 +1,314 @@ +{ + "message": "Successfully majorholder data", + "data": { + "is_more": false, + "movement": [ + { + "id": "13898", + "name": "CGS INTERNATIONAL SEKURITAS INDONESIA", + "symbol": "ENRG", + "date": "29 Oct 26", + "previous": { + "value": "3,600,545,611", + "percentage": "9.04", + "formatted_value": "" + }, + "current": { + "value": "3,100,545,614", + "percentage": "7.78", + "formatted_value": "" + }, + "changes": { + "value": "-499,999,997", + "percentage": "-1.25", + "formatted_value": "499,999,997" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_CROSS", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "715", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "715" + }, + "formatted": "715" + }, + "value": { + "raw": { + "value": "357499997855" + }, + "formatted": "357.50B" + }, + "is_estimated_price": false, + "purpose": "Reverse REPO", + "icon_url": "https://assets.stockbit.com/logos/companies/ENRG.png?version=1750036449822958153" + }, + { + "id": "12202", + "name": "MAYBANK SEKURITAS INDONESIA", + "symbol": "ENRG", + "date": "28 Oct 26", + "previous": { + "value": "2,380,252,500", + "percentage": "5.97", + "formatted_value": "" + }, + "current": { + "value": "2,442,752,500", + "percentage": "6.13", + "formatted_value": "" + }, + "changes": { + "value": "+62,500,000", + "percentage": "+0.16", + "formatted_value": "62,500,000" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_CROSS", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "724" + }, + "formatted": "724" + }, + "value": { + "raw": { + "value": "45250000000" + }, + "formatted": "45.25B" + }, + "is_estimated_price": true, + "purpose": "Penambahan jaminan saham untuk transaksi repo", + "icon_url": "https://assets.stockbit.com/logos/companies/ENRG.png?version=1750036449822958153" + }, + { + "id": "1000000448", + "name": "TRINUGRAHA THOHIR HARMONI", + "symbol": "VISI", + "date": "28 Oct 26", + "previous": { + "value": "246,000,000", + "percentage": "7.70", + "formatted_value": "" + }, + "current": { + "value": "270,144,900", + "percentage": "8.45", + "formatted_value": "" + }, + "changes": { + "value": "+24,144,900", + "percentage": "+0.76", + "formatted_value": "24,144,900" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_PRIVATE_PLACEMENT", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "994", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "994" + }, + "formatted": "994" + }, + "value": { + "raw": { + "value": "24000030600" + }, + "formatted": "24.00B" + }, + "is_estimated_price": false, + "purpose": "PMTHMETD", + "icon_url": "https://assets.stockbit.com/logos/companies/VISI.png" + }, + { + "id": "1000005952", + "name": "WIBOWO GROUP CAPITAL", + "symbol": "MBSS", + "date": "15 Oct 26", + "previous": { + "value": "1,443,766,800", + "percentage": "82.50", + "formatted_value": "" + }, + "current": { + "value": "1,576,605,000", + "percentage": "90.09", + "formatted_value": "" + }, + "changes": { + "value": "+132,838,200", + "percentage": "+7.59", + "formatted_value": "132,838,200" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_TENDER_OFFER", + "data_source": { + "label": "Sumber: IDX", + "type": "SOURCE_TYPE_IDX" + }, + "price_formatted": "2,915", + "broker_detail": { + "code": "", + "group": "BROKER_GROUP_UNSPECIFIED" + }, + "badges": [], + "price": { + "raw": { + "value": "2915" + }, + "formatted": "2,915" + }, + "value": { + "raw": { + "value": "387223353000" + }, + "formatted": "387.22B" + }, + "is_estimated_price": false, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/MBSS.png" + }, + { + "id": "1000006017", + "name": "JEFRI NEDI", + "symbol": "FUJI", + "date": "15 Oct 26", + "previous": { + "value": "109,431,600", + "percentage": "8.42", + "formatted_value": "" + }, + "current": { + "value": "109,251,600", + "percentage": "8.40", + "formatted_value": "" + }, + "changes": { + "value": "-180,000", + "percentage": "-0.01", + "formatted_value": "180,000" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_SELL", + "data_source": { + "label": "Sumber: KSEI", + "type": "SOURCE_TYPE_KSEI" + }, + "price_formatted": "", + "broker_detail": { + "code": "CP", + "group": "BROKER_GROUP_FOREIGN" + }, + "badges": [], + "price": { + "raw": { + "value": "298" + }, + "formatted": "298" + }, + "value": { + "raw": { + "value": "53640000" + }, + "formatted": "53.64M" + }, + "is_estimated_price": true, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/FUJI.png" + }, + { + "id": "1000004481", + "name": "RUDI R. SUTANTRA", + "symbol": "ATLA", + "date": "15 Oct 26", + "previous": { + "value": "2,638,254,200", + "percentage": "42.56", + "formatted_value": "" + }, + "current": { + "value": "2,610,254,200", + "percentage": "42.10", + "formatted_value": "" + }, + "changes": { + "value": "-28,000,000", + "percentage": "-0.45", + "formatted_value": "28,000,000" + }, + "marker": "", + "is_posted": false, + "cmh_id": "0", + "nationality": "NATIONALITY_TYPE_LOCAL", + "action_type": "ACTION_TYPE_SELL", + "data_source": { + "label": "Sumber: KSEI", + "type": "SOURCE_TYPE_KSEI" + }, + "price_formatted": "", + "broker_detail": { + "code": "AG", + "group": "BROKER_GROUP_FOREIGN" + }, + "badges": [], + "price": { + "raw": { + "value": "29" + }, + "formatted": "29" + }, + "value": { + "raw": { + "value": "812000000" + }, + "formatted": "812.00M" + }, + "is_estimated_price": true, + "purpose": "", + "icon_url": "https://assets.stockbit.com/logos/companies/ATLA.png" + } + ] + } +} diff --git a/crates/idx-mcp/src/params.rs b/crates/idx-mcp/src/params.rs index 3142955..774c635 100644 --- a/crates/idx-mcp/src/params.rs +++ b/crates/idx-mcp/src/params.rs @@ -7,6 +7,7 @@ use idx_core::broker::types::{BrokerBoard, BrokerInvestor}; use idx_core::corporate::types::ActionKind; use idx_core::flow::types::FlowSource; use idx_core::market::{ScreenFilter, ScreenRegion}; +use idx_core::movements::types::{ActionFilter, MAX_PAGES}; use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema}; use serde::Deserialize; @@ -253,6 +254,34 @@ pub struct CorporateCalendarParams { pub kinds: Option>, } +#[derive(Debug, Deserialize, JsonSchema)] +pub struct MovementsParams { + /// IDX ticker, e.g. "BBCA"; omit for the whole market. + #[serde(default)] + pub symbol: Option, + /// First day, YYYY-MM-DD. + #[serde(default)] + pub from: Option, + /// Last day, YYYY-MM-DD. + #[serde(default)] + pub to: Option, + /// One holder's movements: the `holder_id` of a row. + #[serde(default)] + pub holder_id: Option, + /// Only this kind of movement; "corporate-action" covers rights issues, private placements and the like. + #[serde(default)] + #[schemars(schema_with = "movement_action_schema")] + pub action: Option, + /// "idx" (insider disclosures, any size) or "ksei" (holders at 5% and above). + #[serde(default)] + #[schemars(schema_with = "movement_source_schema")] + pub source: Option, + /// Pages of 50 rows (default 1, at most 10); each page is one request to Stockbit. + #[serde(default)] + #[schemars(schema_with = "movement_pages_schema")] + pub pages: Option, +} + /// Parses `kinds`, or `default` when absent. pub fn action_kinds( kinds: Option>, @@ -346,6 +375,18 @@ fn action_kinds_schema(_: &mut SchemaGenerator) -> Schema { json_schema!({ "type": "array", "items": { "type": "string", "enum": kinds } }) } +fn movement_action_schema(_: &mut SchemaGenerator) -> Schema { + string_enum(ActionFilter::ALL.map(ActionFilter::as_str).to_vec()) +} + +fn movement_source_schema(_: &mut SchemaGenerator) -> Schema { + string_enum(vec!["idx", "ksei"]) +} + +fn movement_pages_schema(_: &mut SchemaGenerator) -> Schema { + json_schema!({ "type": "integer", "minimum": 1, "maximum": MAX_PAGES }) +} + fn login_method_schema(_: &mut SchemaGenerator) -> Schema { string_enum(LoginMethod::ALL.map(LoginMethod::as_str).to_vec()) } diff --git a/crates/idx-mcp/src/server.rs b/crates/idx-mcp/src/server.rs index bcf375c..4c48842 100644 --- a/crates/idx-mcp/src/server.rs +++ b/crates/idx-mcp/src/server.rs @@ -16,6 +16,7 @@ use idx_core::financial::{EarningsFilter, StatementFilter}; use idx_core::flow::types::FlowRange; use idx_core::investor::{HolderSource, Investor}; use idx_core::market::{ScreenFilter, ScreenQuery, ScreenRegion}; +use idx_core::movements::types::MovementQuery; use idx_core::ownership::types::ChangeRow; use idx_core::{CachePolicy, Fetched, Idx}; use rmcp::handler::server::router::tool::ToolRouter; @@ -29,8 +30,8 @@ use tokio::sync::Semaphore; use crate::params::{ AnalysisKind, AnalyzeParams, BandarParams, BrokerParams, ChangesParams, CompanyParams, CompanySection, CorporateActionsParams, CorporateCalendarParams, EntityParams, FlowParams, - HistoryParams, IntradayParams, LoginMethod, LoginParams, OrderBookParams, ScreenParams, - SearchParams, ShareholdersParams, SymbolsParams, SyncParams, action_kinds, + HistoryParams, IntradayParams, LoginMethod, LoginParams, MovementsParams, OrderBookParams, + ScreenParams, SearchParams, ShareholdersParams, SymbolsParams, SyncParams, action_kinds, }; const SYNC_TOOL: &str = "ownership_sync"; @@ -401,6 +402,42 @@ AUTHERROR means there is no session: call stockbit_status, then stockbit_login." .await } + #[tool( + description = "Reported changes in insiders' and major holders' stakes in IDX stocks, \ +from the user's own Stockbit session, newest first: IDX insider disclosures (directors, \ +commissioners and other insiders, any size, with the trade price) and KSEI changes of holders \ +at 5% and above (price estimated: `price_estimated`). One stock's, or the market's without \ +`symbol`. Shares are exact and signed (`shares_change` < 0 is a sale); percentages are basis \ +points as Stockbit rounds them, so a small insider can read 0. `more` is true when rows remain \ +past `pages`. These are filings, not signals: many insiders buying at one price on one day is \ +usually a share plan, and rows appear days after the change. AUTHERROR means there is no \ +session: call stockbit_status, then stockbit_login." + )] + async fn get_shareholder_movements(&self, params: Parameters) -> ToolResult { + let MovementsParams { + symbol, + from, + to, + holder_id, + action, + source, + pages, + } = params.0; + self.live(move |idx| { + let mut query = MovementQuery::from_args( + symbol.as_deref(), + from.as_deref(), + to.as_deref(), + holder_id.as_deref(), + pages.unwrap_or(1), + )?; + query.action = action.as_deref().map(str::parse).transpose()?; + query.source = source.as_deref().map(str::parse).transpose()?; + idx.movements().list(&query, CachePolicy::Default) + }) + .await + } + #[tool( description = "Company data for one IDX ticker: profile, financial statements, \ earnings, analyst sentiment, insights, and news. News items carry `relevance`: \ diff --git a/crates/idx-mcp/tests/golden/tools.json b/crates/idx-mcp/tests/golden/tools.json index b4a8878..6ba541f 100644 --- a/crates/idx-mcp/tests/golden/tools.json +++ b/crates/idx-mcp/tests/golden/tools.json @@ -555,6 +555,76 @@ }, "name": "get_quotes" }, + { + "description": "Reported changes in insiders' and major holders' stakes in IDX stocks, from the user's own Stockbit session, newest first: IDX insider disclosures (directors, commissioners and other insiders, any size, with the trade price) and KSEI changes of holders at 5% and above (price estimated: `price_estimated`). One stock's, or the market's without `symbol`. Shares are exact and signed (`shares_change` < 0 is a sale); percentages are basis points as Stockbit rounds them, so a small insider can read 0. `more` is true when rows remain past `pages`. These are filings, not signals: many insiders buying at one price on one day is usually a share plan, and rows appear days after the change. AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "action": { + "default": null, + "description": "Only this kind of movement; \"corporate-action\" covers rights issues, private placements and the like.", + "enum": [ + "buy", + "sell", + "transfer", + "cross", + "corporate-action" + ], + "type": "string" + }, + "from": { + "default": null, + "description": "First day, YYYY-MM-DD.", + "type": [ + "string", + "null" + ] + }, + "holder_id": { + "default": null, + "description": "One holder's movements: the `holder_id` of a row.", + "type": [ + "string", + "null" + ] + }, + "pages": { + "default": null, + "description": "Pages of 50 rows (default 1, at most 10); each page is one request to Stockbit.", + "maximum": 10, + "minimum": 1, + "type": "integer" + }, + "source": { + "default": null, + "description": "\"idx\" (insider disclosures, any size) or \"ksei\" (holders at 5% and above).", + "enum": [ + "idx", + "ksei" + ], + "type": "string" + }, + "symbol": { + "default": null, + "description": "IDX ticker, e.g. \"BBCA\"; omit for the whole market.", + "type": [ + "string", + "null" + ] + }, + "to": { + "default": null, + "description": "Last day, YYYY-MM-DD.", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "name": "get_shareholder_movements" + }, { "description": "Shareholders above 1% of an IDX ticker from the latest KSEI release, with concentration metrics (top1, top3, HHI, free float).", "inputSchema": { diff --git a/crates/idx-mcp/tests/mcp.rs b/crates/idx-mcp/tests/mcp.rs index 5274ffc..b705104 100644 --- a/crates/idx-mcp/tests/mcp.rs +++ b/crates/idx-mcp/tests/mcp.rs @@ -9,7 +9,7 @@ use idx_core::config::CoreConfig; use idx_core::investor::{ImportSource, Investor}; use serde_json::{Value, json}; -const TOOLS: [&str; 20] = [ +const TOOLS: [&str; 21] = [ "analyze_bandar", "analyze_stock", "compare_stocks", @@ -24,6 +24,7 @@ const TOOLS: [&str; 20] = [ "get_ownership_changes", "get_price_history", "get_quotes", + "get_shareholder_movements", "get_shareholders", "ownership_status", "screen_stocks", @@ -551,6 +552,54 @@ fn corporate_actions_need_a_session_and_keep_kinds_apart() { assert_eq!(body["code"], "INVALIDINPUT"); } +#[test] +fn shareholder_movements_page_and_filter() { + let mut client = Client::start(&[], false); + let (is_error, body) = client.call("get_shareholder_movements", json!({})); + assert!(is_error, "{body}"); + assert_eq!(body["code"], "AUTHERROR"); + + let mut client = Client::start_with_env(&[], false, &[TEST_SESSION]); + let market = client.ok("get_shareholder_movements", json!({"pages": 2})); + assert_fetched(&market); + assert_eq!(market["source"], "stockbit"); + let rows = market["data"]["movements"].as_array().unwrap(); + assert_eq!(rows.len(), 14, "8 rows on page 1, 6 on the last page"); + assert_eq!(market["data"]["more"], false); + assert!( + rows.windows(2) + .all(|w| w[0]["date"].as_str() >= w[1]["date"].as_str()), + "newest first" + ); + + let sells = client.ok( + "get_shareholder_movements", + json!({"action": "sell", "source": "ksei", "holder_id": "1000004481", "pages": 3}), + ); + let rows = sells["data"]["movements"].as_array().unwrap(); + assert_eq!(rows.len(), 2); + assert!(rows.iter().all(|r| r["symbol"] == "ATLA" + && r["action"] == "sell" + && r["shares_change"].as_i64() < Some(0) + && r["price_estimated"] == true)); + + let bbca = client.ok("get_shareholder_movements", json!({"symbol": "bbca"})); + assert_eq!(bbca["data"]["more"], true, "BBCA has a second page"); + assert_eq!(bbca["data"]["movements"][0]["roles"], json!(["director"])); + + for bad in [ + json!({"action": "dividend"}), + json!({"source": "bing"}), + json!({"holder_id": "RUDI"}), + json!({"pages": 11}), + json!({"from": "2026-11-02", "to": "2026-11-01"}), + ] { + let (is_error, body) = client.call("get_shareholder_movements", bad.clone()); + assert!(is_error, "{bad} -> {body}"); + assert_eq!(body["code"], "INVALIDINPUT", "{bad} -> {body}"); + } +} + #[test] fn errors_carry_cli_codes() { let mut client = Client::start(&[], false); diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 0997cd4..b7c6832 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -296,6 +296,13 @@ WIB as the fallback. `get_corporate_calendar` filter by `CorporateAction::date` (the cum date for entitlements) and sort oldest first. Endpoint notes and the wider design: `docs/STOCKBIT.md`. +- Shareholder movements (`movements`, `api/stockbit/movement.rs`) read + `/insider/company/majorholder`: IDX insider disclosures and KSEI 5% holder + changes, 50 rows a page, filtered by Stockbit (`symbol`, `date_start`, + `date_end`, `insider` (holder id), `action_type`, `source_type`). Each page + is cached an hour under `stockbit-movements`, keyed by every filter and the + page. `ownership movements` and `get_shareholder_movements` read up to 10 + pages; the KSEI register in SQLite is not involved. ### Capability Gating ``` @@ -310,6 +317,7 @@ Factory functions: intraday_provider() → Box orderbook_provider() → Box corporate_action_provider() → Box + shareholder_movement_provider() → Box ``` `ProviderKind::Stockbit` serves quotes (and, with a session, daily history): diff --git a/docs/STOCKBIT.md b/docs/STOCKBIT.md index 037de85..4a0b507 100644 --- a/docs/STOCKBIT.md +++ b/docs/STOCKBIT.md @@ -167,19 +167,33 @@ lists are not errors. A row whose dates are all placeholders is dropped. ### Endpoint -`GET /insider/company/majorholder?symbol=&insider=&date_start=&date_end=&page=`; -all parameters optional. 50 rows a page, `data.is_more` for the next page. +Rows shipped as `idx ownership movements` and `get_shareholder_movements`; +the summary score is next. + +`GET /insider/company/majorholder?symbol=&insider=&date_start=&date_end=&action_type=&source_type=&page=`; +all parameters optional, all filtered by Stockbit (checked 2026-11-03). +`date_start` / `date_end` are YYYY-MM-DD; `insider` is the holder id, which is +the row's `id` (not unique per row); `action_type` takes `ACTION_TYPE_BUY`, +`_SELL`, `_TRANSFER`, `_CROSS` or `_CORPACTION` (the app's filter list); +`source_type` takes `SOURCE_TYPE_IDX` or `_KSEI`. `page` counts from 1. 50 rows +a page, `data.is_more` for the next page; a busy day has more than 50 rows. Without `symbol` it is market-wide, newest first: on 2026-11-03 the newest rows were from 2026-11-02. BBCA's 50 rows span 2024-03-22 to 2026-03-25. Each row (`data.movement[]`): `name`, `symbol`, `date` (`"25 Mar 26"`), `previous` / `current` / `changes` `{value: shares as "193,206", percentage}`, -`action_type` (`ACTION_TYPE_BUY|SELL|TRANSFER`), `nationality` +`action_type` (`ACTION_TYPE_BUY`, `_SELL`, `_TRANSFER`, `_CROSS`, +`_RIGHT_ISSUE`, `_PRIVATE_PLACEMENT`, `_TENDER_OFFER`; the bundle also names +`_BONUS_STOCK`, `_DIVIDEND_STOCK`, `_DIVIDEND_CASH`), `nationality` (`NATIONALITY_TYPE_LOCAL|FOREIGN`), `badges` (`SHAREHOLDER_BADGE_DIREKTUR`, `..._KOMISARIS`), `price.raw.value`, `value.raw.value` (IDR), `is_estimated_price`, `purpose` (free text such as "Pembelian", "Investasi"), `data_source.type` (`SOURCE_TYPE_IDX` for insider disclosures, `SOURCE_TYPE_KSEI` for 5% holder changes), `broker_detail` (empty so far). +KSEI rows carry an estimated price (`is_estimated_price`: true); IDX rows +mostly the trade price, though crossings can be estimated too. `CROSS` rows +name securities firms as the holder. A rights issue can change the stake +with no change in shares (dilution). ### Relation to `ownership` @@ -208,10 +222,15 @@ Yahoo prices, forward 5/20/60-session returns against IHSG). ### Surface -- `idx ownership movements [SYM] [--from DATE] [--to DATE] [--holder NAME] - [--action buy|sell|transfer] [--pages N]`: rows, newest first. -- `idx ownership movements --summary [--from DATE]`: the per-symbol score. -- MCP: `get_shareholder_movements {symbol?, from?, to?, holder?, pages?}`. +- `idx ownership movements [SYM] [--from DATE] [--to DATE] [--holder ID] + [--action buy|sell|transfer|cross|corporate-action] [--source idx|ksei] + [--pages N]`: rows, newest first (shipped). `--holder` takes the holder id + rather than a name: Stockbit filters by id, and a name search would only see + the pages already read. +- MCP: `get_shareholder_movements {symbol?, from?, to?, holder_id?, action?, + source?, pages?}` (shipped). +- Next: `idx ownership movements --summary [--from DATE]`, the per-symbol + score. ## P2 and P3 @@ -236,7 +255,7 @@ Yahoo prices, forward 5/20/60-session returns against IHSG). states (done 2026-11-03). 2. Corporate actions (parsers, `stocks actions`, `stocks calendar`, MCP, goldens) (done). -3. Shareholder movements, rows first, then `--summary`. +3. Shareholder movements, rows first (done), then `--summary`. 4. Event study for the movement score; P2 by demand. ## Open questions diff --git a/web/src/content/docs/cli/ownership.md b/web/src/content/docs/cli/ownership.md index 07b1037..f22f76c 100644 --- a/web/src/content/docs/cli/ownership.md +++ b/web/src/content/docs/cli/ownership.md @@ -36,6 +36,32 @@ two releases. `ticker` also reports concentration: the top holder's share, the top three, the Herfindahl index (HHI) and the free float (shares held by holders below 1%). +## Insider and major holder movements + +With your own Stockbit login (`idx stockbit login`, see [Stockbit](/cli/stockbit/)), +`movements` lists reported changes in holders' stakes, newest first. It reads +Stockbit live and needs no import: + +```bash +idx ownership movements BBCA # one stock, 50 rows +idx ownership movements # the whole market +idx ownership movements --action sell --source ksei --pages 3 +idx ownership movements --from 2026-10-01 --to 2026-10-31 +idx ownership movements --holder 1000004481 # one holder's history +``` + +Two sources share the list. `IDX` rows are insider disclosures: directors, +commissioners and other insiders, at any size, with the trade price. `KSEI` +rows are changes of holders at 5% and above, which report no price; Stockbit +estimates one, shown with `~`. `--holder` takes the number in the HOLDER ID +column. Shares are exact. Stakes are as Stockbit rounds them, so a director's +small holding reads `<0.01%`. + +These are filings, not signals. Many insiders buying at one price on one day +is usually a share plan, transfers are not trades, and a row appears days +after the change. Each page is 50 rows and one request to Stockbit (`--pages` +up to 10); answers are cached for an hour. + ## Import reports yourself The snapshot covers most needs. To load a month it lacks, or older history, diff --git a/web/src/content/docs/cli/reference.md b/web/src/content/docs/cli/reference.md index e02f3a4..6e35899 100644 --- a/web/src/content/docs/cli/reference.md +++ b/web/src/content/docs/cli/reference.md @@ -1158,6 +1158,7 @@ Commands: concentration Rank tickers by ownership concentration flow Show Bing institutional flow for a ticker changes Diff two KSEI releases + movements Insider and major holder buys and sells, as reported (Stockbit login) graph Ownership network graph resolve Manual entity resolution workflow releases List imported KSEI releases @@ -1547,6 +1548,79 @@ Examples: idx ownership changes --from 2026-08-31 --to 2026-09-30 ``` +### `idx ownership movements` + +```text +Reported changes in holders' stakes from your own Stockbit session (`idx stockbit login`), newest first: IDX insider disclosures (directors, commissioners and other insiders, any size, with the trade price) and KSEI's changes of holders at 5% and above (Stockbit estimates their price). One stock's, or the whole market's without SYMBOL. Each page is 50 rows and one request; answers are cached for an hour. + +These are filings, not signals: a share plan shows as many insiders buying at one price, and a row appears days after the change. + +Usage: idx ownership movements [OPTIONS] [SYMBOL] + +Arguments: + [SYMBOL] + Single ticker symbol (e.g. BBCA); omit for the whole market + +Options: + --from + First day, YYYY-MM-DD + + -o, --output + Output format [default: auto = table on a terminal, json when piped] + + [possible values: auto, table, json, jsonl] + + --no-color + Disable colored output + + --to + Last day, YYYY-MM-DD + + --holder + One holder's movements, by the id in the HOLDER ID column + + -q, --quiet + Suppress non-essential output + + --action + Only this kind of movement + + [possible values: buy, sell, transfer, cross, corporate-action] + + -v, --verbose... + Increase verbosity (-v, -vv) + + --provider + Market data provider [default: general.provider, else msn] + + [possible values: yahoo, msn, stockbit] + + --source + Only IDX insider disclosures or KSEI 5% holder changes + + [possible values: idx, ksei] + + --offline + Run without network requests + + --pages + Pages of 50 rows to read (1-10) + + [default: 1] + + --no-cache + Bypass local cache + + -h, --help + Print help (see a summary with '-h') + +Examples: + idx ownership movements BBCA + idx ownership movements --action sell --source ksei + idx ownership movements --from 2026-10-01 --to 2026-10-31 --pages 5 + idx ownership movements --holder 1000004481 # one holder's history (HOLDER ID column) +``` + ### `idx ownership graph` ```text diff --git a/web/src/content/docs/cli/stockbit.md b/web/src/content/docs/cli/stockbit.md index 5c54f8f..735e066 100644 --- a/web/src/content/docs/cli/stockbit.md +++ b/web/src/content/docs/cli/stockbit.md @@ -77,6 +77,7 @@ idx stocks orderbook BBCA # depth, queued orders, foreign flow idx stocks orderbook BBRI --depth 5 idx stocks actions BBCA # dividends, splits, meetings, ... idx stocks calendar --kind dividend # cum dates in the next 30 days +idx ownership movements BBCA # insider and major holder buys and sells idx --provider stockbit stocks quote BBCA # live, not delayed idx --provider stockbit stocks history BBCA --period 1y # Stockbit's daily candles idx stockbit logout @@ -201,6 +202,7 @@ What the login adds: | `stocks history` under `--provider stockbit` | Yahoo | Stockbit's daily candles for `5d` to `1y`; Yahoo for other windows | | `stocks intraday` | public page | public page | | `stocks actions`, `stocks calendar` | `AUTHERROR` | corporate actions: one stock's history, or the market's calendar | +| `ownership movements` | `AUTHERROR` | insider and major holder buys and sells, as reported to IDX and KSEI | The order book is what Stockbit's own app shows. Outside trading it is the book as the market left it, and the output says so. Foreign buy, sell and net @@ -222,6 +224,6 @@ market or republishing prices. With your login, automated use is tied to your account: keep it human-paced. Over MCP, the same data comes from `get_intraday`, `get_orderbook`, -`get_corporate_actions`, `get_corporate_calendar` and `stockbit_status`, and from `get_quotes` and `get_price_history` when the +`get_corporate_actions`, `get_corporate_calendar`, `get_shareholder_movements` and `stockbit_status`, and from `get_quotes` and `get_price_history` when the server runs with `IDX_PROVIDER=stockbit`. The server never logs in; run `idx stockbit login` in a terminal. diff --git a/web/src/content/docs/mcp/index.md b/web/src/content/docs/mcp/index.md index d73870a..d45736d 100644 --- a/web/src/content/docs/mcp/index.md +++ b/web/src/content/docs/mcp/index.md @@ -5,8 +5,8 @@ description: idx-mcp serves idx's stock and ownership data to AI agents over MCP `idx-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server over stdio. It gives an agent the same data as the `idx` CLI, as -[20 tools](/mcp/tools/) (plus an opt-in `ownership_sync`): quotes, today's -session by the minute, the order book and corporate actions (with a Stockbit +[21 tools](/mcp/tools/) (plus an opt-in `ownership_sync`): quotes, today's +session by the minute, the order book, corporate actions and insider movements (with a Stockbit login), price history, screening, company data, analysis, comparison, broker summaries, bandarmology, foreign flow, and the KSEI ownership queries. diff --git a/web/src/content/docs/mcp/tools.md b/web/src/content/docs/mcp/tools.md index 19e1260..4dca344 100644 --- a/web/src/content/docs/mcp/tools.md +++ b/web/src/content/docs/mcp/tools.md @@ -150,6 +150,20 @@ Latest quotes (price, change, volume, 52-week range, market cap) for one or more | --- | --- | --- | --- | | `symbols` | array of string | yes | IDX tickers, e.g. ["BBCA", "BBRI"]; the `.JK` suffix is optional. At most 20. | +## `get_shareholder_movements` + +Reported changes in insiders' and major holders' stakes in IDX stocks, from the user's own Stockbit session, newest first: IDX insider disclosures (directors, commissioners and other insiders, any size, with the trade price) and KSEI changes of holders at 5% and above (price estimated: `price_estimated`). One stock's, or the market's without `symbol`. Shares are exact and signed (`shares_change` < 0 is a sale); percentages are basis points as Stockbit rounds them, so a small insider can read 0. `more` is true when rows remain past `pages`. These are filings, not signals: many insiders buying at one price on one day is usually a share plan, and rows appear days after the change. AUTHERROR means there is no session: call stockbit_status, then stockbit_login. + +| Input | Type | Required | Description | +| --- | --- | --- | --- | +| `action` | `buy` / `sell` / `transfer` / `cross` / `corporate-action` | no | Only this kind of movement; "corporate-action" covers rights issues, private placements and the like. | +| `from` | string | no | First day, YYYY-MM-DD. | +| `holder_id` | string | no | One holder's movements: the `holder_id` of a row. | +| `pages` | integer | no | Pages of 50 rows (default 1, at most 10); each page is one request to Stockbit. | +| `source` | `idx` / `ksei` | no | "idx" (insider disclosures, any size) or "ksei" (holders at 5% and above). | +| `symbol` | string | no | IDX ticker, e.g. "BBCA"; omit for the whole market. | +| `to` | string | no | Last day, YYYY-MM-DD. | + ## `get_shareholders` Shareholders above 1% of an IDX ticker from the latest KSEI release, with concentration metrics (top1, top3, HHI, free float). From 615083ee0ba8314433598a385cc885cb7af1f068 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Tue, 3 Nov 2026 16:02:26 +0700 Subject: [PATCH 06/16] test(smoke): live case for ownership movements with a Stockbit session Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- docs/SMOKE.md | 4 ++-- scripts/live-smoke.sh | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/SMOKE.md b/docs/SMOKE.md index b87705f..5faad19 100644 --- a/docs/SMOKE.md +++ b/docs/SMOKE.md @@ -63,8 +63,8 @@ scripts/live-smoke.sh --dry-run session sees `market_status: close` and no bid/offer. These run without a Stockbit login: each side has its own config, and seeding it with a real refresh token would rotate (and so retire) that token. When - `idx stockbit status` reports a session, `stocks orderbook`, `stocks actions` - and `stocks calendar` also run, on the new binary with your real config + `idx stockbit status` reports a session, `stocks orderbook`, `stocks actions`, + `stocks calendar` and `ownership movements` (market-wide, one page) also run, on the new binary with your real config directory (the session file is shared under its lock, never copied; cache and data stay isolated). Check the rest by hand: `idx --provider stockbit stocks quote BBCA` and diff --git a/scripts/live-smoke.sh b/scripts/live-smoke.sh index 026911f..a63ba96 100755 --- a/scripts/live-smoke.sh +++ b/scripts/live-smoke.sh @@ -136,6 +136,8 @@ contract() { echo '(.symbol | type == "string") and (.price | type == "number") and (.market_status | type == "string") and (.bids | type == "array") and (.offers | type == "array")' ;; "stocks actions "*|"stocks calendar"*) echo 'type == "array" and length > 0 and all(.[]; (.symbol | type == "string") and (.kind | type == "string") and (.date | type == "string"))' ;; + "ownership movements"*) + echo '(.more | type == "boolean") and (.movements | length > 0) and all(.movements[]; (.symbol | type == "string") and (.date | type == "string") and (.holder_id | type == "string") and (.action | type == "string") and (.shares_change | type == "number"))' ;; "stocks broker "*) echo '(.symbol | type == "string") and (.buyers | length > 0) and (.sellers | length > 0) and all(.buyers[]; (.code | type == "string") and (.value | type == "number")) and (.total_value | type == "number")' ;; "stocks bandar "*) @@ -267,9 +269,10 @@ if selected stockbit; then run_new_case orderbook "stocks orderbook $SYMBOL --depth 5" run_new_case actions "stocks actions $SYMBOL --kind dividend,split" run_new_case calendar "stocks calendar --kind dividend,rights" + run_new_case movements "ownership movements" REAL_CONFIG=0 else - echo " no Stockbit session: orderbook, actions and calendar not run" + echo " no Stockbit session: orderbook, actions, calendar and movements not run" fi fi From 1e5561e9903ce8369391a8bf8920aab78d9910ee Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 17:35:51 +0700 Subject: [PATCH 07/16] fix(actions): JSON kinds match --kind, and harden parsing and ranges - JSON named kinds by their Rust names (public_expose, tender_offer, stock_dividend, reverse_split) while --kind and MCP take expose, tender, stock-dividend, reverse-split, so an output kind could not be passed back. JSON now uses the input names; old cache entries still read, and --kind also accepts underscores. - {"dividend": null, "today": "..."} failed to parse and aborted the whole command; a null list beside scalars now reads as none. - An extreme --from panicked on the default 30 days; it is an error now. The 366-day limit let 367 days through; it counts both ends now. - An entitlement without a cum date sat on its ex date under a note that calls DATE the cum date. The table marks it (ex) and says what that means; JSON leaves cum_date out, as before, and the docs say so. - A dividend's currency was ignored; one not in IDR now carries currency and the table shows it instead of Rp. - The live check no longer fails a quiet month's empty calendar. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- crates/idx-cli/src/output/table.rs | 36 ++++++++-- .../tests/golden/stockbit-actions.json.golden | 2 +- .../stockbit-calendar-meetings.json.golden | 2 +- .../idx-core/src/api/stockbit/corpaction.rs | 30 ++++++++- crates/idx-core/src/corporate/types.rs | 65 ++++++++++++++++--- crates/idx-mcp/src/server.rs | 5 +- crates/idx-mcp/tests/golden/tools.json | 2 +- scripts/live-smoke.sh | 6 +- web/src/content/docs/cli/stocks.md | 5 +- web/src/content/docs/mcp/tools.md | 2 +- 10 files changed, 131 insertions(+), 24 deletions(-) diff --git a/crates/idx-cli/src/output/table.rs b/crates/idx-cli/src/output/table.rs index 1663578..af37008 100644 --- a/crates/idx-cli/src/output/table.rs +++ b/crates/idx-cli/src/output/table.rs @@ -1708,10 +1708,14 @@ fn action_detail(action: &CorporateAction) -> String { let mut parts: Vec = Vec::new(); match action.kind { ActionKind::Dividend => { + let unit = action + .currency + .as_deref() + .map_or_else(|| "Rp".to_string(), terminal_safe); parts.extend( action .cash_per_share - .map(|c| format!("Rp {} per share", format_rupiah(c))), + .map(|c| format!("{unit} {} per share", format_rupiah(c))), ); } ActionKind::StockDividend | ActionKind::Bonus => { @@ -1784,6 +1788,28 @@ fn action_detail(action: &CorporateAction) -> String { const CORPORATE_DATE_NOTE: &str = "DATE is the cum date for dividends, bonuses, rights and \ splits (buy by that day to be entitled); for other actions, the event's first day."; +const CORPORATE_EX_NOTE: &str = "A DATE marked (ex) is the ex date: Stockbit gives no cum \ +date for it, and buying that day is too late to be entitled."; + +/// An entitlement Stockbit gave no cum date for sits on its ex date. +fn on_ex_date(action: &CorporateAction) -> bool { + action.kind.is_entitlement() && action.cum_date.is_none() +} + +fn action_date_cell(action: &CorporateAction) -> Cell { + if on_ex_date(action) { + cell(format!("{} (ex)", action.date)) + } else { + cell(action.date) + } +} + +fn print_corporate_notes(actions: &[CorporateAction]) { + println!("{CORPORATE_DATE_NOTE}"); + if actions.iter().any(on_ex_date) { + println!("{CORPORATE_EX_NOTE}"); + } +} fn opt_date(date: Option) -> String { date.map(|d| d.to_string()) @@ -1805,7 +1831,7 @@ pub fn print_corporate_actions(symbol: &str, actions: &[CorporateAction]) -> Res .set_header(vec!["DATE", "KIND", "EX", "RECORD", "PAY", "DETAIL"]); for action in actions { table.add_row(vec![ - cell(action.date), + action_date_cell(action), cell(action_kind_label(action.kind)), cell(opt_date(action.ex_date)), cell(opt_date(action.record_date)), @@ -1814,7 +1840,7 @@ pub fn print_corporate_actions(symbol: &str, actions: &[CorporateAction]) -> Res ]); } println!("{table}"); - println!("{CORPORATE_DATE_NOTE}"); + print_corporate_notes(actions); } println!("{STOCKBIT_SESSION_NOTE}"); Ok(()) @@ -1844,7 +1870,7 @@ pub fn print_corporate_calendar( .set_header(vec!["DATE", "SYMBOL", "KIND", "EX", "DETAIL"]); for action in actions { table.add_row(vec![ - cell(action.date), + action_date_cell(action), cell(action.symbol.trim_end_matches(".JK")), cell(action_kind_label(action.kind)), cell(opt_date(action.ex_date)), @@ -1852,7 +1878,7 @@ pub fn print_corporate_calendar( ]); } println!("{table}"); - println!("{CORPORATE_DATE_NOTE}"); + print_corporate_notes(actions); } println!("{STOCKBIT_SESSION_NOTE}"); Ok(()) diff --git a/crates/idx-cli/tests/golden/stockbit-actions.json.golden b/crates/idx-cli/tests/golden/stockbit-actions.json.golden index d5f9ad6..a49932d 100644 --- a/crates/idx-cli/tests/golden/stockbit-actions.json.golden +++ b/crates/idx-cli/tests/golden/stockbit-actions.json.golden @@ -1,4 +1,4 @@ exit: 0 --- stdout -[{"symbol":"BBCA.JK","kind":"public_expose","date":"2026-09-09","time":"16:00","venue":"Public Expose Live 2026 yang tercantum pada website idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2026-03-12","record_date":"2026-02-09","time":"14:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta 10310"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2025-09-11","time":"16:00","venue":"Public Expose Live 2025 yang tercantum pada website idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2025-03-12","record_date":"2025-02-07","time":"09:30","venue":"Menara BCA, Grand Indonesia, Jl. M.H. Thamrin No. 1, Jakarta, 10310"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2024-08-28","time":"15:00","venue":"Public Expose Live 2024 Informasi Jadwal Pubex Live 2024 dan pendaftaran peserta di website www.idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2024-03-14","record_date":"2024-02-07","time":"09:30","venue":"Menara BCA Grand Indonesia Lt 18.Jl. MH Thamrin No 1 Jakarta Selatan"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2023-11-29","time":"10:00","venue":"Public Expose Live 2023"},{"symbol":"BBCA.JK","kind":"meeting","date":"2023-03-16","record_date":"2023-02-13","time":"09:30","venue":"Menara BCA"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2022-09-14","time":"10:00","venue":"Public Expose Live 2022"},{"symbol":"BBCA.JK","kind":"meeting","date":"2022-03-17","record_date":"2022-02-14","time":"09:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta"},{"symbol":"BBCA.JK","kind":"split","date":"2021-10-12","cum_date":"2021-10-12","ex_date":"2021-10-13","record_date":"2021-10-14","ratio":{"old":1,"new":5},"factor":5.0},{"symbol":"BBCA.JK","kind":"meeting","date":"2021-09-23","record_date":"2021-08-27","time":"10:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta"},{"symbol":"BBCA.JK","kind":"public_expose","date":"2021-09-08","time":"15:00","venue":"Public Expose Live 2021"},{"symbol":"BBCA.JK","kind":"meeting","date":"2021-03-29","record_date":"2021-02-24","time":"09:00","venue":"Menara BCA, Grand Indonesia, Lt 19. Jl. M.H Thamrin No 1. Jakarta"},{"symbol":"BBCA.JK","kind":"meeting","date":"2020-07-30","record_date":"2020-07-03","time":"10:00","venue":"Menara BCA Grand Indonesia, Lt. 19. Jl. M.H. Thamrin No. 1. Jakarta"},{"symbol":"BBCA.JK","kind":"split","date":"2008-01-25","cum_date":"2008-01-25","ex_date":"2008-01-28","record_date":"2008-01-30","ratio":{"old":1,"new":2},"factor":2.0},{"symbol":"BBCA.JK","kind":"split","date":"2004-06-07","cum_date":"2004-06-07","ex_date":"2004-06-08","record_date":"2004-06-10","ratio":{"old":1,"new":2},"factor":2.0}] +[{"symbol":"BBCA.JK","kind":"expose","date":"2026-09-09","time":"16:00","venue":"Public Expose Live 2026 yang tercantum pada website idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2026-03-12","record_date":"2026-02-09","time":"14:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta 10310"},{"symbol":"BBCA.JK","kind":"expose","date":"2025-09-11","time":"16:00","venue":"Public Expose Live 2025 yang tercantum pada website idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2025-03-12","record_date":"2025-02-07","time":"09:30","venue":"Menara BCA, Grand Indonesia, Jl. M.H. Thamrin No. 1, Jakarta, 10310"},{"symbol":"BBCA.JK","kind":"expose","date":"2024-08-28","time":"15:00","venue":"Public Expose Live 2024 Informasi Jadwal Pubex Live 2024 dan pendaftaran peserta di website www.idx.co.id"},{"symbol":"BBCA.JK","kind":"meeting","date":"2024-03-14","record_date":"2024-02-07","time":"09:30","venue":"Menara BCA Grand Indonesia Lt 18.Jl. MH Thamrin No 1 Jakarta Selatan"},{"symbol":"BBCA.JK","kind":"expose","date":"2023-11-29","time":"10:00","venue":"Public Expose Live 2023"},{"symbol":"BBCA.JK","kind":"meeting","date":"2023-03-16","record_date":"2023-02-13","time":"09:30","venue":"Menara BCA"},{"symbol":"BBCA.JK","kind":"expose","date":"2022-09-14","time":"10:00","venue":"Public Expose Live 2022"},{"symbol":"BBCA.JK","kind":"meeting","date":"2022-03-17","record_date":"2022-02-14","time":"09:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta"},{"symbol":"BBCA.JK","kind":"split","date":"2021-10-12","cum_date":"2021-10-12","ex_date":"2021-10-13","record_date":"2021-10-14","ratio":{"old":1,"new":5},"factor":5.0},{"symbol":"BBCA.JK","kind":"meeting","date":"2021-09-23","record_date":"2021-08-27","time":"10:00","venue":"Menara BCA, Grand Indonesia Jl. M.H. Thamrin No. 1 Jakarta"},{"symbol":"BBCA.JK","kind":"expose","date":"2021-09-08","time":"15:00","venue":"Public Expose Live 2021"},{"symbol":"BBCA.JK","kind":"meeting","date":"2021-03-29","record_date":"2021-02-24","time":"09:00","venue":"Menara BCA, Grand Indonesia, Lt 19. Jl. M.H Thamrin No 1. Jakarta"},{"symbol":"BBCA.JK","kind":"meeting","date":"2020-07-30","record_date":"2020-07-03","time":"10:00","venue":"Menara BCA Grand Indonesia, Lt. 19. Jl. M.H. Thamrin No. 1. Jakarta"},{"symbol":"BBCA.JK","kind":"split","date":"2008-01-25","cum_date":"2008-01-25","ex_date":"2008-01-28","record_date":"2008-01-30","ratio":{"old":1,"new":2},"factor":2.0},{"symbol":"BBCA.JK","kind":"split","date":"2004-06-07","cum_date":"2004-06-07","ex_date":"2004-06-08","record_date":"2004-06-10","ratio":{"old":1,"new":2},"factor":2.0}] --- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-calendar-meetings.json.golden b/crates/idx-cli/tests/golden/stockbit-calendar-meetings.json.golden index 28caa37..0f7f01b 100644 --- a/crates/idx-cli/tests/golden/stockbit-calendar-meetings.json.golden +++ b/crates/idx-cli/tests/golden/stockbit-calendar-meetings.json.golden @@ -1,4 +1,4 @@ exit: 0 --- stdout -[{"symbol":"AUTO.JK","kind":"public_expose","date":"2026-11-05","time":"10:00","venue":"Zoom Webinar"},{"symbol":"BATA.JK","kind":"meeting","date":"2026-11-05","record_date":"2026-10-09","time":"14:00","venue":"Gedung Ventura, lantai 7. Jl. Raden Ajeng Kartini No.26, Cilandak Barat, Jakarta Selatan"},{"symbol":"AMAG.JK","kind":"public_expose","date":"2026-11-06","time":"15:00","venue":"Virtual Zoom Webinar, di PT Asuransi Multi Artha Guna Tbk, Gedung TCC Batavia Tower One, Jalan KH Mas Mansyur Kav 126, Jakarta Pusat"},{"symbol":"BRIS.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"10:00","venue":"Jakarta Pusat, melalui fasilitas Electronic General Meeting System KSEI (eASY.KSEI) dalam tautan https//akses.ksei.co.id"},{"symbol":"GIAA.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"14:00","venue":"Secara elektronik melalui sistem eASY.KSEI (https//akses.ksei.co.id/)"},{"symbol":"INPS.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-07","time":"14:00","venue":"Gedung Inprase, Jl. Sunter Garden Raya Blok D8 No. 3G-3H, Sunter Agung, Tanjung Priok, Jakarta Utara, DKI Jakarta 14350"},{"symbol":"KDTN.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"14:00","venue":"PT Puri Sentul Permai Tbk diumumkan dan sesuai iklan)"},{"symbol":"MTFN.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"10:00","venue":"Kantor Taman E3.3, Unit D3A, Lantai 5, Jl. DR. Ide Anak Agung Gde Agung, Kuningan Jakarta Selatan"},{"symbol":"MTFN.JK","kind":"public_expose","date":"2026-11-06","time":"11:00","venue":"Kantor Taman E3.3, Unit D3A, Lantai 5 Jl. DR. Ide Anak Agung Gde Agung, Kuningan Jakarta Selatan"},{"symbol":"ULTJ.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-08-31","time":"10:00","venue":"Kantor Perseroan, Jalan Raya Cimareme No 131 Bandung Barat, Jawa Barat Indonesia"}] +[{"symbol":"AUTO.JK","kind":"expose","date":"2026-11-05","time":"10:00","venue":"Zoom Webinar"},{"symbol":"BATA.JK","kind":"meeting","date":"2026-11-05","record_date":"2026-10-09","time":"14:00","venue":"Gedung Ventura, lantai 7. Jl. Raden Ajeng Kartini No.26, Cilandak Barat, Jakarta Selatan"},{"symbol":"AMAG.JK","kind":"expose","date":"2026-11-06","time":"15:00","venue":"Virtual Zoom Webinar, di PT Asuransi Multi Artha Guna Tbk, Gedung TCC Batavia Tower One, Jalan KH Mas Mansyur Kav 126, Jakarta Pusat"},{"symbol":"BRIS.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"10:00","venue":"Jakarta Pusat, melalui fasilitas Electronic General Meeting System KSEI (eASY.KSEI) dalam tautan https//akses.ksei.co.id"},{"symbol":"GIAA.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"14:00","venue":"Secara elektronik melalui sistem eASY.KSEI (https//akses.ksei.co.id/)"},{"symbol":"INPS.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-07","time":"14:00","venue":"Gedung Inprase, Jl. Sunter Garden Raya Blok D8 No. 3G-3H, Sunter Agung, Tanjung Priok, Jakarta Utara, DKI Jakarta 14350"},{"symbol":"KDTN.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"14:00","venue":"PT Puri Sentul Permai Tbk diumumkan dan sesuai iklan)"},{"symbol":"MTFN.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-10-12","time":"10:00","venue":"Kantor Taman E3.3, Unit D3A, Lantai 5, Jl. DR. Ide Anak Agung Gde Agung, Kuningan Jakarta Selatan"},{"symbol":"MTFN.JK","kind":"expose","date":"2026-11-06","time":"11:00","venue":"Kantor Taman E3.3, Unit D3A, Lantai 5 Jl. DR. Ide Anak Agung Gde Agung, Kuningan Jakarta Selatan"},{"symbol":"ULTJ.JK","kind":"meeting","date":"2026-11-06","record_date":"2026-08-31","time":"10:00","venue":"Kantor Perseroan, Jalan Raya Cimareme No 131 Bandung Barat, Jawa Barat Indonesia"}] --- stderr diff --git a/crates/idx-core/src/api/stockbit/corpaction.rs b/crates/idx-core/src/api/stockbit/corpaction.rs index 7dfb0f1..0848ca8 100644 --- a/crates/idx-core/src/api/stockbit/corpaction.rs +++ b/crates/idx-core/src/api/stockbit/corpaction.rs @@ -47,7 +47,9 @@ pub fn parse_corporate_actions( let rows = match root.get("data") { Some(Value::Object(data)) => match data.values().find_map(Value::as_array) { Some(rows) => rows.as_slice(), - None if data.values().all(Value::is_null) => &[], + // No rows reads `{"dividend": null, "today": "..."}`: a null list + // beside scalars. An object in their place is a new layout. + None if !data.values().any(Value::is_object) => &[], None => return Err(bad("no list in data".to_string())), }, Some(Value::Array(rows)) => rows.as_slice(), @@ -97,6 +99,9 @@ fn entitlement( match kind { ActionKind::Dividend => { action.cash_per_share = number(suffixed(row, "value")).map(|v| round_to(v, 2)); + action.currency = text(suffixed(row, "currency")) + .map(|c| c.trim_start_matches("CURRENCY_").to_ascii_uppercase()) + .filter(|c| c != "IDR"); } ActionKind::Rights => { action.price = whole(suffixed(row, "price")); @@ -376,10 +381,16 @@ mod tests { ), (ActionKind::ReverseSplit, r#"{"data":{"stock_reverse":[]}}"#), (ActionKind::Dividend, r#"{"data":null}"#), + ( + ActionKind::Dividend, + r#"{"data":{"dividend":null,"today":"2026-11-04"}}"#, + ), ] { assert!(parse_corporate_actions(kind, body).unwrap().is_empty()); } assert!(parse_corporate_actions(ActionKind::Dividend, r#"{"message":"x"}"#).is_err()); + let moved = r#"{"data":{"dividend":{"rows":[]},"today":"2026-11-04"}}"#; + assert!(parse_corporate_actions(ActionKind::Dividend, moved).is_err()); // A reverse split named like a split, read by suffix. let body = r#"{"data":{"stock_reverse":[{"company_symbol":"ABCD", "reverse_cumdate":"2026-12-01","reverse_exdate":"2026-12-02", @@ -389,6 +400,23 @@ mod tests { assert_eq!(rows[0].factor, Some(0.1)); } + /// A dividend not in IDR names its currency; one in IDR leaves it out. + /// Without a cum date, the action sits on its ex date. + #[test] + fn test_parse_dividend_currency_and_missing_cum_date() { + let body = r#"{"data":{"dividend":[ + {"company_symbol":"ABCD","dividend_cumdate":"2026-11-11", + "dividend_exdate":"2026-11-12","dividend_value":"0.0012", + "dividend_currency":"CURRENCY_USD"}, + {"company_symbol":"EFGH","dividend_cumdate":"0001-01-01 00:00:00", + "dividend_exdate":"2026-11-12","dividend_value":"5", + "dividend_currency":"CURRENCY_IDR"}]}}"#; + let rows = parse_corporate_actions(ActionKind::Dividend, body).unwrap(); + assert_eq!(rows[0].currency.as_deref(), Some("USD")); + assert_eq!(rows[1].currency, None); + assert_eq!((rows[1].date, rows[1].cum_date), (day("2026-11-12"), None)); + } + #[test] fn test_parse_numbers_and_placeholders() { assert_eq!(number(Some(&Value::from("1,191.09"))), Some(1191.09)); diff --git a/crates/idx-core/src/corporate/types.rs b/crates/idx-core/src/corporate/types.rs index 97984e3..b6086c8 100644 --- a/crates/idx-core/src/corporate/types.rs +++ b/crates/idx-core/src/corporate/types.rs @@ -3,14 +3,17 @@ use serde::{Deserialize, Serialize}; use crate::error::IdxError; -/// The kinds of corporate action Stockbit lists, one request each. +/// The kinds of corporate action Stockbit lists, one request each. JSON +/// names them as `--kind` does (`as_str`), so an output kind can be passed +/// back in. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[cfg_attr(feature = "clap", derive(clap::ValueEnum))] -#[serde(rename_all = "snake_case")] +#[serde(rename_all = "kebab-case")] pub enum ActionKind { /// Cash dividend. Dividend, #[cfg_attr(feature = "clap", value(name = "stock-dividend"))] + #[serde(alias = "stock_dividend")] StockDividend, /// Bonus shares. Bonus, @@ -20,14 +23,17 @@ pub enum ActionKind { /// Stock split. Split, #[cfg_attr(feature = "clap", value(name = "reverse-split"))] + #[serde(alias = "reverse_split")] ReverseSplit, /// Shareholders' meeting (RUPS). Meeting, /// Public expose. #[cfg_attr(feature = "clap", value(name = "expose"))] + #[serde(rename = "expose", alias = "public_expose")] PublicExpose, Ipo, #[cfg_attr(feature = "clap", value(name = "tender"))] + #[serde(rename = "tender", alias = "tender_offer")] TenderOffer, } @@ -96,9 +102,10 @@ impl std::str::FromStr for ActionKind { type Err = IdxError; fn from_str(value: &str) -> Result { + let wanted = value.trim().to_ascii_lowercase().replace('_', "-"); Self::ALL .into_iter() - .find(|kind| kind.as_str() == value) + .find(|kind| kind.as_str() == wanted) .ok_or_else(|| { let names: Vec<_> = Self::ALL.iter().map(|k| k.as_str()).collect(); IdxError::InvalidInput(format!( @@ -135,7 +142,8 @@ pub struct CorporateAction { /// Where the action sits on a calendar: the cum date for entitlements /// (the last day to buy and be entitled), else the meeting or expose /// day, the listing day, a warrant's first trading day, or a tender - /// offer's first day. + /// offer's first day. An entitlement Stockbit gives no cum date for is + /// placed on its ex date, and `cum_date` is then absent. pub date: NaiveDate, #[serde(default, skip_serializing_if = "Option::is_none")] pub cum_date: Option, @@ -150,6 +158,10 @@ pub struct CorporateAction { /// e.g. 3.8). #[serde(default, skip_serializing_if = "Option::is_none")] pub cash_per_share: Option, + /// The dividend's currency (ISO code, e.g. `USD`) when it is not IDR; + /// absent for IDR, which every recorded dividend was. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub currency: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub ratio: Option, /// Stockbit's price adjustment factor: 5 for a 1:5 split, 1.6667 for a @@ -194,6 +206,7 @@ impl CorporateAction { record_date: None, pay_date: None, cash_per_share: None, + currency: None, ratio: None, factor: None, price: None, @@ -221,7 +234,8 @@ pub struct CalendarRange { } impl CalendarRange { - /// `from` defaults to today, `to` to 30 days after `from`. + /// `from` defaults to today, `to` to 30 days after `from`; at most + /// `CALENDAR_MAX_DAYS` days, counting both ends. pub fn from_args( from: Option<&str>, to: Option<&str>, @@ -233,16 +247,18 @@ impl CalendarRange { }) }; let from = from.map(|v| parse("from", v)).transpose()?.unwrap_or(today); - let to = to - .map(|v| parse("to", v)) - .transpose()? - .unwrap_or(from + Duration::days(CALENDAR_DEFAULT_DAYS)); + let to = match to { + Some(v) => parse("to", v)?, + None => from + .checked_add_signed(Duration::days(CALENDAR_DEFAULT_DAYS)) + .ok_or_else(|| IdxError::InvalidInput(format!("from ({from}) is out of range")))?, + }; if to < from { return Err(IdxError::InvalidInput(format!( "to ({to}) is before from ({from})" ))); } - if (to - from).num_days() > CALENDAR_MAX_DAYS { + if (to - from).num_days() >= CALENDAR_MAX_DAYS { return Err(IdxError::InvalidInput(format!( "a calendar covers at most {CALENDAR_MAX_DAYS} days" ))); @@ -270,9 +286,13 @@ mod tests { assert_eq!((range.from, range.to), (today, day("2026-12-03"))); let range = CalendarRange::from_args(Some("2026-11-10"), None, today).unwrap(); assert_eq!(range.to, day("2026-12-10")); + // 366 days counting both ends is the most. + let range = CalendarRange::from_args(Some("2028-01-01"), Some("2028-12-31"), today); + assert!(range.is_ok()); for (from, to) in [ (Some("2026-11-10"), Some("2026-11-09")), (Some("2026-01-01"), Some("2027-06-01")), + (Some("2028-01-01"), Some("2029-01-01")), (Some("11/10/2026"), None), ] { assert!(matches!( @@ -282,11 +302,36 @@ mod tests { } } + /// The last date there is: 30 days on is an error, not a panic. + #[test] + fn test_calendar_range_at_the_end_of_time() { + let last = NaiveDate::MAX.format("%Y-%m-%d").to_string(); + let err = CalendarRange::from_args(Some(&last), None, day("2026-11-03")).unwrap_err(); + assert!(err.to_string().contains("out of range"), "{err}"); + } + #[test] fn test_action_kind_names_round_trip() { for kind in ActionKind::ALL { assert_eq!(kind.as_str().parse::().unwrap(), kind); } assert!("rups".parse::().is_err()); + assert_eq!( + "stock_dividend".parse::().unwrap(), + ActionKind::StockDividend + ); + } + + /// JSON's `kind` is the name `--kind` and MCP take. + #[test] + fn test_action_kind_json_is_the_input_name() { + for kind in ActionKind::ALL { + let json = serde_json::to_value(kind).unwrap(); + assert_eq!(json, kind.as_str(), "{kind:?}"); + assert_eq!(serde_json::from_value::(json).unwrap(), kind); + } + // Entries cached before the names changed still read. + let old: ActionKind = serde_json::from_str("\"public_expose\"").unwrap(); + assert_eq!(old, ActionKind::PublicExpose); } } diff --git a/crates/idx-mcp/src/server.rs b/crates/idx-mcp/src/server.rs index 23bbffa..3790249 100644 --- a/crates/idx-mcp/src/server.rs +++ b/crates/idx-mcp/src/server.rs @@ -358,8 +358,9 @@ average price, the close, `change_bps` and `non_regular_bps`." description = "Corporate actions of one IDX stock from the user's own Stockbit \ session, newest first: `kind` (dividend, stock-dividend, bonus, rights, warrant, split, \ reverse-split, meeting, expose, ipo, tender), `date` (the cum date for dividends, bonuses, \ -rights and splits, i.e. the last day to buy and be entitled; else the event's first day), \ -`ex_date`, `record_date`, `pay_date`, and per kind `cash_per_share` (IDR, may have decimals), \ +rights and splits, i.e. the last day to buy and be entitled, or the ex date when `cum_date` \ +is absent; else the event's first day), `ex_date`, `record_date`, `pay_date`, and per kind \ +`cash_per_share` (IDR, may have decimals; in `currency`, an ISO code, when that is present), \ `ratio` {old, new} (1:5 split = 1 share becomes 5; 655:104 rights = 104 rights per 655 held), \ `factor` (price adjustment), `price` (rights, warrant exercise, tender or IPO price, IDR), \ `period` and `exercise` {start, end}, `shares`, `percentage_bps`, `time`, `venue`. Absent \ diff --git a/crates/idx-mcp/tests/golden/tools.json b/crates/idx-mcp/tests/golden/tools.json index bdec564..13ecd5e 100644 --- a/crates/idx-mcp/tests/golden/tools.json +++ b/crates/idx-mcp/tests/golden/tools.json @@ -236,7 +236,7 @@ "name": "get_company" }, { - "description": "Corporate actions of one IDX stock from the user's own Stockbit session, newest first: `kind` (dividend, stock-dividend, bonus, rights, warrant, split, reverse-split, meeting, expose, ipo, tender), `date` (the cum date for dividends, bonuses, rights and splits, i.e. the last day to buy and be entitled; else the event's first day), `ex_date`, `record_date`, `pay_date`, and per kind `cash_per_share` (IDR, may have decimals), `ratio` {old, new} (1:5 split = 1 share becomes 5; 655:104 rights = 104 rights per 655 held), `factor` (price adjustment), `price` (rights, warrant exercise, tender or IPO price, IDR), `period` and `exercise` {start, end}, `shares`, `percentage_bps`, `time`, `venue`. Absent fields are omitted. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours). AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", + "description": "Corporate actions of one IDX stock from the user's own Stockbit session, newest first: `kind` (dividend, stock-dividend, bonus, rights, warrant, split, reverse-split, meeting, expose, ipo, tender), `date` (the cum date for dividends, bonuses, rights and splits, i.e. the last day to buy and be entitled, or the ex date when `cum_date` is absent; else the event's first day), `ex_date`, `record_date`, `pay_date`, and per kind `cash_per_share` (IDR, may have decimals; in `currency`, an ISO code, when that is present), `ratio` {old, new} (1:5 split = 1 share becomes 5; 655:104 rights = 104 rights per 655 held), `factor` (price adjustment), `price` (rights, warrant exercise, tender or IPO price, IDR), `period` and `exercise` {start, end}, `shares`, `percentage_bps`, `time`, `venue`. Absent fields are omitted. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours). AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", "inputSchema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { diff --git a/scripts/live-smoke.sh b/scripts/live-smoke.sh index 026911f..fd0e292 100755 --- a/scripts/live-smoke.sh +++ b/scripts/live-smoke.sh @@ -134,8 +134,12 @@ contract() { echo 'type == "array" and all(.[]; (.title | type == "string") and (.url | type == "string"))' ;; "stocks orderbook "*) echo '(.symbol | type == "string") and (.price | type == "number") and (.market_status | type == "string") and (.bids | type == "array") and (.offers | type == "array")' ;; - "stocks actions "*|"stocks calendar"*) + # The smoke symbol always has dividends on record; a quiet month can + # leave the calendar empty. + "stocks actions "*) echo 'type == "array" and length > 0 and all(.[]; (.symbol | type == "string") and (.kind | type == "string") and (.date | type == "string"))' ;; + "stocks calendar"*) + echo 'type == "array" and all(.[]; (.symbol | type == "string") and (.kind | type == "string") and (.date | type == "string"))' ;; "stocks broker "*) echo '(.symbol | type == "string") and (.buyers | length > 0) and (.sellers | length > 0) and all(.buyers[]; (.code | type == "string") and (.value | type == "number")) and (.total_value | type == "number")' ;; "stocks bandar "*) diff --git a/web/src/content/docs/cli/stocks.md b/web/src/content/docs/cli/stocks.md index 51c1523..d955873 100644 --- a/web/src/content/docs/cli/stocks.md +++ b/web/src/content/docs/cli/stocks.md @@ -62,7 +62,10 @@ exposes and tender offers (`--kind ipo` adds its IPO). `calendar` lists them across the market between `--from` and `--to` (at most 366 days), including what is announced ahead. An action's date is its cum date for dividends, bonuses, rights and splits: buy by then to be entitled. For the others it is -the event's first day. Dividends per share keep their decimals (`Rp 3.8`). +the event's first day. When Stockbit gives no cum date, the action sits on +its ex date, marked `(ex)` in the table, and JSON leaves `cum_date` out. +Dividends per share keep their decimals (`Rp 3.8`); one not paid in Rupiah +carries `currency` (e.g. `USD`). JSON's `kind` is the name `--kind` takes. Both need your Stockbit session and answer `AUTHERROR` without one. Stockbit serves one kind per request, 1 s apart, so a first call with every kind takes diff --git a/web/src/content/docs/mcp/tools.md b/web/src/content/docs/mcp/tools.md index a904389..863bbc6 100644 --- a/web/src/content/docs/mcp/tools.md +++ b/web/src/content/docs/mcp/tools.md @@ -65,7 +65,7 @@ Company data for one IDX ticker: profile, financial statements, earnings, analys ## `get_corporate_actions` -Corporate actions of one IDX stock from the user's own Stockbit session, newest first: `kind` (dividend, stock-dividend, bonus, rights, warrant, split, reverse-split, meeting, expose, ipo, tender), `date` (the cum date for dividends, bonuses, rights and splits, i.e. the last day to buy and be entitled; else the event's first day), `ex_date`, `record_date`, `pay_date`, and per kind `cash_per_share` (IDR, may have decimals), `ratio` {old, new} (1:5 split = 1 share becomes 5; 655:104 rights = 104 rights per 655 held), `factor` (price adjustment), `price` (rights, warrant exercise, tender or IPO price, IDR), `period` and `exercise` {start, end}, `shares`, `percentage_bps`, `time`, `venue`. Absent fields are omitted. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours). AUTHERROR means there is no session: call stockbit_status, then stockbit_login. +Corporate actions of one IDX stock from the user's own Stockbit session, newest first: `kind` (dividend, stock-dividend, bonus, rights, warrant, split, reverse-split, meeting, expose, ipo, tender), `date` (the cum date for dividends, bonuses, rights and splits, i.e. the last day to buy and be entitled, or the ex date when `cum_date` is absent; else the event's first day), `ex_date`, `record_date`, `pay_date`, and per kind `cash_per_share` (IDR, may have decimals; in `currency`, an ISO code, when that is present), `ratio` {old, new} (1:5 split = 1 share becomes 5; 655:104 rights = 104 rights per 655 held), `factor` (price adjustment), `price` (rights, warrant exercise, tender or IPO price, IDR), `period` and `exercise` {start, end}, `shares`, `percentage_bps`, `time`, `venue`. Absent fields are omitted. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours). AUTHERROR means there is no session: call stockbit_status, then stockbit_login. | Input | Type | Required | Description | | --- | --- | --- | --- | From 0c7320a343c4d7cbecce73e91870190759e5a0f3 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 17:39:10 +0700 Subject: [PATCH 08/16] fix(movements): read a query's pages as one answer and keep a partial one - Each page was cached on its own, so a multi-page answer could join pages read at different times from a feed that gains rows at the top, repeating some rows and missing others. A query's pages are now read together and cached as one entry. - A failed later page threw away the pages already read. They are now returned with incomplete saying why, and not cached. - The library did not cap pages at MAX_PAGES itself; it clamps now. - The hint said to raise --pages even at 10; at 10 it says to narrow the dates. -o jsonl, which streams rows only, gives the hint on stderr. - A duplicate match arm in the CLI was dead; it is gone. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- crates/idx-cli/src/cli/ownership.rs | 4 +- crates/idx-cli/src/output/mod.rs | 13 ++- crates/idx-cli/src/output/table.rs | 22 ++++- crates/idx-cli/tests/cli.rs | 27 ++++++ crates/idx-core/src/api/mock.rs | 4 + crates/idx-core/src/movements/mod.rs | 127 ++++++++++++++++--------- crates/idx-core/src/movements/types.rs | 5 + crates/idx-mcp/src/server.rs | 3 +- crates/idx-mcp/tests/golden/tools.json | 2 +- web/src/content/docs/cli/ownership.md | 4 +- web/src/content/docs/mcp/tools.md | 2 +- 11 files changed, 159 insertions(+), 54 deletions(-) diff --git a/crates/idx-cli/src/cli/ownership.rs b/crates/idx-cli/src/cli/ownership.rs index cd2850f..63cef02 100644 --- a/crates/idx-cli/src/cli/ownership.rs +++ b/crates/idx-cli/src/cli/ownership.rs @@ -252,9 +252,6 @@ pub fn handle( offline: bool, no_cache: bool, ) -> Result<(), IdxError> { - if let OwnershipCommand::Movements(args) = cmd { - return handle_movements(args, config, CachePolicy::from_flags(offline, no_cache)?); - } let investor = Investor::new(&config.core); let inv = &investor; match cmd { @@ -752,6 +749,7 @@ fn handle_movements( crate::output::render_shareholder_movements( symbol.as_deref(), &list.data, + query.pages, &config.output, config.no_color, ) diff --git a/crates/idx-cli/src/output/mod.rs b/crates/idx-cli/src/output/mod.rs index 633acb2..62506f4 100644 --- a/crates/idx-cli/src/output/mod.rs +++ b/crates/idx-cli/src/output/mod.rs @@ -129,16 +129,25 @@ pub fn render_corporate_calendar( /// JSON is `{movements, more}` (`more`: rows remain past the pages read); /// JSONL is one movement per line. +/// `pages` is how many pages the query asked for, for the hint when more +/// rows exist. JSONL streams the rows only, so the hint goes to stderr. pub fn render_shareholder_movements( symbol: Option<&str>, list: &MovementList, + pages: u32, format: &OutputFormat, no_color: bool, ) -> Result<(), IdxError> { match format { - OutputFormat::Table => table::print_shareholder_movements(symbol, list, no_color), + OutputFormat::Table => table::print_shareholder_movements(symbol, list, pages, no_color), OutputFormat::Json => json::print_json(list), - OutputFormat::Jsonl => json::print_json(&list.movements), + OutputFormat::Jsonl => { + json::print_json(&list.movements)?; + if list.more { + idx_core::runtime::info(table::more_movements_hint(pages)); + } + Ok(()) + } } } diff --git a/crates/idx-cli/src/output/table.rs b/crates/idx-cli/src/output/table.rs index d3afec8..216fce0 100644 --- a/crates/idx-cli/src/output/table.rs +++ b/crates/idx-cli/src/output/table.rs @@ -1920,9 +1920,22 @@ const MOVEMENT_NOTE: &str = "IDX rows are insider disclosures (directors, commis other insiders); KSEI rows are changes of holders at 5% and above. ~ marks Stockbit's estimated \ price. Rows appear days after the change."; +/// What to do when rows remain past the pages read. +pub fn more_movements_hint(pages: u32) -> String { + if pages >= idx_core::movements::types::MAX_PAGES { + "More rows exist: narrow --from/--to (10 pages is the most one query reads).".to_string() + } else { + format!( + "More rows exist: raise --pages (up to {}) or narrow --from/--to.", + idx_core::movements::types::MAX_PAGES + ) + } +} + pub fn print_shareholder_movements( symbol: Option<&str>, list: &MovementList, + pages: u32, no_color: bool, ) -> Result<(), IdxError> { let title = match symbol { @@ -1987,8 +2000,13 @@ pub fn print_shareholder_movements( println!("{table}"); println!("{MOVEMENT_NOTE}"); } - if list.more { - println!("More rows exist: raise --pages (up to 10) or narrow --from/--to."); + if let Some(reason) = &list.incomplete { + println!( + "Reading stopped early ({}); these are the rows read before it.", + terminal_safe(reason) + ); + } else if list.more { + println!("{}", more_movements_hint(pages)); } println!("{STOCKBIT_SESSION_NOTE}"); Ok(()) diff --git a/crates/idx-cli/tests/cli.rs b/crates/idx-cli/tests/cli.rs index 490e254..b1e5cbe 100644 --- a/crates/idx-cli/tests/cli.rs +++ b/crates/idx-cli/tests/cli.rs @@ -2239,6 +2239,33 @@ fn auto_history_falls_back_to_yahoo_when_the_session_is_refused() { let _ = fs::remove_dir_all(root); } +/// A page after the first that fails keeps the rows read before it, says +/// why, and is not cached; a query's pages are cached as one answer. +#[test] +fn movements_keep_the_pages_read_when_a_later_one_fails() { + let root = test_env_dir("movements-partial"); + let run = |fail_page: Option<&str>| { + let mut cmd = mock_bin_with_root(&root); + cmd.env("IDX_STOCKBIT_REFRESH_TOKEN", FAKE_STOCKBIT_TOKEN) + .args(["-o", "json", "ownership", "movements", "--pages", "2"]); + if let Some(page) = fail_page { + cmd.env("IDX_MOCK_MOVEMENTS_FAIL_PAGE", page); + } + run_success_json(&mut cmd) + }; + let partial = run(Some("2")); + assert_eq!(partial["movements"].as_array().unwrap().len(), 8); + assert_eq!(partial["more"], true); + assert!(partial["incomplete"].is_string(), "{partial}"); + // Not cached: the next run reads both pages. + let full = run(None); + assert_eq!(full["movements"].as_array().unwrap().len(), 14); + assert!(full.get("incomplete").is_none()); + // Cached as one answer: a failing page 2 now changes nothing. + assert_eq!(run(Some("2")), full); + let _ = fs::remove_dir_all(root); +} + /// A test session, signed by nobody, that expires in 2100. const FAKE_STOCKBIT_TOKEN: &str = "eyJhbGciOiJub25lIn0.eyJleHAiOiA0MTAyNDQ0ODAwLCAibm90ZSI6ICJ0ZXN0IHRva2VuLCBzaWduZWQgYnkgbm9ib2R5In0.c2ln"; diff --git a/crates/idx-core/src/api/mock.rs b/crates/idx-core/src/api/mock.rs index 3e13721..9dbf60a 100644 --- a/crates/idx-core/src/api/mock.rs +++ b/crates/idx-core/src/api/mock.rs @@ -271,6 +271,10 @@ impl ShareholderMovementProvider for MockStockbitProvider { page: u32, ) -> Result { let subject = query.symbol.as_deref().unwrap_or("shareholder movements"); + // `IDX_MOCK_MOVEMENTS_FAIL_PAGE=N` rate-limits page N alone. + if std::env::var("IDX_MOCK_MOVEMENTS_FAIL_PAGE").ok() == Some(page.to_string()) { + return Err(IdxError::RateLimited); + } let mut name = "majorholder".to_string(); if let Some(symbol) = &query.symbol { name.push('_'); diff --git a/crates/idx-core/src/movements/mod.rs b/crates/idx-core/src/movements/mod.rs index f35387e..293d0a7 100644 --- a/crates/idx-core/src/movements/mod.rs +++ b/crates/idx-core/src/movements/mod.rs @@ -1,7 +1,9 @@ //! Shareholder movements from the user's Stockbit session: reported changes //! in insiders' and major holders' stakes (IDX insider disclosures and KSEI's //! 5% holder changes), one stock's or the market's, newest first. Each page -//! is 50 rows and one request (paced 1 s apart), cached for an hour. +//! is 50 rows and one request (paced 1 s apart). A query's pages are read +//! together and cached together for an hour, so they come from one moment +//! of a feed that gains rows at the top. //! //! These are the reports as filed. Whether they predict anything is not //! claimed here: share plans read as a cluster of buys at one price, and a @@ -9,12 +11,15 @@ pub mod types; +use std::cell::RefCell; + use chrono::Utc; -use crate::api::{shareholder_movement_provider, stockbit}; +use crate::api::{ShareholderMovementProvider, shareholder_movement_provider, stockbit}; use crate::client::{CachePolicy, CacheSpec, Fetched, Idx, cached_fetch}; use crate::error::IdxError; -use types::{MovementList, MovementQuery}; +use crate::runtime; +use types::{MAX_PAGES, MovementList, MovementQuery}; /// The feed gains rows through the day; an hour keeps a session's repeated /// queries cheap without hiding a day's filings for long. @@ -26,15 +31,19 @@ pub struct Movements<'a> { } impl Movements<'_> { - /// Up to `query.pages` pages of the feed, newest first; `more` says - /// whether rows remain past them. The result is as old as its oldest page - /// and stale if any page is. + /// Up to `query.pages` pages of the feed (at most `MAX_PAGES`), newest + /// first; `more` says whether rows remain past them. + /// + /// When a page after the first fails and no cached answer is at hand, + /// the rows read before it are returned with `incomplete` saying why, + /// and are not cached. pub fn list( &self, query: &MovementQuery, policy: CachePolicy, ) -> Result, IdxError> { let mut query = query.clone(); + query.pages = query.pages.clamp(1, MAX_PAGES); if let Some(symbol) = &query.symbol { let (resolved, _) = self.idx.idx_code(symbol, "shareholder movements")?; query.symbol = Some(resolved); @@ -44,50 +53,80 @@ impl Movements<'_> { .symbol .clone() .unwrap_or_else(|| "shareholder movements".to_string()); - let mut list = Fetched { - data: MovementList::default(), - source: stockbit::SOURCE, - fetched_at: Utc::now(), - stale: false, - }; - for page in 1..=query.pages.max(1) { - let key = cache_key(&query, page); - let part = cached_fetch( - &self.idx.cache, - CacheSpec { - bucket: BUCKET, - key: &key, - ttl_secs: TTL_SECS, - subject: &subject, + let key = cache_key(&query); + let partial = RefCell::new(None); + let result = cached_fetch( + &self.idx.cache, + CacheSpec { + bucket: BUCKET, + key: &key, + ttl_secs: TTL_SECS, + subject: &subject, + source: stockbit::SOURCE, + }, + policy, + || read_pages(provider.as_ref(), &query, &partial), + Ok, + ); + match (result, partial.into_inner()) { + (Err(err), Some(mut list)) => { + runtime::warn(format!( + "{err}; showing the {} rows read before it", + list.movements.len() + )); + list.incomplete = Some(err.to_string()); + Ok(Fetched { + data: list, source: stockbit::SOURCE, - }, - policy, - || provider.shareholder_movements(&query, page), - Ok, - )?; - list.fetched_at = list.fetched_at.min(part.fetched_at); - list.stale |= part.stale; - list.data.movements.extend(part.data.movements); - list.data.more = part.data.more; - if !part.data.more { - break; + fetched_at: Utc::now(), + stale: false, + }) } + (result, _) => result, } - Ok(list) } } -/// Every filter and the page, so no two queries share an entry. -fn cache_key(query: &MovementQuery, page: u32) -> String { +/// Reads the query's pages in turn. A failure after the first page leaves +/// the rows read so far in `partial` and fails, so they are not cached. +fn read_pages( + provider: &dyn ShareholderMovementProvider, + query: &MovementQuery, + partial: &RefCell>, +) -> Result { + let mut list = MovementList::default(); + for page in 1..=query.pages { + match provider.shareholder_movements(query, page) { + Ok(part) => { + list.movements.extend(part.movements); + list.more = part.more; + if !part.more { + break; + } + } + Err(err) if page > 1 => { + list.more = true; + *partial.borrow_mut() = Some(list); + return Err(err); + } + Err(err) => return Err(err), + } + } + Ok(list) +} + +/// Every filter and the page count, so no two queries share an entry. +fn cache_key(query: &MovementQuery) -> String { let opt = |value: Option| value.unwrap_or_else(|| "-".to_string()); format!( - "{}:{}:{}:{}:{}:{}:p{page}", + "{}:{}:{}:{}:{}:{}:{}p", query.symbol.as_deref().unwrap_or("market"), opt(query.from.map(|d| d.to_string())), opt(query.to.map(|d| d.to_string())), query.holder_id.as_deref().unwrap_or("-"), query.action.map(|a| a.as_str()).unwrap_or("-"), query.source.map(|s| s.as_str()).unwrap_or("-"), + query.pages, ) } @@ -99,25 +138,27 @@ mod tests { #[test] fn cache_keys_differ_by_every_filter() { let base = MovementQuery::from_args(None, None, None, None, 1).unwrap(); - let mut keys = vec![cache_key(&base, 1), cache_key(&base, 2)]; + let mut two = base.clone(); + two.pages = 2; + let mut keys = vec![cache_key(&base), cache_key(&two)]; let mut q = base.clone(); q.symbol = Some("BBCA.JK".to_string()); - keys.push(cache_key(&q, 1)); + keys.push(cache_key(&q)); let mut q = base.clone(); q.from = chrono::NaiveDate::from_ymd_opt(2026, 10, 1); - keys.push(cache_key(&q, 1)); + keys.push(cache_key(&q)); let mut q = base.clone(); q.to = chrono::NaiveDate::from_ymd_opt(2026, 10, 1); - keys.push(cache_key(&q, 1)); + keys.push(cache_key(&q)); let mut q = base.clone(); q.holder_id = Some("14074".to_string()); - keys.push(cache_key(&q, 1)); + keys.push(cache_key(&q)); let mut q = base.clone(); q.action = Some(ActionFilter::Sell); - keys.push(cache_key(&q, 1)); + keys.push(cache_key(&q)); let mut q = base; q.source = Some(MovementSource::Ksei); - keys.push(cache_key(&q, 1)); + keys.push(cache_key(&q)); let unique: std::collections::HashSet<_> = keys.iter().collect(); assert_eq!(unique.len(), keys.len(), "{keys:?}"); } diff --git a/crates/idx-core/src/movements/types.rs b/crates/idx-core/src/movements/types.rs index 1d031ce..6c974b4 100644 --- a/crates/idx-core/src/movements/types.rs +++ b/crates/idx-core/src/movements/types.rs @@ -288,6 +288,11 @@ pub struct MovementList { /// More rows exist past the pages read (raise `--pages`, or narrow the /// dates). pub more: bool, + /// Why reading stopped before the pages asked for: a later page failed, + /// and `movements` holds the rows read before it. Absent when every page + /// asked for was read. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub incomplete: Option, } #[cfg(test)] diff --git a/crates/idx-mcp/src/server.rs b/crates/idx-mcp/src/server.rs index d78708f..7e74026 100644 --- a/crates/idx-mcp/src/server.rs +++ b/crates/idx-mcp/src/server.rs @@ -411,7 +411,8 @@ commissioners and other insiders, any size, with the trade price) and KSEI chang at 5% and above (price estimated: `price_estimated`). One stock's, or the market's without \ `symbol`. Shares are exact and signed (`shares_change` < 0 is a sale); percentages are basis \ points as Stockbit rounds them, so a small insider can read 0. `more` is true when rows remain \ -past `pages`. These are filings, not signals: many insiders buying at one price on one day is \ +past `pages`; `incomplete`, when present, says a later page failed and the rows are those read \ +before it (retry later for the rest). These are filings, not signals: many insiders buying at one price on one day is \ usually a share plan, and rows appear days after the change. AUTHERROR means there is no \ session: call stockbit_status, then stockbit_login." )] diff --git a/crates/idx-mcp/tests/golden/tools.json b/crates/idx-mcp/tests/golden/tools.json index aec2f76..1342bfa 100644 --- a/crates/idx-mcp/tests/golden/tools.json +++ b/crates/idx-mcp/tests/golden/tools.json @@ -556,7 +556,7 @@ "name": "get_quotes" }, { - "description": "Reported changes in insiders' and major holders' stakes in IDX stocks, from the user's own Stockbit session, newest first: IDX insider disclosures (directors, commissioners and other insiders, any size, with the trade price) and KSEI changes of holders at 5% and above (price estimated: `price_estimated`). One stock's, or the market's without `symbol`. Shares are exact and signed (`shares_change` < 0 is a sale); percentages are basis points as Stockbit rounds them, so a small insider can read 0. `more` is true when rows remain past `pages`. These are filings, not signals: many insiders buying at one price on one day is usually a share plan, and rows appear days after the change. AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", + "description": "Reported changes in insiders' and major holders' stakes in IDX stocks, from the user's own Stockbit session, newest first: IDX insider disclosures (directors, commissioners and other insiders, any size, with the trade price) and KSEI changes of holders at 5% and above (price estimated: `price_estimated`). One stock's, or the market's without `symbol`. Shares are exact and signed (`shares_change` < 0 is a sale); percentages are basis points as Stockbit rounds them, so a small insider can read 0. `more` is true when rows remain past `pages`; `incomplete`, when present, says a later page failed and the rows are those read before it (retry later for the rest). These are filings, not signals: many insiders buying at one price on one day is usually a share plan, and rows appear days after the change. AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", "inputSchema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { diff --git a/web/src/content/docs/cli/ownership.md b/web/src/content/docs/cli/ownership.md index f22f76c..7258b2e 100644 --- a/web/src/content/docs/cli/ownership.md +++ b/web/src/content/docs/cli/ownership.md @@ -60,7 +60,9 @@ small holding reads `<0.01%`. These are filings, not signals. Many insiders buying at one price on one day is usually a share plan, transfers are not trades, and a row appears days after the change. Each page is 50 rows and one request to Stockbit (`--pages` -up to 10); answers are cached for an hour. +up to 10); a query's pages are read and cached together, for an hour. JSON's +`more` says rows remain past them. If a later page fails, you get the rows +read before it, with `incomplete` saying why, and nothing is cached. ## Import reports yourself diff --git a/web/src/content/docs/mcp/tools.md b/web/src/content/docs/mcp/tools.md index ecca1a1..21118de 100644 --- a/web/src/content/docs/mcp/tools.md +++ b/web/src/content/docs/mcp/tools.md @@ -152,7 +152,7 @@ Latest quotes (price, change, volume, 52-week range, market cap) for one or more ## `get_shareholder_movements` -Reported changes in insiders' and major holders' stakes in IDX stocks, from the user's own Stockbit session, newest first: IDX insider disclosures (directors, commissioners and other insiders, any size, with the trade price) and KSEI changes of holders at 5% and above (price estimated: `price_estimated`). One stock's, or the market's without `symbol`. Shares are exact and signed (`shares_change` < 0 is a sale); percentages are basis points as Stockbit rounds them, so a small insider can read 0. `more` is true when rows remain past `pages`. These are filings, not signals: many insiders buying at one price on one day is usually a share plan, and rows appear days after the change. AUTHERROR means there is no session: call stockbit_status, then stockbit_login. +Reported changes in insiders' and major holders' stakes in IDX stocks, from the user's own Stockbit session, newest first: IDX insider disclosures (directors, commissioners and other insiders, any size, with the trade price) and KSEI changes of holders at 5% and above (price estimated: `price_estimated`). One stock's, or the market's without `symbol`. Shares are exact and signed (`shares_change` < 0 is a sale); percentages are basis points as Stockbit rounds them, so a small insider can read 0. `more` is true when rows remain past `pages`; `incomplete`, when present, says a later page failed and the rows are those read before it (retry later for the rest). These are filings, not signals: many insiders buying at one price on one day is usually a share plan, and rows appear days after the change. AUTHERROR means there is no session: call stockbit_status, then stockbit_login. | Input | Type | Required | Description | | --- | --- | --- | --- | From a0bf478ec29c3569d6de086746b300d110769529 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 19:23:48 +0700 Subject: [PATCH 09/16] fix(actions): take the old kind names as input too JSON `kind` now uses the `--kind` names, so an agent that copies a kind from an answer cached or read before that change (`public_expose`, `tender_offer`) would get INVALIDINPUT. Both are accepted, as hidden `--kind` aliases and by the MCP tools. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- crates/idx-core/src/corporate/types.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/idx-core/src/corporate/types.rs b/crates/idx-core/src/corporate/types.rs index b6086c8..4c67369 100644 --- a/crates/idx-core/src/corporate/types.rs +++ b/crates/idx-core/src/corporate/types.rs @@ -28,11 +28,17 @@ pub enum ActionKind { /// Shareholders' meeting (RUPS). Meeting, /// Public expose. - #[cfg_attr(feature = "clap", value(name = "expose"))] + #[cfg_attr( + feature = "clap", + value(name = "expose", alias = "public-expose", alias = "public_expose") + )] #[serde(rename = "expose", alias = "public_expose")] PublicExpose, Ipo, - #[cfg_attr(feature = "clap", value(name = "tender"))] + #[cfg_attr( + feature = "clap", + value(name = "tender", alias = "tender-offer", alias = "tender_offer") + )] #[serde(rename = "tender", alias = "tender_offer")] TenderOffer, } @@ -103,6 +109,13 @@ impl std::str::FromStr for ActionKind { fn from_str(value: &str) -> Result { let wanted = value.trim().to_ascii_lowercase().replace('_', "-"); + // The names JSON carried before they matched `--kind`, which an + // agent may pass back from an earlier answer. + let wanted = match wanted.as_str() { + "public-expose" => "expose", + "tender-offer" => "tender", + other => other, + }; Self::ALL .into_iter() .find(|kind| kind.as_str() == wanted) @@ -333,5 +346,11 @@ mod tests { // Entries cached before the names changed still read. let old: ActionKind = serde_json::from_str("\"public_expose\"").unwrap(); assert_eq!(old, ActionKind::PublicExpose); + // And as input, so a kind copied from an older answer works. + assert_eq!("public_expose".parse::().unwrap(), old); + assert_eq!( + "tender_offer".parse::().unwrap(), + ActionKind::TenderOffer + ); } } From 9b46161566739d37f09bbf16c7ae18c824376f93 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 19:26:10 +0700 Subject: [PATCH 10/16] fix(mcp): hand a call's warnings to the agent idx-core reports what it works around (history falling back to yahoo when Stockbit refuses the session, a stale cache served after a failed fetch, a movements query cut short) as warnings on stderr. An agent never reads idx-mcp's stderr, so it saw `source: "yahoo"` or `stale: true` with no reason. - Each tool call collects its warnings with runtime::on_warning and returns them as `warnings` on the answer or the error, when there are any. - The stale-cache warning names the failure behind it. - The mock's session API 403 is the real session API's block message; the public page's block names IDX_PROVIDER=msn as well as `--provider msn`. Goldens: error-intraday-blocked (json, table) carry the reworded block hint. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- .../golden/error-intraday-blocked.json.golden | 2 +- .../error-intraday-blocked.table.golden | 2 +- crates/idx-core/src/api/mock.rs | 4 ++ crates/idx-core/src/api/stockbit/exodus.rs | 16 +++-- crates/idx-core/src/api/stockbit/parse.rs | 4 +- crates/idx-core/src/client.rs | 2 +- crates/idx-mcp/src/server.rs | 50 +++++++++++--- crates/idx-mcp/tests/mcp.rs | 66 +++++++++++++++++++ docs/DESIGN.md | 4 +- web/src/content/docs/mcp/index.md | 15 +++++ 10 files changed, 146 insertions(+), 19 deletions(-) diff --git a/crates/idx-cli/tests/golden/error-intraday-blocked.json.golden b/crates/idx-cli/tests/golden/error-intraday-blocked.json.golden index 402cc2b..7554cf0 100644 --- a/crates/idx-cli/tests/golden/error-intraday-blocked.json.golden +++ b/crates/idx-cli/tests/golden/error-intraday-blocked.json.golden @@ -1,4 +1,4 @@ exit: 4 --- stdout --- stderr -{"code":"UPSTREAMBLOCKED","error":true,"message":"upstream blocked: stockbit.com refused this client (HTTP 403 from its CDN); idx does not retry a block. Try again later or from another network; `--provider msn` serves quotes without Stockbit"} +{"code":"UPSTREAMBLOCKED","error":true,"message":"upstream blocked: stockbit.com refused this client (HTTP 403 from its CDN); idx does not retry a block. Try again later or from another network; the msn provider (`--provider msn`, or IDX_PROVIDER=msn for idx-mcp) serves quotes without Stockbit"} diff --git a/crates/idx-cli/tests/golden/error-intraday-blocked.table.golden b/crates/idx-cli/tests/golden/error-intraday-blocked.table.golden index fd793c7..d7b4759 100644 --- a/crates/idx-cli/tests/golden/error-intraday-blocked.table.golden +++ b/crates/idx-cli/tests/golden/error-intraday-blocked.table.golden @@ -1,4 +1,4 @@ exit: 4 --- stdout --- stderr -Error: upstream blocked: stockbit.com refused this client (HTTP 403 from its CDN); idx does not retry a block. Try again later or from another network; `--provider msn` serves quotes without Stockbit +Error: upstream blocked: stockbit.com refused this client (HTTP 403 from its CDN); idx does not retry a block. Try again later or from another network; the msn provider (`--provider msn`, or IDX_PROVIDER=msn for idx-mcp) serves quotes without Stockbit diff --git a/crates/idx-core/src/api/mock.rs b/crates/idx-core/src/api/mock.rs index 9dbf60a..8477e7e 100644 --- a/crates/idx-core/src/api/mock.rs +++ b/crates/idx-core/src/api/mock.rs @@ -187,6 +187,10 @@ impl MockStockbitProvider { "Stockbit rejected the session; run `idx stockbit login` again".to_string(), )); } + // The session API's own block, as `exodus::fetch` reports it. + if std::env::var("IDX_MOCK_STOCKBIT_STATUS").as_deref() == Ok("403") { + return Err(stockbit::exodus::blocked()); + } if let Some(err) = self.failure(symbol) { return Err(err); } diff --git a/crates/idx-core/src/api/stockbit/exodus.rs b/crates/idx-core/src/api/stockbit/exodus.rs index d594ffe..0569609 100644 --- a/crates/idx-core/src/api/stockbit/exodus.rs +++ b/crates/idx-core/src/api/stockbit/exodus.rs @@ -257,11 +257,7 @@ fn classify(reply: Reply, subject: &str) -> Result { Err(IdxError::SymbolNotFound(subject.to_string())) } 429 => Err(IdxError::RateLimited), - 403 => Err(IdxError::UpstreamBlocked( - "exodus.stockbit.com refused this client (HTTP 403 from its CDN); idx does not \ - retry a block. Try again later or from another network" - .to_string(), - )), + 403 => Err(blocked()), status => Err(IdxError::Http(format!( "stockbit api: HTTP {status}{}", message(&reply.body) @@ -497,6 +493,16 @@ fn trim_to_period(mut bars: Vec, period: &Period) -> Vec { } } +/// A 403 from the CDN in front of the session API: a block, not a refused +/// session, so nothing is retried. +pub(crate) fn blocked() -> IdxError { + IdxError::UpstreamBlocked( + "exodus.stockbit.com refused this client (HTTP 403 from its CDN); idx does not \ + retry a block. Try again later or from another network" + .to_string(), + ) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/idx-core/src/api/stockbit/parse.rs b/crates/idx-core/src/api/stockbit/parse.rs index 9ecbd5c..17a0b90 100644 --- a/crates/idx-core/src/api/stockbit/parse.rs +++ b/crates/idx-core/src/api/stockbit/parse.rs @@ -124,8 +124,8 @@ pub fn status_error(status: u16, resolved: &str) -> IdxError { match status { 403 => IdxError::UpstreamBlocked( "stockbit.com refused this client (HTTP 403 from its CDN); idx does not retry a \ - block. Try again later or from another network; `--provider msn` serves quotes \ - without Stockbit" + block. Try again later or from another network; the msn provider (`--provider msn`, \ + or IDX_PROVIDER=msn for idx-mcp) serves quotes without Stockbit" .to_string(), ), 404 => IdxError::SymbolNotFound(resolved.to_string()), diff --git a/crates/idx-core/src/client.rs b/crates/idx-core/src/client.rs index 57e6333..9fe1940 100644 --- a/crates/idx-core/src/client.rs +++ b/crates/idx-core/src/client.rs @@ -199,7 +199,7 @@ where Err(err) => { if use_cache && let Some(stale) = cache.any::(spec.bucket, spec.key)? { runtime::warn(format!( - "network failed, serving stale cache for {}", + "network failed ({err}), serving stale cache for {}", spec.subject )); return Ok(hit(stale, true)); diff --git a/crates/idx-mcp/src/server.rs b/crates/idx-mcp/src/server.rs index 37b52a5..8d2722e 100644 --- a/crates/idx-mcp/src/server.rs +++ b/crates/idx-mcp/src/server.rs @@ -2,7 +2,9 @@ //! `Idx` (as one CLI invocation would), so tools share the CLI's on-disk //! cache and ownership database. +use std::cell::RefCell; use std::collections::BTreeMap; +use std::rc::Rc; use idx_core::analysis::BandarQuery; use idx_core::analysis::bandar::{BandarReport, DEFAULT_TOP}; @@ -18,7 +20,7 @@ use idx_core::investor::{HolderSource, Investor}; use idx_core::market::{ScreenFilter, ScreenQuery, ScreenRegion}; use idx_core::movements::types::MovementQuery; use idx_core::ownership::types::ChangeRow; -use idx_core::{CachePolicy, Fetched, Idx}; +use idx_core::{CachePolicy, Fetched, Idx, runtime}; use rmcp::handler::server::router::tool::ToolRouter; use rmcp::handler::server::wrapper::Parameters; use rmcp::model::{CallToolResult, Implementation, ServerCapabilities, ServerConfig}; @@ -57,7 +59,9 @@ static CALL_SLOTS: Semaphore = Semaphore::const_new(4); const INSTRUCTIONS: &str = "Indonesian stock market (IDX) data. Market and financial \ tools fetch live data (cached on disk) and wrap it as {data, source, fetched_at, stale}; \ -stale=true means an expired cache entry was served. Ownership tools read a local KSEI \ +stale=true means an expired cache entry was served. An answer (or error) may carry \ +`warnings`: what idx worked around, such as a refused Stockbit session that made history \ +fall back to yahoo, or the failure behind a stale entry; pass on any that need the user. Ownership tools read a local KSEI \ database of holders above 1%: call ownership_status first to see which release dates \ exist. Percentages ending in _bps are basis points (5494 = 54.94%). Errors carry a \ stable code, e.g. SYMBOLNOTFOUND, RATELIMITED, INVALIDINPUT."; @@ -745,13 +749,43 @@ where .acquire() .await .map_err(|err| ErrorData::internal_error(err.to_string(), None))?; - let result = tokio::task::spawn_blocking(move || f().and_then(to_json)) - .await - .map_err(|err| ErrorData::internal_error(err.to_string(), None))?; - Ok(match result { - Ok(value) => CallToolResult::structured(value), - Err(err) => CallToolResult::structured_error(Value::Object(error_body(&err))), + let (result, warnings) = tokio::task::spawn_blocking(move || { + // idx-core warns on stderr, which the agent never sees; what this + // call warns about (a fallback, a stale cache, a partial answer) + // goes into its answer instead. The call runs on this thread. + let warnings = Rc::new(RefCell::new(Vec::::new())); + let sink = { + let warnings = warnings.clone(); + runtime::on_warning(move |message| { + let mut warnings = warnings.borrow_mut(); + if !warnings.iter().any(|seen| seen == message) { + warnings.push(message.to_string()); + } + }) + }; + let result = f().and_then(to_json); + drop(sink); + (result, warnings.take()) }) + .await + .map_err(|err| ErrorData::internal_error(err.to_string(), None))?; + Ok(match result { + Ok(value) => CallToolResult::structured(with_warnings(value, warnings)), + Err(err) => CallToolResult::structured_error(with_warnings( + Value::Object(error_body(&err)), + warnings, + )), + }) +} + +/// Adds `warnings` to an answer when the call had any. +fn with_warnings(mut value: Value, warnings: Vec) -> Value { + if !warnings.is_empty() + && let Some(object) = value.as_object_mut() + { + object.insert("warnings".into(), json!(warnings)); + } + value } /// Per-symbol failures as error bodies carrying their symbol. diff --git a/crates/idx-mcp/tests/mcp.rs b/crates/idx-mcp/tests/mcp.rs index b705104..fa27569 100644 --- a/crates/idx-mcp/tests/mcp.rs +++ b/crates/idx-mcp/tests/mcp.rs @@ -374,6 +374,72 @@ fn stockbit_provider_quotes_carry_market_status_and_blocks_surface_once() { ); } +/// What idx works around reaches the agent as `warnings`, since it never +/// sees idx-mcp's stderr: a refused session that made history fall back to +/// yahoo, and a movements query cut short. A clean answer has none. +#[test] +fn workarounds_reach_the_agent_as_warnings() { + let mut client = Client::start_with_env( + &[], + false, + &[ + TEST_SESSION, + ("IDX_PROVIDER", "stockbit"), + ("IDX_MOCK_STOCKBIT_STATUS", "401"), + ], + ); + let history = client.ok( + "get_price_history", + json!({"symbol": "BBCA", "period": "1mo"}), + ); + assert_eq!(history["source"], "yahoo"); + let warnings = history["warnings"].as_array().expect("warnings"); + assert_eq!(warnings.len(), 1, "{warnings:?}"); + assert!( + warnings[0] + .as_str() + .unwrap() + .contains("Stockbit rejected the session") + && warnings[0] + .as_str() + .unwrap() + .contains("falls back to yahoo"), + "{warnings:?}" + ); + let analysis = client.ok("analyze_stock", json!({"symbol": "BBCA"})); + assert!( + analysis["warnings"][0] + .as_str() + .unwrap() + .contains("falls back to yahoo") + ); + // The next call starts with none of the last one's warnings. + let (is_error, body) = client.call("get_orderbook", json!({"symbol": "BBCA"})); + assert!(is_error && body["code"] == "AUTHERROR", "{body}"); + assert!(body.get("warnings").is_none(), "{body}"); + + let mut client = Client::start_with_env( + &[], + false, + &[TEST_SESSION, ("IDX_MOCK_MOVEMENTS_FAIL_PAGE", "2")], + ); + let partial = client.ok( + "get_shareholder_movements", + json!({"symbol": "BBCA", "pages": 3}), + ); + assert_eq!(partial["data"]["incomplete"], "provider rate limited"); + assert!( + partial["warnings"][0] + .as_str() + .unwrap() + .contains("showing the 8 rows read before it") + ); + + let mut client = Client::start_with_env(&[], false, &[TEST_SESSION]); + let clean = client.ok("get_shareholder_movements", json!({"symbol": "BBCA"})); + assert!(clean.get("warnings").is_none(), "{clean}"); +} + /// The sign-in tool answers at once. With no browser to open (the mock /// provider never starts one), auto falls back to the page and says why; the /// page takes the cookie the way the browser would, and stockbit_status diff --git a/docs/DESIGN.md b/docs/DESIGN.md index f9e8b20..ba75a77 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -93,7 +93,9 @@ Key decisions: - **`Fetched` envelope** for live data: `{ data, source, fetched_at, stale }`, so agents and API clients can see freshness. idx-core still emits the stale-cache warnings through `runtime` (which `set_quiet` silences) so CLI - stderr stays identical. + stderr stays identical. idx-mcp also catches a call's warnings with + `runtime::on_warning` (the call runs on one blocking thread) and returns + them as `warnings`, since an agent never reads the server's stderr. - **`CachePolicy`**: `Default | Offline | Refresh` replaces the `--offline` / `--no-cache` flag handling now spread through `cli/stocks.rs`. - **Explicit configuration.** `CoreConfig::load()` is the one place idx-core reads diff --git a/web/src/content/docs/mcp/index.md b/web/src/content/docs/mcp/index.md index d45736d..940e93a 100644 --- a/web/src/content/docs/mcp/index.md +++ b/web/src/content/docs/mcp/index.md @@ -33,6 +33,21 @@ Tools that fetch live data return: failed. Ownership tools return their data directly, from the local database. +What `idx` prints as a warning in a terminal comes back in `warnings`, on an +answer or an error, when there was any. For example, history that fell back to +Yahoo because Stockbit refused your session says so, and a stale answer names +the failure behind it: + +```json +{ + "data": [{ "date": "2026-11-03", "close": 9875, "...": "..." }], + "source": "yahoo", + "fetched_at": "2026-11-04T03:20:11Z", + "stale": false, + "warnings": ["Stockbit rejected the session; run `idx stockbit login` again; history falls back to yahoo meanwhile"] +} +``` + Errors come back as a tool result with `isError` set and the CLI's error body, so the agent can decide whether to retry: From 884c6459e455842a188dd6c9e59d2fe78a208d20 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 20:44:07 +0700 Subject: [PATCH 11/16] fix(actions): keep small foreign dividends, allow only read paths, show open offers From Pullfrog's review of #78: - A dividend in another currency keeps 6 decimals (USD 0.0012 was rounded to 0.0 in JSON and "USD 0" in the table); rupiah stays to the sen. - `--kind stock_dividend` and `--kind reverse_split` work on the CLI too, as they already did over MCP. - The session client GETs only the prefixes in READ_PATHS, as docs/STOCKBIT.md's rule 1 already said: any other path (orders, PIN, withdrawals) fails before a request or token refresh leaves the process. - `stocks calendar` and get_corporate_calendar also list rights trading, tender offers and IPO offers still open in the range, so an offer that began earlier shows while it can be acted on. A warrant's years-long windows do not count. The 2026-11-03..12 golden gains DOOH, NAYZ and AUTO. - `stocks calendar --help` names the ex-date fallback, and docs/STOCKBIT.md shows the record and surface as shipped. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- crates/idx-cli/src/cli/stocks.rs | 7 +- crates/idx-cli/src/output/table.rs | 38 ++++++++-- crates/idx-cli/tests/cli.rs | 21 ++++++ .../golden/stockbit-calendar.json.golden | 2 +- .../golden/stockbit-calendar.table.golden | 70 +++++++++--------- .../idx-core/src/api/stockbit/corpaction.rs | 6 +- crates/idx-core/src/api/stockbit/exodus.rs | 38 ++++++++++ crates/idx-core/src/corporate/mod.rs | 5 +- crates/idx-core/src/corporate/types.rs | 71 +++++++++++++++++-- crates/idx-mcp/src/server.rs | 6 +- crates/idx-mcp/tests/golden/tools.json | 2 +- docs/ARCHITECTURE.md | 6 +- docs/STOCKBIT.md | 34 ++++++--- web/src/content/docs/cli/reference.md | 2 +- web/src/content/docs/cli/stocks.md | 4 +- web/src/content/docs/mcp/tools.md | 2 +- 16 files changed, 247 insertions(+), 67 deletions(-) diff --git a/crates/idx-cli/src/cli/stocks.rs b/crates/idx-cli/src/cli/stocks.rs index 718d7bb..0982248 100644 --- a/crates/idx-cli/src/cli/stocks.rs +++ b/crates/idx-cli/src/cli/stocks.rs @@ -184,9 +184,10 @@ call takes about a second per kind; answers are cached for 6 hours.", #[command( about = "Upcoming and recent corporate actions across the market (Stockbit login)", long_about = "Corporate actions across IDX from your own Stockbit session (`idx stockbit \ -login`), oldest first, dated within --from and --to (default: today and the next 30 days). \ -An action's date is its cum date for dividends, bonuses, rights and splits, else the event's \ -first day. Stockbit lists about a year back and what is announced ahead. One request per \ +login`), oldest first, dated within --from and --to (default: today and the next 30 days), \ +plus rights trading, tender offers and IPO offers still open then. An action's date is its \ +cum date for dividends, bonuses, rights and splits (its ex date when Stockbit gives no cum \ +date), else the event's first day. Stockbit lists about a year back and what is announced ahead. One request per \ kind, 1 s apart; answers are cached for 6 hours.", after_help = "Examples:\n idx stocks calendar\n idx stocks calendar --kind dividend,rights\n idx stocks calendar --from 2026-12-01 --to 2026-12-31 --kind meeting" )] diff --git a/crates/idx-cli/src/output/table.rs b/crates/idx-cli/src/output/table.rs index af37008..45ecc93 100644 --- a/crates/idx-cli/src/output/table.rs +++ b/crates/idx-cli/src/output/table.rs @@ -1701,6 +1701,20 @@ fn format_rupiah(value: f64) -> String { } } +/// Another currency's amount with up to six decimals, since a dollar +/// dividend can be a fraction of a cent: `0.0012`, `1,250.5`. +fn format_foreign_amount(value: f64) -> String { + let micros = (value.abs() * 1_000_000.0).round() as u64; + let (whole, frac) = (micros / 1_000_000, micros % 1_000_000); + let sign = if value < 0.0 && micros > 0 { "-" } else { "" }; + let whole = format_u64(whole); + if frac == 0 { + return format!("{sign}{whole}"); + } + let frac = format!("{frac:06}"); + format!("{sign}{whole}.{}", frac.trim_end_matches('0')) +} + /// What an action gives or asks, in one line. fn action_detail(action: &CorporateAction) -> String { let span = |range: Option| range.map(|r| format!("{} to {}", r.start, r.end)); @@ -1708,14 +1722,14 @@ fn action_detail(action: &CorporateAction) -> String { let mut parts: Vec = Vec::new(); match action.kind { ActionKind::Dividend => { - let unit = action - .currency - .as_deref() - .map_or_else(|| "Rp".to_string(), terminal_safe); + let (unit, amount): (String, fn(f64) -> String) = match action.currency.as_deref() { + Some(currency) => (terminal_safe(currency), format_foreign_amount), + None => ("Rp".to_string(), format_rupiah), + }; parts.extend( action .cash_per_share - .map(|c| format!("{unit} {} per share", format_rupiah(c))), + .map(|c| format!("{unit} {} per share", amount(c))), ); } ActionKind::StockDividend | ActionKind::Bonus => { @@ -1887,12 +1901,22 @@ pub fn print_corporate_calendar( #[cfg(test)] mod tests { use super::{ - format_earnings_period, format_idr, format_signal, format_table_date, format_u64, - humanize_metric_key, stale_quote_notes, + format_earnings_period, format_foreign_amount, format_idr, format_rupiah, format_signal, + format_table_date, format_u64, humanize_metric_key, stale_quote_notes, }; use idx_core::analysis::signals::Signal; use idx_core::api::types::Quote; + /// Rupiah to the sen; another currency keeps a fraction of a cent. + #[test] + fn dividend_amounts_keep_their_decimals() { + assert_eq!(format_rupiah(1191.09), "1,191.09"); + assert_eq!(format_rupiah(3.8), "3.8"); + assert_eq!(format_foreign_amount(0.0012), "0.0012"); + assert_eq!(format_foreign_amount(1250.5), "1,250.5"); + assert_eq!(format_foreign_amount(2.0), "2"); + } + fn quote_as_of(symbol: &str, as_of: &str) -> Quote { Quote { symbol: symbol.into(), diff --git a/crates/idx-cli/tests/cli.rs b/crates/idx-cli/tests/cli.rs index 490e254..05b627a 100644 --- a/crates/idx-cli/tests/cli.rs +++ b/crates/idx-cli/tests/cli.rs @@ -3266,3 +3266,24 @@ fn bandar_never_reads_a_broker_summary_cached_in_the_old_shape() { assert!(!table.contains("No trades."), "{table}"); assert!(table.contains("big distribution"), "{table}"); } + +/// `--kind` takes the names JSON carried before they matched it, so a kind +/// copied from an older answer works here as it does over MCP. +#[test] +fn actions_kind_takes_the_old_json_names() { + let root = test_env_dir("actions-old-kinds"); + let rows = run_success_json( + mock_bin_with_root(&root) + .env("IDX_STOCKBIT_REFRESH_TOKEN", FAKE_STOCKBIT_TOKEN) + .args(["-o", "json", "stocks", "actions", "BBCA", "--kind"]) + .arg("stock_dividend,reverse_split,public_expose,tender_offer"), + ); + let kinds: Vec<&str> = rows + .as_array() + .unwrap() + .iter() + .map(|row| row["kind"].as_str().unwrap()) + .collect(); + assert!(kinds.contains(&"expose"), "{kinds:?}"); + let _ = fs::remove_dir_all(root); +} diff --git a/crates/idx-cli/tests/golden/stockbit-calendar.json.golden b/crates/idx-cli/tests/golden/stockbit-calendar.json.golden index 7455de0..505d3ad 100644 --- a/crates/idx-cli/tests/golden/stockbit-calendar.json.golden +++ b/crates/idx-cli/tests/golden/stockbit-calendar.json.golden @@ -1,4 +1,4 @@ exit: 0 --- stdout -[{"symbol":"MGLV.JK","kind":"rights","date":"2026-11-04","cum_date":"2026-11-04","ex_date":"2026-11-05","record_date":"2026-11-06","ratio":{"old":100,"new":15},"factor":1.15,"price":8880,"period":{"start":"2026-11-10","end":"2026-11-23"}},{"symbol":"JPFA.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-12","cash_per_share":90.0},{"symbol":"PTPS.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-18","cash_per_share":2.0},{"symbol":"UNTR.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-23","cash_per_share":430.0},{"symbol":"CNMA.JK","kind":"dividend","date":"2026-11-06","cum_date":"2026-11-06","ex_date":"2026-11-09","record_date":"2026-11-10","pay_date":"2026-11-19","cash_per_share":4.0},{"symbol":"SMSM.JK","kind":"dividend","date":"2026-11-09","cum_date":"2026-11-09","ex_date":"2026-11-10","record_date":"2026-11-11","pay_date":"2026-11-26","cash_per_share":45.0},{"symbol":"AVIA.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-19","cash_per_share":12.0},{"symbol":"BWPT.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-25","cash_per_share":1.0},{"symbol":"ITMG.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-18","cash_per_share":1191.09},{"symbol":"MEDC.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-12-02","cash_per_share":21.65},{"symbol":"SSMS.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-12-02","cash_per_share":52.49},{"symbol":"TAPG.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-27","cash_per_share":70.0},{"symbol":"IFII.JK","kind":"dividend","date":"2026-11-11","cum_date":"2026-11-11","ex_date":"2026-11-12","record_date":"2026-11-13","pay_date":"2026-11-26","cash_per_share":5.0},{"symbol":"MIDI.JK","kind":"dividend","date":"2026-11-11","cum_date":"2026-11-11","ex_date":"2026-11-12","record_date":"2026-11-13","pay_date":"2026-12-01","cash_per_share":3.8}] +[{"symbol":"DOOH.JK","kind":"tender","date":"2026-10-05","pay_date":"2026-11-09","price":148,"period":{"start":"2026-10-05","end":"2026-11-03"},"shares":2624548624,"percentage_bps":3391,"name":"Era Media Sejahtera Tbk."},{"symbol":"NAYZ.JK","kind":"tender","date":"2026-10-05","pay_date":"2026-11-10","price":75,"period":{"start":"2026-10-05","end":"2026-11-03"},"shares":1169011472,"percentage_bps":4584,"name":"Hassana Boga Sejahtera Tbk."},{"symbol":"AUTO.JK","kind":"tender","date":"2026-10-13","pay_date":"2026-11-18","price":3600,"period":{"start":"2026-10-13","end":"2026-11-11"},"shares":238442293,"percentage_bps":495,"name":"Astra Otoparts Tbk."},{"symbol":"MGLV.JK","kind":"rights","date":"2026-11-04","cum_date":"2026-11-04","ex_date":"2026-11-05","record_date":"2026-11-06","ratio":{"old":100,"new":15},"factor":1.15,"price":8880,"period":{"start":"2026-11-10","end":"2026-11-23"}},{"symbol":"JPFA.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-12","cash_per_share":90.0},{"symbol":"PTPS.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-18","cash_per_share":2.0},{"symbol":"UNTR.JK","kind":"dividend","date":"2026-11-05","cum_date":"2026-11-05","ex_date":"2026-11-06","record_date":"2026-11-09","pay_date":"2026-11-23","cash_per_share":430.0},{"symbol":"CNMA.JK","kind":"dividend","date":"2026-11-06","cum_date":"2026-11-06","ex_date":"2026-11-09","record_date":"2026-11-10","pay_date":"2026-11-19","cash_per_share":4.0},{"symbol":"SMSM.JK","kind":"dividend","date":"2026-11-09","cum_date":"2026-11-09","ex_date":"2026-11-10","record_date":"2026-11-11","pay_date":"2026-11-26","cash_per_share":45.0},{"symbol":"AVIA.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-19","cash_per_share":12.0},{"symbol":"BWPT.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-25","cash_per_share":1.0},{"symbol":"ITMG.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-18","cash_per_share":1191.09},{"symbol":"MEDC.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-12-02","cash_per_share":21.65},{"symbol":"SSMS.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-12-02","cash_per_share":52.49},{"symbol":"TAPG.JK","kind":"dividend","date":"2026-11-10","cum_date":"2026-11-10","ex_date":"2026-11-11","record_date":"2026-11-12","pay_date":"2026-11-27","cash_per_share":70.0},{"symbol":"IFII.JK","kind":"dividend","date":"2026-11-11","cum_date":"2026-11-11","ex_date":"2026-11-12","record_date":"2026-11-13","pay_date":"2026-11-26","cash_per_share":5.0},{"symbol":"MIDI.JK","kind":"dividend","date":"2026-11-11","cum_date":"2026-11-11","ex_date":"2026-11-12","record_date":"2026-11-13","pay_date":"2026-12-01","cash_per_share":3.8}] --- stderr diff --git a/crates/idx-cli/tests/golden/stockbit-calendar.table.golden b/crates/idx-cli/tests/golden/stockbit-calendar.table.golden index 7eb5aba..9ddb54e 100644 --- a/crates/idx-cli/tests/golden/stockbit-calendar.table.golden +++ b/crates/idx-cli/tests/golden/stockbit-calendar.table.golden @@ -1,37 +1,43 @@ exit: 0 --- stdout -Corporate actions from 2026-11-03 to 2026-11-12 (14) -┌────────────┬────────┬──────────┬────────────┬───────────────────────────────────────────────────────────────────────┐ -│ DATE ┆ SYMBOL ┆ KIND ┆ EX ┆ DETAIL │ -╞════════════╪════════╪══════════╪════════════╪═══════════════════════════════════════════════════════════════════════╡ -│ 2026-11-04 ┆ MGLV ┆ rights ┆ 2026-11-05 ┆ 15 rights per 100 held, at Rp 8,880, trading 2026-11-10 to 2026-11-23 │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-05 ┆ JPFA ┆ dividend ┆ 2026-11-06 ┆ Rp 90 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-05 ┆ PTPS ┆ dividend ┆ 2026-11-06 ┆ Rp 2 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-05 ┆ UNTR ┆ dividend ┆ 2026-11-06 ┆ Rp 430 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-06 ┆ CNMA ┆ dividend ┆ 2026-11-09 ┆ Rp 4 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-09 ┆ SMSM ┆ dividend ┆ 2026-11-10 ┆ Rp 45 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-10 ┆ AVIA ┆ dividend ┆ 2026-11-11 ┆ Rp 12 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-10 ┆ BWPT ┆ dividend ┆ 2026-11-11 ┆ Rp 1 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-10 ┆ ITMG ┆ dividend ┆ 2026-11-11 ┆ Rp 1,191.09 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-10 ┆ MEDC ┆ dividend ┆ 2026-11-11 ┆ Rp 21.65 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-10 ┆ SSMS ┆ dividend ┆ 2026-11-11 ┆ Rp 52.49 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-10 ┆ TAPG ┆ dividend ┆ 2026-11-11 ┆ Rp 70 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-11 ┆ IFII ┆ dividend ┆ 2026-11-12 ┆ Rp 5 per share │ -├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ -│ 2026-11-11 ┆ MIDI ┆ dividend ┆ 2026-11-12 ┆ Rp 3.8 per share │ -└────────────┴────────┴──────────┴────────────┴───────────────────────────────────────────────────────────────────────┘ +Corporate actions from 2026-11-03 to 2026-11-12 (17) +┌────────────┬────────┬──────────────┬────────────┬──────────────────────────────────────────────────────────────────────────┐ +│ DATE ┆ SYMBOL ┆ KIND ┆ EX ┆ DETAIL │ +╞════════════╪════════╪══════════════╪════════════╪══════════════════════════════════════════════════════════════════════════╡ +│ 2026-10-05 ┆ DOOH ┆ tender offer ┆ - ┆ Rp 148, for 2,624,548,624 shares (33.91%), open 2026-10-05 to 2026-11-03 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-05 ┆ NAYZ ┆ tender offer ┆ - ┆ Rp 75, for 1,169,011,472 shares (45.84%), open 2026-10-05 to 2026-11-03 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-10-13 ┆ AUTO ┆ tender offer ┆ - ┆ Rp 3,600, for 238,442,293 shares (4.95%), open 2026-10-13 to 2026-11-11 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-04 ┆ MGLV ┆ rights ┆ 2026-11-05 ┆ 15 rights per 100 held, at Rp 8,880, trading 2026-11-10 to 2026-11-23 │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-05 ┆ JPFA ┆ dividend ┆ 2026-11-06 ┆ Rp 90 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-05 ┆ PTPS ┆ dividend ┆ 2026-11-06 ┆ Rp 2 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-05 ┆ UNTR ┆ dividend ┆ 2026-11-06 ┆ Rp 430 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-06 ┆ CNMA ┆ dividend ┆ 2026-11-09 ┆ Rp 4 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-09 ┆ SMSM ┆ dividend ┆ 2026-11-10 ┆ Rp 45 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ AVIA ┆ dividend ┆ 2026-11-11 ┆ Rp 12 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ BWPT ┆ dividend ┆ 2026-11-11 ┆ Rp 1 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ ITMG ┆ dividend ┆ 2026-11-11 ┆ Rp 1,191.09 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ MEDC ┆ dividend ┆ 2026-11-11 ┆ Rp 21.65 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ SSMS ┆ dividend ┆ 2026-11-11 ┆ Rp 52.49 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-10 ┆ TAPG ┆ dividend ┆ 2026-11-11 ┆ Rp 70 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-11 ┆ IFII ┆ dividend ┆ 2026-11-12 ┆ Rp 5 per share │ +├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ 2026-11-11 ┆ MIDI ┆ dividend ┆ 2026-11-12 ┆ Rp 3.8 per share │ +└────────────┴────────┴──────────────┴────────────┴──────────────────────────────────────────────────────────────────────────┘ DATE is the cum date for dividends, bonuses, rights and splits (buy by that day to be entitled); for other actions, the event's first day. Source: your Stockbit session; for personal, non-commercial use (Stockbit's terms). --- stderr diff --git a/crates/idx-core/src/api/stockbit/corpaction.rs b/crates/idx-core/src/api/stockbit/corpaction.rs index 0848ca8..6679c8d 100644 --- a/crates/idx-core/src/api/stockbit/corpaction.rs +++ b/crates/idx-core/src/api/stockbit/corpaction.rs @@ -98,10 +98,12 @@ fn entitlement( action.factor = number(suffixed(row, "factor")); match kind { ActionKind::Dividend => { - action.cash_per_share = number(suffixed(row, "value")).map(|v| round_to(v, 2)); action.currency = text(suffixed(row, "currency")) .map(|c| c.trim_start_matches("CURRENCY_").to_ascii_uppercase()) .filter(|c| c != "IDR"); + // Rupiah to the sen; a dollar dividend can be a fraction of a cent. + let places = if action.currency.is_some() { 6 } else { 2 }; + action.cash_per_share = number(suffixed(row, "value")).map(|v| round_to(v, places)); } ActionKind::Rights => { action.price = whole(suffixed(row, "price")); @@ -413,7 +415,9 @@ mod tests { "dividend_currency":"CURRENCY_IDR"}]}}"#; let rows = parse_corporate_actions(ActionKind::Dividend, body).unwrap(); assert_eq!(rows[0].currency.as_deref(), Some("USD")); + assert_eq!(rows[0].cash_per_share, Some(0.0012), "not rounded to cents"); assert_eq!(rows[1].currency, None); + assert_eq!(rows[1].cash_per_share, Some(5.0)); assert_eq!((rows[1].date, rows[1].cum_date), (day("2026-11-12"), None)); } diff --git a/crates/idx-core/src/api/stockbit/exodus.rs b/crates/idx-core/src/api/stockbit/exodus.rs index 051f4b3..78e201a 100644 --- a/crates/idx-core/src/api/stockbit/exodus.rs +++ b/crates/idx-core/src/api/stockbit/exodus.rs @@ -34,6 +34,11 @@ use crate::error::IdxError; const BASE_URL: &str = "https://exodus.stockbit.com"; const REFRESH_PATH: &str = "/login/refresh"; +/// The only paths idx GETs from the session API. The same API places orders, +/// withdraws cash and changes the PIN; a path outside these fails before any +/// request (or token refresh) leaves the process. A feature that reads a new +/// endpoint adds its prefix here. +const READ_PATHS: &[&str] = &["/company-price-feed/", "/charts/", "/corpaction/"]; /// The prefix of the states in which the regular market trades: /// `STATE_NAME_SESSION_2` was recorded on 2026-11-03 from 13:30; session 1 is /// assumed to follow the same naming. Every other state (`STATE_NAME_BREAK`, @@ -159,6 +164,11 @@ impl Exodus { } fn get(&self, path: &str, subject: &str) -> Result { + if !is_read_path(path) { + return Err(IdxError::Unsupported(format!( + "idx does not call {path} on Stockbit's session API" + ))); + } let refresher = |refresh: &str| self.refresh(refresh); let token = self.store.access(&refresher, unix_now())?; let mut reply = self.send(path, &token)?; @@ -477,10 +487,38 @@ fn trim_to_period(mut bars: Vec, period: &Period) -> Vec { } } +/// Whether `path` is one idx reads; `..` never climbs out of a prefix. +fn is_read_path(path: &str) -> bool { + READ_PATHS.iter().any(|prefix| path.starts_with(prefix)) && !path.contains("..") +} + #[cfg(test)] mod tests { use super::*; + /// Only the endpoints idx reads pass; trading and account paths, and a + /// path that climbs out of a prefix, never leave the process. + #[test] + fn only_read_paths_are_called() { + for path in [ + "/company-price-feed/market-time/session", + "/company-price-feed/v2/orderbook/companies/BBCA", + "/charts/BBCA/daily?timeframe=1y&chart_type=PRICE_CHART_TYPE_CANDLE", + "/corpaction/dividend?symbol=BBCA", + ] { + assert!(is_read_path(path), "{path}"); + } + for path in [ + "/order/buy", + "/login/refresh", + "/corpaction/../order/buy", + "/charts", + "", + ] { + assert!(!is_read_path(path), "{path}"); + } + } + fn fixture(name: &str) -> String { std::fs::read_to_string(format!( "{}/tests/fixtures/stockbit_exodus_{name}", diff --git a/crates/idx-core/src/corporate/mod.rs b/crates/idx-core/src/corporate/mod.rs index 4ddfe01..58ec161 100644 --- a/crates/idx-core/src/corporate/mod.rs +++ b/crates/idx-core/src/corporate/mod.rs @@ -43,7 +43,8 @@ impl Corporate<'_> { } /// The market's corporate actions of `kinds` dated within `range` (see - /// `CorporateAction::date`), oldest first. + /// `CorporateAction::date`), plus offers still open in it (see + /// `CalendarRange::includes`), oldest first. pub fn calendar( &self, range: CalendarRange, @@ -52,7 +53,7 @@ impl Corporate<'_> { ) -> Result>, IdxError> { let fetched = self.fetch(kinds, None, policy)?; Ok(fetched.map(|mut actions| { - actions.retain(|a| range.contains(a.date)); + actions.retain(|a| range.includes(a)); actions.sort_by(|a, b| (a.date, &a.symbol, a.kind).cmp(&(b.date, &b.symbol, b.kind))); actions })) diff --git a/crates/idx-core/src/corporate/types.rs b/crates/idx-core/src/corporate/types.rs index 4c67369..c03fa90 100644 --- a/crates/idx-core/src/corporate/types.rs +++ b/crates/idx-core/src/corporate/types.rs @@ -12,7 +12,10 @@ use crate::error::IdxError; pub enum ActionKind { /// Cash dividend. Dividend, - #[cfg_attr(feature = "clap", value(name = "stock-dividend"))] + #[cfg_attr( + feature = "clap", + value(name = "stock-dividend", alias = "stock_dividend") + )] #[serde(alias = "stock_dividend")] StockDividend, /// Bonus shares. @@ -22,7 +25,10 @@ pub enum ActionKind { Warrant, /// Stock split. Split, - #[cfg_attr(feature = "clap", value(name = "reverse-split"))] + #[cfg_attr( + feature = "clap", + value(name = "reverse-split", alias = "reverse_split") + )] #[serde(alias = "reverse_split")] ReverseSplit, /// Shareholders' meeting (RUPS). @@ -167,8 +173,8 @@ pub struct CorporateAction { pub record_date: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub pay_date: Option, - /// Cash dividend per share, IDR as Stockbit gives it (up to 2 decimals, - /// e.g. 3.8). + /// Cash dividend per share as Stockbit gives it: IDR to the sen (e.g. + /// 3.8), another `currency` to 6 decimals (e.g. USD 0.0012). #[serde(default, skip_serializing_if = "Option::is_none")] pub cash_per_share: Option, /// The dividend's currency (ISO code, e.g. `USD`) when it is not IDR; @@ -282,6 +288,20 @@ impl CalendarRange { pub fn contains(&self, date: NaiveDate) -> bool { (self.from..=self.to).contains(&date) } + + /// Whether `action` belongs on this calendar: dated in it, or an offer + /// still open in it (rights trading, a tender offer, an IPO offer), so a + /// calendar shows what can still be acted on. A warrant's windows run + /// for years, so a warrant counts by its date alone. + pub fn includes(&self, action: &CorporateAction) -> bool { + let open_offer = matches!( + action.kind, + ActionKind::Rights | ActionKind::TenderOffer | ActionKind::Ipo + ) && action + .period + .is_some_and(|period| period.start <= self.to && period.end >= self.from); + self.contains(action.date) || open_offer + } } #[cfg(test)] @@ -292,6 +312,49 @@ mod tests { NaiveDate::parse_from_str(s, "%Y-%m-%d").unwrap() } + /// A calendar shows what is dated in it and the offers still open in it; + /// a warrant's years-long windows do not put it on every calendar. + #[test] + fn test_calendar_includes_offers_still_open() { + let range = CalendarRange { + from: day("2026-11-03"), + to: day("2026-11-12"), + }; + let with_period = |kind, date: &str, start: &str, end: &str| { + let mut action = CorporateAction::new("AUTO.JK".into(), kind, day(date)); + action.period = Some(DateRange { + start: day(start), + end: day(end), + }); + action + }; + let tender = with_period( + ActionKind::TenderOffer, + "2026-10-13", + "2026-10-13", + "2026-11-11", + ); + assert!(range.includes(&tender), "open until 11-11"); + let rights = with_period(ActionKind::Rights, "2026-10-20", "2026-10-28", "2026-11-03"); + assert!(range.includes(&rights), "trades on the first day"); + let closed = with_period( + ActionKind::TenderOffer, + "2026-09-01", + "2026-09-01", + "2026-11-02", + ); + assert!(!range.includes(&closed), "closed the day before"); + let warrant = with_period( + ActionKind::Warrant, + "2025-01-10", + "2025-01-10", + "2028-01-10", + ); + assert!(!range.includes(&warrant), "a warrant counts by its date"); + let dated = CorporateAction::new("BBCA.JK".into(), ActionKind::Dividend, day("2026-11-12")); + assert!(range.includes(&dated)); + } + #[test] fn test_calendar_range_defaults_and_bounds() { let today = day("2026-11-03"); diff --git a/crates/idx-mcp/src/server.rs b/crates/idx-mcp/src/server.rs index 319e577..5df708e 100644 --- a/crates/idx-mcp/src/server.rs +++ b/crates/idx-mcp/src/server.rs @@ -384,8 +384,10 @@ fields are omitted. One Stockbit request per kind (about 1 s each on a cold cach #[tool( description = "Corporate actions across IDX from the user's own Stockbit session, \ -oldest first, dated from `from` to `to` (default today and the next 30 days): upcoming cum \ -dates, meetings, exposes, rights, warrants, IPOs and tender offers, and the past year. Each \ +oldest first, dated from `from` to `to` (default today and the next 30 days), plus rights \ +trading, tender offers and IPO offers still open in that range (their `period` overlaps it, \ +though `date` may be earlier): upcoming cum dates, meetings, exposes, rights, warrants, IPOs \ +and tender offers, and the past year. Each \ item has the same fields as get_corporate_actions, with `symbol`. One Stockbit request per \ kind (about 1 s each on a cold cache, then cached 6 hours); pass `kinds` to ask for less. \ AUTHERROR means there is no session: call stockbit_status, then stockbit_login." diff --git a/crates/idx-mcp/tests/golden/tools.json b/crates/idx-mcp/tests/golden/tools.json index 97e8a9c..53ef641 100644 --- a/crates/idx-mcp/tests/golden/tools.json +++ b/crates/idx-mcp/tests/golden/tools.json @@ -274,7 +274,7 @@ "name": "get_corporate_actions" }, { - "description": "Corporate actions across IDX from the user's own Stockbit session, oldest first, dated from `from` to `to` (default today and the next 30 days): upcoming cum dates, meetings, exposes, rights, warrants, IPOs and tender offers, and the past year. Each item has the same fields as get_corporate_actions, with `symbol`. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours); pass `kinds` to ask for less. AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", + "description": "Corporate actions across IDX from the user's own Stockbit session, oldest first, dated from `from` to `to` (default today and the next 30 days), plus rights trading, tender offers and IPO offers still open in that range (their `period` overlaps it, though `date` may be earlier): upcoming cum dates, meetings, exposes, rights, warrants, IPOs and tender offers, and the past year. Each item has the same fields as get_corporate_actions, with `symbol`. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours); pass `kinds` to ask for less. AUTHERROR means there is no session: call stockbit_status, then stockbit_login.", "inputSchema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 7adf79b..3af5ac5 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -296,8 +296,10 @@ WIB as the fallback. request per kind, cached 6 hours under `stockbit-corpaction` (`:` or `:market`); `stocks actions` / `get_corporate_actions` sort newest first, `stocks calendar` / - `get_corporate_calendar` filter by `CorporateAction::date` (the cum date - for entitlements) and sort oldest first. Endpoint notes and the wider + `get_corporate_calendar` keep what `CalendarRange::includes`: a + `CorporateAction::date` (the cum date for entitlements) in the range, or a + rights, tender or IPO `period` that overlaps it (not a warrant's, which + runs for years), sorted oldest first. Endpoint notes and the wider design: `docs/STOCKBIT.md`. ### Capability Gating diff --git a/docs/STOCKBIT.md b/docs/STOCKBIT.md index 037de85..17c692d 100644 --- a/docs/STOCKBIT.md +++ b/docs/STOCKBIT.md @@ -10,7 +10,8 @@ one GET at a time at least 1 s apart. Nothing here ships yet unless marked. ## Rules for every session feature 1. **Read-only by construction.** The session client (`api/stockbit/exodus.rs`) - issues GET on an allowlist of path prefixes, plus `POST /login/refresh`. + issues GET only on an allowlist of path prefixes (`READ_PATHS`), plus + `POST /login/refresh`. The bundle also holds trading (orders, day trade, PIN, cash withdrawal, portfolio), chat, posting and account endpoints; idx never calls them, and the allowlist makes a stray call fail before it leaves the process. @@ -134,18 +135,32 @@ Examples from 2026-11-03: PPGL bonus 6:4 ex 2026-11-03; PRDA split 1:5 cum ### Types +As shipped (`corporate/types.rs`), one flat record with a calendar `date` and +optional per-kind fields; JSON leaves absent ones out: + ```rust pub struct CorporateAction { - pub symbol: String, // BBCA.JK - pub kind: ActionKind, // Dividend, StockDividend, Bonus, Rights, Warrant, - // Split, ReverseSplit, Meeting, PublicExpose, Ipo, TenderOffer + pub symbol: String, // BBCA.JK + pub kind: ActionKind, // JSON: dividend, stock-dividend, bonus, rights, warrant, + // split, reverse-split, meeting, expose, ipo, tender + pub date: NaiveDate, // cum date for entitlements (ex date without one), + // else the event's first day pub cum_date: Option, pub ex_date: Option, pub record_date: Option, pub pay_date: Option, - pub event_date: Option, // meeting, expose, listing, tender end - pub detail: ActionDetail, // kind-specific: amount + currency; old:new ratio - // and factor; price; trading/exercise windows; venue + pub cash_per_share: Option, // dividends; IDR to the sen, else up to 6 decimals + pub currency: Option, // dividends not paid in IDR + pub ratio: Option, // old : new + pub factor: Option, // Stockbit's price adjustment + pub price: Option, // rights, warrant, tender or IPO price (IDR) + pub period: Option, // rights or warrant trading, tender, IPO offer + pub exercise: Option, // warrant exercise + pub shares: Option, // offered (IPO) or sought (tender) + pub percentage_bps: Option, // tender + pub time: Option, // meeting or expose + pub venue: Option, + pub name: Option, // IPO or tender issuer } ``` @@ -157,8 +172,9 @@ lists are not errors. A row whose dates are all placeholders is dropped. - `idx stocks actions SYM [--kind dividend,rights,...]`: one stock's history, newest first; every kind but `ipo` by default. - `idx stocks calendar [--kind ...] [--from DATE] [--to DATE]`: market-wide, - default today to +30 days, oldest first by `date`. -- MCP: `get_corporate_actions {symbol, kinds?, since?}`, + default today to +30 days, oldest first by `date`; rights trading, tender + offers and IPO offers still open in the range are included too. +- MCP: `get_corporate_actions {symbol, kinds?}`, `get_corporate_calendar {kinds?, from?, to?}`. - Later: `stocks history` notes ex-dates of splits, bonuses and rights in the window, so a gap is not read as a crash. diff --git a/web/src/content/docs/cli/reference.md b/web/src/content/docs/cli/reference.md index e02f3a4..dda1a85 100644 --- a/web/src/content/docs/cli/reference.md +++ b/web/src/content/docs/cli/reference.md @@ -290,7 +290,7 @@ Examples: ### `idx stocks calendar` ```text -Corporate actions across IDX from your own Stockbit session (`idx stockbit login`), oldest first, dated within --from and --to (default: today and the next 30 days). An action's date is its cum date for dividends, bonuses, rights and splits, else the event's first day. Stockbit lists about a year back and what is announced ahead. One request per kind, 1 s apart; answers are cached for 6 hours. +Corporate actions across IDX from your own Stockbit session (`idx stockbit login`), oldest first, dated within --from and --to (default: today and the next 30 days), plus rights trading, tender offers and IPO offers still open then. An action's date is its cum date for dividends, bonuses, rights and splits (its ex date when Stockbit gives no cum date), else the event's first day. Stockbit lists about a year back and what is announced ahead. One request per kind, 1 s apart; answers are cached for 6 hours. Usage: idx stocks calendar [OPTIONS] diff --git a/web/src/content/docs/cli/stocks.md b/web/src/content/docs/cli/stocks.md index d955873..71b1810 100644 --- a/web/src/content/docs/cli/stocks.md +++ b/web/src/content/docs/cli/stocks.md @@ -60,7 +60,9 @@ idx stocks calendar --kind dividend,rights --to 2026-12-31 issues, warrants, splits and reverse splits, shareholders' meetings, public exposes and tender offers (`--kind ipo` adds its IPO). `calendar` lists them across the market between `--from` and `--to` (at most 366 days), including -what is announced ahead. An action's date is its cum date for dividends, +what is announced ahead, plus rights trading, tender offers and IPO offers +still open in that range, so an offer that began earlier still shows while +you can act on it. An action's date is its cum date for dividends, bonuses, rights and splits: buy by then to be entitled. For the others it is the event's first day. When Stockbit gives no cum date, the action sits on its ex date, marked `(ex)` in the table, and JSON leaves `cum_date` out. diff --git a/web/src/content/docs/mcp/tools.md b/web/src/content/docs/mcp/tools.md index a35fc5d..b9ed56f 100644 --- a/web/src/content/docs/mcp/tools.md +++ b/web/src/content/docs/mcp/tools.md @@ -74,7 +74,7 @@ Corporate actions of one IDX stock from the user's own Stockbit session, newest ## `get_corporate_calendar` -Corporate actions across IDX from the user's own Stockbit session, oldest first, dated from `from` to `to` (default today and the next 30 days): upcoming cum dates, meetings, exposes, rights, warrants, IPOs and tender offers, and the past year. Each item has the same fields as get_corporate_actions, with `symbol`. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours); pass `kinds` to ask for less. AUTHERROR means there is no session: call stockbit_status, then stockbit_login. +Corporate actions across IDX from the user's own Stockbit session, oldest first, dated from `from` to `to` (default today and the next 30 days), plus rights trading, tender offers and IPO offers still open in that range (their `period` overlaps it, though `date` may be earlier): upcoming cum dates, meetings, exposes, rights, warrants, IPOs and tender offers, and the past year. Each item has the same fields as get_corporate_actions, with `symbol`. One Stockbit request per kind (about 1 s each on a cold cache, then cached 6 hours); pass `kinds` to ask for less. AUTHERROR means there is no session: call stockbit_status, then stockbit_login. | Input | Type | Required | Description | | --- | --- | --- | --- | From 8f5c56e464ad5be1bd21d62229a8bedaf506aefb Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 20:44:51 +0700 Subject: [PATCH 12/16] fix(movements): allow the movements path, and describe its one cache entry - The session client's new read-path allowlist (#78) gains `/insider/company/majorholder?`, the one endpoint movements reads; without it every live movements query would fail before leaving the process. The mock does not go through the client, so its tests could not show this. - docs/ARCHITECTURE.md described one cache entry per page: a query's pages are read and cached together, keyed by the page count, and a failed later page returns the rows before it with `incomplete` (Pullfrog on #80). Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- crates/idx-core/src/api/stockbit/exodus.rs | 9 ++++++++- docs/ARCHITECTURE.md | 10 ++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/idx-core/src/api/stockbit/exodus.rs b/crates/idx-core/src/api/stockbit/exodus.rs index 3d832b9..8948347 100644 --- a/crates/idx-core/src/api/stockbit/exodus.rs +++ b/crates/idx-core/src/api/stockbit/exodus.rs @@ -39,7 +39,12 @@ const REFRESH_PATH: &str = "/login/refresh"; /// withdraws cash and changes the PIN; a path outside these fails before any /// request (or token refresh) leaves the process. A feature that reads a new /// endpoint adds its prefix here. -const READ_PATHS: &[&str] = &["/company-price-feed/", "/charts/", "/corpaction/"]; +const READ_PATHS: &[&str] = &[ + "/company-price-feed/", + "/charts/", + "/corpaction/", + "/insider/company/majorholder?", +]; /// The prefix of the states in which the regular market trades: /// `STATE_NAME_SESSION_2` was recorded on 2026-11-03 from 13:30; session 1 is /// assumed to follow the same naming. Every other state (`STATE_NAME_BREAK`, @@ -525,6 +530,7 @@ mod tests { "/company-price-feed/v2/orderbook/companies/BBCA", "/charts/BBCA/daily?timeframe=1y&chart_type=PRICE_CHART_TYPE_CANDLE", "/corpaction/dividend?symbol=BBCA", + "/insider/company/majorholder?page=1&symbol=BBCA", ] { assert!(is_read_path(path), "{path}"); } @@ -532,6 +538,7 @@ mod tests { "/order/buy", "/login/refresh", "/corpaction/../order/buy", + "/insider/company/majorholder/../../order", "/charts", "", ] { diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index e724e59..edfd44a 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -304,10 +304,12 @@ WIB as the fallback. - Shareholder movements (`movements`, `api/stockbit/movement.rs`) read `/insider/company/majorholder`: IDX insider disclosures and KSEI 5% holder changes, 50 rows a page, filtered by Stockbit (`symbol`, `date_start`, - `date_end`, `insider` (holder id), `action_type`, `source_type`). Each page - is cached an hour under `stockbit-movements`, keyed by every filter and the - page. `ownership movements` and `get_shareholder_movements` read up to 10 - pages; the KSEI register in SQLite is not involved. + `date_end`, `insider` (holder id), `action_type`, `source_type`). + `ownership movements` and `get_shareholder_movements` read up to 10 pages + as one answer, cached an hour under `stockbit-movements`, keyed by every + filter and the page count. If a page after the first fails, the rows read + before it come back with `incomplete` set and nothing is cached. The KSEI + register in SQLite is not involved. ### Capability Gating ``` From 7830de36361e0dc9ebb37f7592c12110b7d37f0a Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 20:46:27 +0700 Subject: [PATCH 13/16] docs(mcp): the generated tools page names `warnings` The tools reference page described results as {data, source, fetched_at, stale} and failures as {error, code, message}, without the `warnings` this PR adds (Pullfrog on #81). The generator's intro says so; page regenerated. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- web/scripts/gen-mcp-tools.sh | 4 +++- web/src/content/docs/mcp/tools.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web/scripts/gen-mcp-tools.sh b/web/scripts/gen-mcp-tools.sh index fefb17f..ad687e7 100755 --- a/web/scripts/gen-mcp-tools.sh +++ b/web/scripts/gen-mcp-tools.sh @@ -19,7 +19,9 @@ description: Every idx-mcp tool and its inputs, generated from the server's tool idx-mcp serves these tools. `ownership_sync` is listed only when the server starts with `--allow-sync`. Results that come from a live provider are wrapped as `{data, source, fetched_at, stale}`; failures return `{error, code, -message}` with `isError` set. +message}` with `isError` set. Either may carry `warnings`, what idx worked +around (such as a history fallback or a stale cache entry), when there was +any. EOF diff --git a/web/src/content/docs/mcp/tools.md b/web/src/content/docs/mcp/tools.md index 43ec637..e6dbb65 100644 --- a/web/src/content/docs/mcp/tools.md +++ b/web/src/content/docs/mcp/tools.md @@ -8,7 +8,9 @@ description: Every idx-mcp tool and its inputs, generated from the server's tool idx-mcp serves these tools. `ownership_sync` is listed only when the server starts with `--allow-sync`. Results that come from a live provider are wrapped as `{data, source, fetched_at, stale}`; failures return `{error, code, -message}` with `isError` set. +message}` with `isError` set. Either may carry `warnings`, what idx worked +around (such as a history fallback or a stale cache entry), when there was +any. ## `analyze_bandar` From 96a900e0b883e034707cf36ddddaaf7b1310a06e Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 21:04:24 +0700 Subject: [PATCH 14/16] fix(calendar): say when the table holds offers opened before --from Open offers are listed by the day they opened, so "from 2026-11-03 to 2026-11-12" sat above tenders dated in October (Pullfrog on #78). The title adds "with offers opened earlier and still open" when such rows are there. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- crates/idx-cli/src/output/table.rs | 10 +++++++++- .../tests/golden/stockbit-calendar.table.golden | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/idx-cli/src/output/table.rs b/crates/idx-cli/src/output/table.rs index 45ecc93..945f731 100644 --- a/crates/idx-cli/src/output/table.rs +++ b/crates/idx-cli/src/output/table.rs @@ -1864,10 +1864,18 @@ pub fn print_corporate_calendar( range: &CalendarRange, actions: &[CorporateAction], ) -> Result<(), IdxError> { + // Offers still open are listed by the day they opened, which can be + // before `from`; the title says so rather than claim the range bounds + // every row. + let earlier = if actions.iter().any(|a| a.date < range.from) { + ", with offers opened earlier and still open" + } else { + "" + }; println!( "{}", format!( - "Corporate actions from {} to {} ({})", + "Corporate actions from {} to {}{earlier} ({})", range.from, range.to, actions.len() diff --git a/crates/idx-cli/tests/golden/stockbit-calendar.table.golden b/crates/idx-cli/tests/golden/stockbit-calendar.table.golden index 9ddb54e..7376ced 100644 --- a/crates/idx-cli/tests/golden/stockbit-calendar.table.golden +++ b/crates/idx-cli/tests/golden/stockbit-calendar.table.golden @@ -1,6 +1,6 @@ exit: 0 --- stdout -Corporate actions from 2026-11-03 to 2026-11-12 (17) +Corporate actions from 2026-11-03 to 2026-11-12, with offers opened earlier and still open (17) ┌────────────┬────────┬──────────────┬────────────┬──────────────────────────────────────────────────────────────────────────┐ │ DATE ┆ SYMBOL ┆ KIND ┆ EX ┆ DETAIL │ ╞════════════╪════════╪══════════════╪════════════╪══════════════════════════════════════════════════════════════════════════╡ From 9373be222a35e16998b39f16fb2bc698376830c5 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Wed, 4 Nov 2026 21:05:01 +0700 Subject: [PATCH 15/16] test(movements): check the allowlist against the real movements path builder The read-path test listed a hand-written movements path; it now also builds paths with movement::request_path, so the test fails offline if the allowlist and the builder drift apart (Pullfrog on #80). Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY --- crates/idx-core/src/api/stockbit/exodus.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/idx-core/src/api/stockbit/exodus.rs b/crates/idx-core/src/api/stockbit/exodus.rs index 8948347..8e3e60b 100644 --- a/crates/idx-core/src/api/stockbit/exodus.rs +++ b/crates/idx-core/src/api/stockbit/exodus.rs @@ -534,6 +534,15 @@ mod tests { ] { assert!(is_read_path(path), "{path}"); } + // Paths another module builds come from its own builder, so the + // allowlist cannot drift from them. + let query = MovementQuery::default(); + for path in [ + movement::request_path(&query, None, 1), + movement::request_path(&query, Some("BBCA"), 3), + ] { + assert!(is_read_path(&path), "{path}"); + } for path in [ "/order/buy", "/login/refresh", From 32b978b16cdad3d106ba05eefbcc586837d0b556 Mon Sep 17 00:00:00 2001 From: hermes Date: Thu, 5 Nov 2026 10:22:03 +0000 Subject: [PATCH 16/16] docs(movements): say the JSON can carry incomplete --- crates/idx-cli/src/output/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/idx-cli/src/output/mod.rs b/crates/idx-cli/src/output/mod.rs index 62506f4..4b7aad2 100644 --- a/crates/idx-cli/src/output/mod.rs +++ b/crates/idx-cli/src/output/mod.rs @@ -127,7 +127,8 @@ pub fn render_corporate_calendar( } } -/// JSON is `{movements, more}` (`more`: rows remain past the pages read); +/// JSON is `{movements, more}` (`more`: rows remain past the pages read), plus +/// `incomplete` when a later page failed and only the rows before it came back; /// JSONL is one movement per line. /// `pages` is how many pages the query asked for, for the hint when more /// rows exist. JSONL streams the rows only, so the hint goes to stderr.