{"id":47912592,"url":"https://github.com/voidful/tw-institutional-stocker","last_synced_at":"2026-04-04T05:24:06.436Z","repository":{"id":323958513,"uuid":"1094270309","full_name":"voidful/tw-institutional-stocker","owner":"voidful","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-30T03:45:17.000Z","size":161687,"stargazers_count":206,"open_issues_count":0,"forks_count":81,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-03-30T06:04:53.668Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://eric-lam.com/tw-institutional-stocker/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voidful.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-11T13:41:44.000Z","updated_at":"2026-03-30T03:45:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/voidful/tw-institutional-stocker","commit_stats":null,"previous_names":["voidful/tw-institutional-stocker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/voidful/tw-institutional-stocker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voidful%2Ftw-institutional-stocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voidful%2Ftw-institutional-stocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voidful%2Ftw-institutional-stocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voidful%2Ftw-institutional-stocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voidful","download_url":"https://codeload.github.com/voidful/tw-institutional-stocker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voidful%2Ftw-institutional-stocker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31388714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T05:24:02.178Z","updated_at":"2026-04-04T05:24:06.431Z","avatar_url":"https://github.com/voidful.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tw_institutional_stocker\n\n台股三大法人持股比重追蹤（上市 + 上櫃），自動每日更新並發佈到 GitHub Pages。\n\n## 新版重點\n\n- 支援多個變化視窗：`WINDOWS = [5, 20, 60, 120]`\n  - 產出：\n    - `docs/data/top_three_inst_change_5_up.json` / `..._down.json`\n    - `docs/data/top_three_inst_change_20_up.json` / ...\n    - `docs/data/top_three_inst_change_60_up.json` / ...\n    - `docs/data/top_three_inst_change_120_up.json` / ...\n  - 前端可透過下拉選單切換視窗。\n\n- 三大法人模型升級：\n  - 外資：仍採官方 `foreign_ratio`。\n  - 投信 / 自營商：支援「基準點校正」：\n    - 準備 `data/inst_baseline.csv`，格式：\n      ```csv\n      date,code,trust_shares_base,dealer_shares_base\n      2025-01-31,2330,100000000,20000000\n      2025-01-31,0050,50000000,0\n      ```\n    - 模型在每檔股票內以日期排序，若遇到 baseline：\n      - 設 `trust_shares_est = baseline_trust + sum(trust_net since baseline)`\n      - 設 `dealer_shares_est = baseline_dealer + sum(dealer_net since baseline)`\n    - 若完全沒有 baseline，則退化為純 cumsum 模型：\n      - `trust_shares_est = cumsum(trust_net)`\n      - `dealer_shares_est = cumsum(dealer_net)`\n\n## 結構概覽\n\n- `update_all.py`\n  - 從 TWSE / TPEX 抓取：\n    - 三大法人每日買賣超（上市 T86 + 上櫃 3itrade_hedge_result）\n    - 外資持股統計（上市 MI_QFIIS + 上櫃 QFII）\n  - 以 `inst_baseline.csv` 為基準點，搭配日淨買超推估投信 / 自營商持股。\n  - 計算三大法人持股比重與多個視窗的變化值。\n  - 匯出：\n    - `docs/data/timeseries/{code}.json`\n    - `docs/data/top_three_inst_change_{w}_up.json` / `..._down.json`\n\n- `docs/`\n  - 靜態前端（index.html + script.js + style.css）\n  - 提供：\n    - 隨輸入代碼動態載入該股三法人持股時序。\n    - 以 5 / 20 / 60 / 120 日變化排序的排名表，可點擊列載入該股圖。\n    - 市場過濾（全部 / TWSE / TPEX）與 log scale 切換。\n\n- `.github/workflows/update.yml`\n  - 每天 00:10 UTC 由 GitHub Actions 執行 `python update_all.py`\n  - 若 `data/` 或 `docs/data/` 有變動，會自動 commit + push 回 main 分支。\n\n## 本地開發\n\n```bash\npip install -r requirements.txt\npython update_all.py\n```\n\n執行完後，`docs/data/` 底下會長出 json 檔，直接用 `python -m http.server` 或 VSCode Live Server 打開 `docs/index.html` 即可預覽。\n\n若要啟用「基準點校正」：\n1. 從投信 / 自營商的財報或官方持股統計整理出某幾個日期的「實際持股股數」。\n2. 填入 `data/inst_baseline.csv`。\n3. 重新跑 `python update_all.py`。之後 GitHub Actions 自動更新也會沿用這些 baseline。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoidful%2Ftw-institutional-stocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoidful%2Ftw-institutional-stocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoidful%2Ftw-institutional-stocker/lists"}