mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
feat: Stockbit login for the order book, live quotes and daily history
Opt-in, with the user's own Stockbit session from a pasted credentialStorage cookie (or IDX_STOCKBIT_REFRESH_TOKEN): - idx stockbit login/status/logout; session file 0600, tokens never shown - rotating refresh under a cross-process lock; one refresh+retry on 401 - stocks orderbook: depth with lots and orders, OHLC, value, foreign flow - --provider stockbit quotes from the session API when logged in - --history-provider stockbit, and auto under the stockbit provider for 5d-1y daily windows - MCP get_orderbook and stockbit_status (17 tools) Endpoints, units and recorded responses from fzn0x/idx (MIT).
This commit is contained in:
parent
570439369e
commit
b5ae9b98de
61 changed files with 2882 additions and 129 deletions
|
|
@ -22,6 +22,7 @@ Commands:
|
|||
config Manage configuration
|
||||
cache Manage local cache
|
||||
ownership Ownership intelligence (bootstrap with `ownership sync`)
|
||||
stockbit Your Stockbit session (opt-in: order book, live quotes)
|
||||
completions Generate shell completions
|
||||
version Show idx-cli version
|
||||
help Print this message or the help of the given subcommand(s)
|
||||
|
|
@ -66,6 +67,7 @@ Usage: idx stocks [OPTIONS] <COMMAND>
|
|||
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)
|
||||
history Get historical OHLC data
|
||||
technical Run technical analysis on a stock
|
||||
growth Run growth analysis on a stock
|
||||
|
|
@ -170,6 +172,57 @@ Examples:
|
|||
idx -o json stocks intraday BBCA | jq '.points[-1]'
|
||||
```
|
||||
|
||||
### `idx stocks orderbook`
|
||||
|
||||
```text
|
||||
The order book of one IDX stock from your own Stockbit session (`idx stockbit login`): bid and offer levels with lots and queued orders, the session's OHLC, volume, value and foreign buy, sell and net. Outside trading it is the book as the market left it, and the output says so.
|
||||
|
||||
Usage: idx stocks orderbook [OPTIONS] <SYMBOL>
|
||||
|
||||
Arguments:
|
||||
<SYMBOL>
|
||||
Single ticker symbol (e.g. BBCA)
|
||||
|
||||
Options:
|
||||
--depth <DEPTH>
|
||||
Price levels per side (1-50)
|
||||
|
||||
[default: 10]
|
||||
|
||||
-o, --output <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 <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 orderbook BBCA
|
||||
idx stocks orderbook BBRI --depth 5
|
||||
idx -o json stocks orderbook TLKM | jq '.offers[0]'
|
||||
```
|
||||
|
||||
### `idx stocks history`
|
||||
|
||||
```text
|
||||
|
|
@ -190,7 +243,7 @@ Options:
|
|||
--no-color
|
||||
Disable colored output
|
||||
--history-provider <HISTORY_PROVIDER>
|
||||
[possible values: auto, yahoo, msn]
|
||||
[possible values: auto, yahoo, msn, stockbit]
|
||||
-q, --quiet
|
||||
Suppress non-essential output
|
||||
-v, --verbose...
|
||||
|
|
@ -221,7 +274,7 @@ Arguments:
|
|||
|
||||
Options:
|
||||
--history-provider <HISTORY_PROVIDER>
|
||||
[possible values: auto, yahoo, msn]
|
||||
[possible values: auto, yahoo, msn, stockbit]
|
||||
-o, --output <OUTPUT>
|
||||
Output format [default: auto = table on a terminal, json when piped] [possible values: auto, table, json, jsonl]
|
||||
--no-color
|
||||
|
|
@ -1494,6 +1547,128 @@ Options:
|
|||
-h, --help Print help
|
||||
```
|
||||
|
||||
## `idx stockbit`
|
||||
|
||||
```text
|
||||
Your own Stockbit session, for `stocks orderbook`, live `--provider stockbit` quotes and Stockbit daily history. Opt-in and personal: idx uses your account's tokens, stored in the config directory with owner-only permissions, and never logs them. Stockbit rotates the refresh token on every refresh, so a browser sharing the session is logged out once idx refreshes: log in through a separate browser profile for idx. Stockbit's terms allow personal, non-commercial use.
|
||||
|
||||
Usage: idx stockbit [OPTIONS] <COMMAND>
|
||||
|
||||
Commands:
|
||||
login Store a session pasted on stdin and check it with Stockbit
|
||||
status Show whether a session is stored and when its tokens expire
|
||||
logout Delete the stored session
|
||||
help Print this message or the help of the given subcommand(s)
|
||||
|
||||
Options:
|
||||
-o, --output <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 <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 stockbit login # paste the credentialStorage cookie
|
||||
pbpaste | idx stockbit login
|
||||
idx stockbit status
|
||||
idx stockbit logout
|
||||
```
|
||||
|
||||
### `idx stockbit login`
|
||||
|
||||
```text
|
||||
Reads, on stdin, the value of stockbit.com's `credentialStorage` cookie (in a logged-in browser: DevTools, Application, Cookies, https://stockbit.com) or a refresh token, stores it, and checks it with one request. Servers can set IDX_STOCKBIT_REFRESH_TOKEN instead.
|
||||
|
||||
Usage: idx stockbit login [OPTIONS]
|
||||
|
||||
Options:
|
||||
-o, --output <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 <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')
|
||||
```
|
||||
|
||||
### `idx stockbit status`
|
||||
|
||||
```text
|
||||
Show whether a session is stored and when its tokens expire
|
||||
|
||||
Usage: idx stockbit status [OPTIONS]
|
||||
|
||||
Options:
|
||||
-o, --output <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 <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
|
||||
```
|
||||
|
||||
### `idx stockbit logout`
|
||||
|
||||
```text
|
||||
Delete the stored session
|
||||
|
||||
Usage: idx stockbit logout [OPTIONS]
|
||||
|
||||
Options:
|
||||
-o, --output <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 <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
|
||||
```
|
||||
|
||||
## `idx completions`
|
||||
|
||||
```text
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
---
|
||||
title: Stockbit
|
||||
description: Today's session by the minute and quotes with best bid/offer, from Stockbit's public page. Opt-in, no account.
|
||||
description: Today's session by the minute and quotes with best bid/offer from Stockbit's public page, plus the order book and live quotes with your own Stockbit login. Both opt-in.
|
||||
---
|
||||
|
||||
[Stockbit](https://stockbit.com)'s public symbol page carries a quote, the
|
||||
best bid and offer, and today's price for every minute of the session. idx
|
||||
reads that page directly. It needs no Stockbit account, no login and no
|
||||
helper tools.
|
||||
helper tools. With your own Stockbit account, idx can also read the order
|
||||
book and live quotes; see [With your Stockbit login](#with-your-stockbit-login).
|
||||
|
||||
```bash
|
||||
idx stocks intraday BBCA # today's session, by the minute
|
||||
|
|
@ -31,7 +32,7 @@ idx -o json stocks intraday BBCA | jq '.points | length'
|
|||
shows the book as it closed. idx leaves `bid` and `offer` out then, so the
|
||||
closing book never passes for a live one.
|
||||
- **Top of the book only.** One bid and one offer price, no depth. The full
|
||||
order book needs a Stockbit login, which idx does not do.
|
||||
order book needs your [Stockbit login](#with-your-stockbit-login).
|
||||
- **Prices only.** The page has no per-minute volume or OHLC.
|
||||
- **Empty sessions are data.** A suspended or delisted stock answers with
|
||||
`points: []` and a `session_note` saying so (`Stockbit lists the stock as
|
||||
|
|
@ -41,8 +42,9 @@ idx -o json stocks intraday BBCA | jq '.points | length'
|
|||
|
||||
`--provider stockbit` (or `IDX_PROVIDER=stockbit`, or
|
||||
`idx config set general.provider stockbit`) changes only where quotes come
|
||||
from. History still comes from Yahoo. Company data, fundamentals and
|
||||
screening answer `UNSUPPORTED` under it, so use MSN for those.
|
||||
from. Without a login, history still comes from Yahoo. Company data,
|
||||
fundamentals and screening answer `UNSUPPORTED` under it, so use MSN for
|
||||
those.
|
||||
|
||||
## How idx talks to Stockbit
|
||||
|
||||
|
|
@ -63,13 +65,63 @@ screening answer `UNSUPPORTED` under it, so use MSN for those.
|
|||
Wait, or try from another network. `--provider msn` serves quotes without
|
||||
Stockbit.
|
||||
|
||||
## With your Stockbit login
|
||||
|
||||
Opt-in, and only with your own account. idx then talks to Stockbit's own API
|
||||
(`exodus.stockbit.com`) with your session's tokens.
|
||||
|
||||
```bash
|
||||
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 --provider stockbit stocks quote BBCA # live, not delayed
|
||||
idx --provider stockbit stocks history BBCA --period 1y # Stockbit's daily candles
|
||||
idx stockbit logout
|
||||
```
|
||||
|
||||
**Logging in.** In a browser logged in to stockbit.com, open DevTools,
|
||||
Application, Cookies, `https://stockbit.com`, and copy the value of
|
||||
`credentialStorage`. Paste it into `idx stockbit login`, or pipe it
|
||||
(`pbpaste | idx stockbit login`). A refresh token on its own works too. idx
|
||||
checks the session with one request and stores it in
|
||||
`~/.config/idx/stockbit-session.json`, readable only by you. Tokens never
|
||||
appear in output, logs or errors. On a server, set
|
||||
`IDX_STOCKBIT_REFRESH_TOKEN` instead.
|
||||
|
||||
**One refresher per session.** Stockbit replaces the refresh token every time
|
||||
it is used. Once idx refreshes your session, a browser holding the same
|
||||
session has to log in again, and two tools sharing one session log each
|
||||
other out. Log in through a separate browser profile (or a private window
|
||||
you then close) for idx. idx processes on one machine take turns through a
|
||||
lock, so they never spend the token twice.
|
||||
|
||||
What the login adds:
|
||||
|
||||
| | Without a login | With your login |
|
||||
| --- | --- | --- |
|
||||
| `--provider stockbit` quotes | public page, delayed | Stockbit's API, live |
|
||||
| Bid and offer in quotes | best price, while open | best price, while open |
|
||||
| `stocks orderbook` | `AUTHERROR` | every level with lots and queued orders, OHLC, value, trades, foreign buy/sell/net |
|
||||
| `stocks history` under `--provider stockbit` | Yahoo | Stockbit's daily candles for `5d` to `1y`; Yahoo for other windows |
|
||||
| `stocks intraday` | public page | public page |
|
||||
|
||||
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. Sizes are lots in the
|
||||
table and shares in JSON. `--history-provider stockbit` asks for Stockbit's
|
||||
candles explicitly; windows it charts only weekly or hourly (`2y`, `5y`,
|
||||
`1wk`) answer `UNSUPPORTED`.
|
||||
|
||||
## Terms
|
||||
|
||||
Stockbit's [terms](https://stockbit.com/terms) allow its content for personal,
|
||||
non-commercial use. They prohibit data mining, robots and redistribution
|
||||
without Stockbit's written consent. idx is not affiliated with or endorsed by
|
||||
Stockbit. Use this for looking at a stock now and then, not for crawling the
|
||||
market or republishing prices.
|
||||
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 the `get_intraday` tool, and from
|
||||
`get_quotes` when the server runs with `IDX_PROVIDER=stockbit`.
|
||||
Over MCP, the same data comes from `get_intraday`, `get_orderbook` 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.
|
||||
|
|
|
|||
|
|
@ -33,6 +33,18 @@ sparkline and the last five minutes. JSON gives every minute in `points`. It
|
|||
is delayed at least 10 minutes. See [Stockbit](/cli/stockbit/) for what it
|
||||
covers and the terms it comes with.
|
||||
|
||||
## Order book (Stockbit login)
|
||||
|
||||
```bash
|
||||
idx stocks orderbook BBCA
|
||||
idx stocks orderbook BBRI --depth 5
|
||||
```
|
||||
|
||||
With your own Stockbit session (`idx stockbit login`), `orderbook` shows
|
||||
every bid and offer level with lots and queued orders, the session's OHLC,
|
||||
value and trades, and foreign buy, sell and net. Without one it answers
|
||||
`AUTHERROR`. See [Stockbit](/cli/stockbit/#with-your-stockbit-login).
|
||||
|
||||
## Company data
|
||||
|
||||
| Command | What it shows |
|
||||
|
|
@ -156,8 +168,10 @@ idx stocks screen --filter high-dividend | jq -r '.[].symbol' | idx stocks compa
|
|||
|
||||
MSN is the default for quotes, company data and screening; Yahoo serves
|
||||
price history. Indo Premier (IPOT) serves broker summaries and foreign flow
|
||||
(IDX's own site with `flow --source idx`), and Stockbit serves `intraday`,
|
||||
whichever provider is selected. Switch with `--provider msn|yahoo|stockbit`
|
||||
(or `IDX_PROVIDER`) and `IDX_HISTORY_PROVIDER=auto|yahoo|msn`, or the
|
||||
matching [config keys](/start/config/). `--provider stockbit` serves quotes
|
||||
only, with the best bid/offer; see [Stockbit](/cli/stockbit/).
|
||||
(IDX's own site with `flow --source idx`), and Stockbit serves `intraday`
|
||||
and, with your login, `orderbook`, whichever provider is selected. Switch
|
||||
with `--provider msn|yahoo|stockbit` (or `IDX_PROVIDER`) and
|
||||
`IDX_HISTORY_PROVIDER=auto|yahoo|msn|stockbit`, or the matching
|
||||
[config keys](/start/config/). `--provider stockbit` serves quotes only, with
|
||||
the best bid/offer, live when you are logged in; see
|
||||
[Stockbit](/cli/stockbit/).
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ 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
|
||||
[15 tools](/mcp/tools/) (plus an opt-in `ownership_sync`): quotes, today's
|
||||
session by the minute, price history, screening, company data, analysis,
|
||||
comparison, broker summaries, bandarmology, foreign flow, and the KSEI
|
||||
ownership queries.
|
||||
[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,
|
||||
bandarmology, foreign flow, and the KSEI ownership queries.
|
||||
|
||||
It shares idx's [config, cache and ownership database](/start/config/#files-idx-keeps),
|
||||
so `idx ownership sync` in a terminal also feeds the server.
|
||||
|
|
@ -46,6 +46,7 @@ body, so the agent can decide whether to retry:
|
|||
| --- | --- |
|
||||
| tickers per call (`get_quotes`, `compare_stocks`) | 20, duplicates removed |
|
||||
| `get_intraday` `tail` | 400 minutes (default: the whole session) |
|
||||
| `get_orderbook` `depth` | 50 levels per side (default 10) |
|
||||
| `screen_stocks` `limit` | 200 |
|
||||
| `search_investors` `limit` | 100 |
|
||||
| `get_ownership_changes` `limit` | 300 per page (default 200); page with `offset` |
|
||||
|
|
|
|||
|
|
@ -92,6 +92,15 @@ Every IDX holding (above 1%) of one investor, matched by name.
|
|||
| --- | --- | --- | --- |
|
||||
| `entity` | string | yes | Investor name or part of it, e.g. "DWIMURIA"; the closest match is used. |
|
||||
|
||||
## `get_orderbook`
|
||||
|
||||
Order book of one IDX stock from the user's own Stockbit session: `bids` and `offers` (best price first) of {price, shares, orders}, the session's OHLC, volume (shares), value and frequency, and foreign buy/sell/net in IDR. `market_status` is Stockbit's state, verbatim; outside STATE_NAME_MARKET_OPEN the book is as the market left it. AUTHERROR means there is no session: call stockbit_status, and ask the user to run `idx stockbit login` in a terminal.
|
||||
|
||||
| Input | Type | Required | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `depth` | integer | no | Price levels per side (default 10, at most 50). |
|
||||
| `symbol` | string | yes | IDX ticker, e.g. "BBCA". |
|
||||
|
||||
## `get_ownership_changes`
|
||||
|
||||
Holder changes (new, exited, increased, decreased) between two KSEI release dates, optionally for one ticker. Rows come largest change first, one page at a time: `summary` covers all of them (counts by type, tickers with the most changes), and `next_offset` is the `offset` for the next page, or null after the last.
|
||||
|
|
@ -162,3 +171,9 @@ Search investor names in the KSEI ownership database.
|
|||
| --- | --- | --- | --- |
|
||||
| `limit` | integer | no | Maximum results (default 20, at most 100). |
|
||||
| `query` | string | yes | Full-text query over investor names. |
|
||||
|
||||
## `stockbit_status`
|
||||
|
||||
Whether a Stockbit session is stored (or seeded by IDX_STOCKBIT_REFRESH_TOKEN) and when its tokens expire; never the tokens. Without one, get_orderbook fails and stockbit-provider quotes use Stockbit's delayed public page; the user adds one with `idx stockbit login` in a terminal.
|
||||
|
||||
No inputs.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ in scripts. Ask for JSON with `-o json`, `IDX_OUTPUT=json`, or
|
|||
```toml
|
||||
[general]
|
||||
provider = "msn" # msn | yahoo | stockbit
|
||||
history_provider = "auto" # auto | yahoo | msn
|
||||
history_provider = "auto" # auto | yahoo | msn | stockbit
|
||||
exchange = "JK"
|
||||
output = "auto" # auto | table | json | jsonl
|
||||
color = true
|
||||
|
|
@ -56,6 +56,8 @@ fundamental_ttl = 3600
|
|||
| `IDX_CACHE_FUNDAMENTAL_TTL` | `cache.fundamental_ttl` |
|
||||
| `IDX_OWNERSHIP_SNAPSHOT_MANIFEST` | `ownership.snapshot_manifest` |
|
||||
| `IDX_CURL_IMPERSONATE_BIN` | path to a `curl_chrome*` binary |
|
||||
| `IDX_STOCKBIT_REFRESH_TOKEN` | seeds a [Stockbit session](/cli/stockbit/#with-your-stockbit-login) when none is stored |
|
||||
| `IDX_STOCKBIT_ACCESS_TOKEN` | seeds the session's access token |
|
||||
|
||||
## Files idx keeps
|
||||
|
||||
|
|
@ -64,6 +66,7 @@ fundamental_ttl = 3600
|
|||
| Config | `~/.config/idx/config.toml` |
|
||||
| Cache | `~/.cache/idx/` (`idx cache info`, `idx cache clear`) |
|
||||
| Ownership database | `~/.local/share/idx/ownership.db` |
|
||||
| Stockbit session (after `idx stockbit login`) | `~/.config/idx/stockbit-session.json`, owner-only |
|
||||
|
||||
The MCP server reads the same config, cache and database.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue