feat: foreign flow from IPOT by default (--source ipot|idx)

`idx stocks flow` now reads IPOT by default, which needs nothing installed:
per session, the all-investor broker summary gives the value traded and
the foreign one gives foreign buying (its footer), the foreign net and
selling (buying less the net), across all boards, through the broker
summary cache. IPOT's foreign net matched IDX's estimate within 0.3 B on
BBCA 2026-10-12 to 16.

`--source idx` (and `source` on get_foreign_flow) keeps IDX's trading
summary: exact share counts, close and the non-regular share, behind
curl-impersonate and Cloudflare.

- ForeignFlowDay gains foreign_buy_value, foreign_sell_value and
  foreign_share_bps for both sources (estimated at the session average
  for IDX); ForeignFlow gains source, the value totals and rounded.
- The table lays out each source's figures; the live smoke runs both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V3syn2fN2LNo5pvTSqc6eh
This commit is contained in:
hermes 2026-10-18 06:19:02 +00:00
commit 8b507d78e2
37 changed files with 2080 additions and 143 deletions

View file

@ -55,18 +55,25 @@ million and more to one decimal, and the output says so.
idx stocks flow BBCA
idx stocks flow BBCA --days 20
idx stocks flow BBCA --from 2026-10-01 --to 2026-10-16
idx stocks flow BBCA --source idx
```
What foreign investors bought and sold, session by session: buy, sell and
net volume in shares, the net value at each session's average price (an
estimate), and the share of all value traded outside the regular board.
Volume, value and the foreign figures are IDX's regular-board figures. The
footer gives the net over the range and foreign investors' share of trading.
Without dates it shows the latest 10 sessions (`--days`, at most 60).
What foreign investors bought and sold, session by session, with the totals
over the range. Without dates it shows the latest 10 sessions (`--days`, at
most 60).
The data is IDX's own daily trading summary. Each session is one request to
idx.co.id, cached afterwards for every stock, and needs
[curl-impersonate](/start/install/) to pass the site's bot protection.
By default the figures come from Indo Premier (IPOT), like `broker`: foreign
buy, sell and net value across all boards and foreign investors' share of
trading. It needs nothing installed, takes two requests per session, and
rounds figures of a million and more to one decimal.
`--source idx` reads IDX's own daily trading summary instead: exact foreign
share counts, the close and day change, and the share of value traded
outside the regular board. Those figures are the regular board, and values
are estimated at each session's average price. Each session is one request
to idx.co.id, cached for every stock, and needs
[curl-impersonate](/start/install/) and a network IDX's Cloudflare lets
through; even then it can answer 403.
## Bandarmology