mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
feat: foreign flow (idx stocks flow, get_foreign_flow)
`idx stocks flow SYMBOL` shows what foreign investors bought and sold of a stock, session by session, from IDX's own daily trading summary: foreign buy, sell and net volume, net value at the session's average price, and the share of value traded outside the regular board, with range totals. Latest 10 sessions by default (--days, at most 60) or --from/--to. The MCP server exposes it as get_foreign_flow. - api/idx: pure parser for GetStockSummary (rows dated another session are dropped) and a provider over curl-impersonate's profile fallback with a 30 s limit; Cloudflare passes only some fingerprints. - flow: each session is cached whole by date, so other stocks' flows for the same sessions need no request. Weekends are never requested. - Idx::idx_code is shared by broker and flow for the .JK-only check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3syn2fN2LNo5pvTSqc6eh
This commit is contained in:
parent
4c2f0acff3
commit
29f143fa1b
40 changed files with 1278 additions and 29 deletions
|
|
@ -123,6 +123,12 @@ contract() {
|
|||
echo '(.highlights | type == "array") and (.risks | type == "array")' ;;
|
||||
"stocks news "*)
|
||||
echo 'type == "array" and all(.[]; (.title | type == "string") and (.url | 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 "*)
|
||||
echo 'type == "array" and length > 0 and all(.[]; (.method | type == "string") and (.tiers | length == 4) and (.imbalance_bps | type == "number"))' ;;
|
||||
"stocks flow "*)
|
||||
echo '(.days | length > 0) and all(.days[]; (.date | type == "string") and (.foreign_buy | type == "number") and (.foreign_sell | type == "number")) and (.foreign_net | type == "number")' ;;
|
||||
"ownership discover"*)
|
||||
echo 'type == "array" and length > 0 and (.[0].pdf_url | type == "string")' ;;
|
||||
"ownership releases")
|
||||
|
|
@ -194,6 +200,12 @@ run_case() {
|
|||
echo " PASS"
|
||||
}
|
||||
|
||||
# A command the --compare binary may predate runs on the new binary only.
|
||||
run_new_case() {
|
||||
local COMPARE_BIN=""
|
||||
run_case "$@"
|
||||
}
|
||||
|
||||
if (( ! DRY_RUN )); then
|
||||
command -v jq >/dev/null 2>&1 || { echo "jq is required; run inside nix develop" >&2; exit 1; }
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
|
@ -217,6 +229,10 @@ if selected stocks; then
|
|||
run_case compare "stocks compare $SYMBOL,BBRI"
|
||||
# BUMI/ADRO/AIMS return non-finite MSN key ratios (Infinity/NaN).
|
||||
run_case compare-nonfinite "stocks compare BUMI,ADRO,AIMS"
|
||||
# Broker summaries (IPOT) and foreign flow (IDX, via curl-impersonate).
|
||||
run_new_case broker "stocks broker $SYMBOL"
|
||||
run_new_case bandar "stocks bandar $SYMBOL,BBRI,TLKM"
|
||||
run_new_case flow "stocks flow $SYMBOL --days 3"
|
||||
fi
|
||||
|
||||
if selected ownership; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue