wm-finpipe 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. wm_finpipe-1.1.0/LICENSE +154 -0
  2. wm_finpipe-1.1.0/PKG-INFO +409 -0
  3. wm_finpipe-1.1.0/README.md +373 -0
  4. wm_finpipe-1.1.0/pyproject.toml +80 -0
  5. wm_finpipe-1.1.0/setup.cfg +4 -0
  6. wm_finpipe-1.1.0/src/finpipe/__init__.py +30 -0
  7. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/corp.equity.yaml +21 -0
  8. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/disc.bonus.yaml +183 -0
  9. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/disc.events.yaml +91 -0
  10. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/disc.filings.yaml +39 -0
  11. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/disc.notice.yaml +160 -0
  12. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/fund.indicators.yaml +161 -0
  13. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/fund.statements.yaml +77 -0
  14. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/market.kline.yaml +223 -0
  15. wm_finpipe-1.1.0/src/finpipe/_catalog/domains/market.moneyflow.yaml +73 -0
  16. wm_finpipe-1.1.0/src/finpipe/_catalog/generated/inventory.json +4684 -0
  17. wm_finpipe-1.1.0/src/finpipe/_catalog/generated/metrics.json +8795 -0
  18. wm_finpipe-1.1.0/src/finpipe/_catalog/schema/domain.schema.json +128 -0
  19. wm_finpipe-1.1.0/src/finpipe/_experience.py +26 -0
  20. wm_finpipe-1.1.0/src/finpipe/api/__init__.py +676 -0
  21. wm_finpipe-1.1.0/src/finpipe/api/_generated.py +1093 -0
  22. wm_finpipe-1.1.0/src/finpipe/catalog.py +244 -0
  23. wm_finpipe-1.1.0/src/finpipe/client.py +516 -0
  24. wm_finpipe-1.1.0/src/finpipe/errors.py +71 -0
  25. wm_finpipe-1.1.0/src/finpipe/py.typed +0 -0
  26. wm_finpipe-1.1.0/src/finpipe/units.py +198 -0
  27. wm_finpipe-1.1.0/src/wm_finpipe.egg-info/PKG-INFO +409 -0
  28. wm_finpipe-1.1.0/src/wm_finpipe.egg-info/SOURCES.txt +44 -0
  29. wm_finpipe-1.1.0/src/wm_finpipe.egg-info/dependency_links.txt +1 -0
  30. wm_finpipe-1.1.0/src/wm_finpipe.egg-info/requires.txt +11 -0
  31. wm_finpipe-1.1.0/src/wm_finpipe.egg-info/top_level.txt +1 -0
  32. wm_finpipe-1.1.0/tests/test_api.py +230 -0
  33. wm_finpipe-1.1.0/tests/test_api_design.py +297 -0
  34. wm_finpipe-1.1.0/tests/test_audit.py +82 -0
  35. wm_finpipe-1.1.0/tests/test_catalog.py +100 -0
  36. wm_finpipe-1.1.0/tests/test_client.py +221 -0
  37. wm_finpipe-1.1.0/tests/test_contract.py +145 -0
  38. wm_finpipe-1.1.0/tests/test_docs.py +433 -0
  39. wm_finpipe-1.1.0/tests/test_drift.py +43 -0
  40. wm_finpipe-1.1.0/tests/test_examples.py +88 -0
  41. wm_finpipe-1.1.0/tests/test_live.py +394 -0
  42. wm_finpipe-1.1.0/tests/test_openapi.py +83 -0
  43. wm_finpipe-1.1.0/tests/test_swagger.py +39 -0
  44. wm_finpipe-1.1.0/tests/test_transport.py +234 -0
  45. wm_finpipe-1.1.0/tests/test_typed.py +108 -0
  46. wm_finpipe-1.1.0/tests/test_units.py +249 -0
@@ -0,0 +1,154 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ Required Notice: Copyright (c) 2026 finpipe contributors
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
14
+
15
+ ## Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
18
+
19
+ ## Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
22
+
23
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ ## Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ ## Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ ## Noncommercial Purposes
34
+
35
+ Any noncommercial purpose is a permitted purpose.
36
+
37
+ ## Personal Uses
38
+
39
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
40
+
41
+ ## Noncommercial Organizations
42
+
43
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
44
+
45
+ ## Fair Use
46
+
47
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
52
+
53
+ ## Patent Defense
54
+
55
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
56
+
57
+ ## Violations
58
+
59
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
60
+
61
+ ## No Liability
62
+
63
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
64
+
65
+ ## Definitions
66
+
67
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
68
+
69
+ **You** refers to the individual or entity agreeing to these terms.
70
+
71
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
72
+
73
+ **Your licenses** are all the licenses granted to you for the software under these terms.
74
+
75
+ **Use** means anything you do with the software requiring one of your licenses.
76
+
77
+ Standard License Header
78
+
79
+ There is no standard license header for the license
80
+
81
+ <<beginOptional>># PolyForm Noncommercial License 1.0.0
82
+
83
+ <<endOptional>>
84
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
85
+
86
+ ## Acceptance
87
+
88
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
89
+
90
+ ## Copyright License
91
+
92
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
93
+
94
+ ## Distribution License
95
+
96
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
97
+
98
+ ## Notices
99
+
100
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
101
+
102
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
103
+
104
+ ## Changes and New Works License
105
+
106
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
107
+
108
+ ## Patent License
109
+
110
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
111
+
112
+ ## Noncommercial Purposes
113
+
114
+ Any noncommercial purpose is a permitted purpose.
115
+
116
+ ## Personal Uses
117
+
118
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
119
+
120
+ ## Noncommercial Organizations
121
+
122
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
123
+
124
+ ## Fair Use
125
+
126
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
127
+
128
+ ## No Other Rights
129
+
130
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
131
+
132
+ ## Patent Defense
133
+
134
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
135
+
136
+ ## Violations
137
+
138
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
139
+
140
+ ## No Liability
141
+
142
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
143
+
144
+ ## Definitions
145
+
146
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
147
+
148
+ **You** refers to the individual or entity agreeing to these terms.
149
+
150
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
151
+
152
+ **Your licenses** are all the licenses granted to you for the software under these terms.
153
+
154
+ **Use** means anything you do with the software requiring one of your licenses.
@@ -0,0 +1,409 @@
1
+ Metadata-Version: 2.4
2
+ Name: wm-finpipe
3
+ Version: 1.1.0
4
+ Summary: A 股个股数据 Python SDK:随包内置机器可读数据目录 + 云端取数客户端(开箱即用,内置体验 appid)
5
+ Author: finpipe contributors
6
+ License-Expression: PolyForm-Noncommercial-1.0.0
7
+ Project-URL: Homepage, https://github.com/open-winmale/finpipe
8
+ Project-URL: Documentation, https://github.com/open-winmale/finpipe/blob/main/docs/API.md
9
+ Project-URL: Issues, https://github.com/open-winmale/finpipe/issues
10
+ Keywords: A股,stock,finance,financial-data,quant,dividend,kline,financial-statements,screener,sdk,china-stock,pandas,market-data
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Office/Business :: Financial :: Investment
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests>=2.28
27
+ Requires-Dist: PyYAML>=6
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7; extra == "dev"
30
+ Requires-Dist: pytest-cov>=5; extra == "dev"
31
+ Requires-Dist: jsonschema>=4; extra == "dev"
32
+ Requires-Dist: mypy>=1.8; extra == "dev"
33
+ Provides-Extra: dataframe
34
+ Requires-Dist: pandas>=1.5; extra == "dataframe"
35
+ Dynamic: license-file
36
+
37
+ # wm-finpipe
38
+
39
+ [![CI](https://github.com/open-winmale/finpipe/actions/workflows/ci.yml/badge.svg)](https://github.com/open-winmale/finpipe/actions/workflows/ci.yml)
40
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-blue)](pyproject.toml)
41
+ [![License: PolyForm Noncommercial](https://img.shields.io/badge/License-PolyForm_NC_1.0-blue)](./LICENSE)
42
+ [![Types: py.typed](https://img.shields.io/badge/Types-py.typed-blue)](src/finpipe/py.typed)
43
+
44
+ > **English TL;DR** — `wm-finpipe` is a source-available Python SDK for A-share market data:
45
+ > k-line (3 adjustment modes), money flow, the three financial statements, 2,197 metric codes
46
+ > (historical & industry percentiles, TTM dividend analytics, technical screens), announcements,
47
+ > dividend history & high-dividend screeners. Ships a machine-readable offline catalog,
48
+ > unified base units with per-response data guards (ratios as decimals, money in CNY,
49
+ > volume in shares), a typed facade, and a zero-config trial AppID.
50
+ > **Install from source** (PyPI release is pending): `git clone` the repo, `pip install .`,
51
+ > then `finpipe.Client()`. Free for non-commercial use; commercial use requires a separate
52
+ > license. See the [English quick start](#english-quick-start).
53
+
54
+ > **⚠️ 许可声明(请先阅读)**:本项目采用
55
+ > [PolyForm Noncommercial 1.0.0](LICENSE) 许可,**属于 source-available(源码可见),
56
+ > 不是 OSI 定义的开源软件**。个人学习、研究等非商业使用完全免费;商业使用需另行授权。
57
+
58
+ A 股个股数据 Python SDK(**A股为主,港股/美股部分支持**——K 线与档案等部分接口已覆盖,
59
+ 详见目录)。注册即得充足免费额度;源码安装后即可取数,无需任何配置
60
+ (代码中 `import finpipe`)。当前尚未发布到 PyPI,请使用「安装」一节的源码方式。
61
+
62
+ ```python
63
+ import finpipe
64
+
65
+ cli = finpipe.Client() # 零配置:内置体验 appid 自动启用
66
+
67
+ cli.kline.bars("600519", n=30) # 日 K(不复权)
68
+ cli.kline.bars("600519", n=30, adj="qfq") # 前复权 / "hfq"=后复权
69
+ cli.statements.income("600519", years=5) # 利润表(合并口径,多期)
70
+ cli.dividend.history("600519", limit=10) # 分红历史明细
71
+ cli.dividend.yield_ttm("600519") # TTM 股息率(小数)
72
+ cli.indicator.get("600519", "$PE_TTM_LAST") # 平台指标(TTM 市盈率)
73
+ cli.notice.list("600519", window="3m") # 公告
74
+ cli.info.profile("600519") # 公司档案
75
+ ```
76
+
77
+ ## 为什么选择 finpipe
78
+
79
+ - **免费额度充足**——注册开放平台账号即得免费额度,个人学习、研究等非商业用途完全免费且
80
+ 足够使用(具体额度以开放平台为准)。
81
+ - **开箱即用**——SDK 内置体验 appid,`Client()` 零配置即可取数;正式使用换成自己的 appid。
82
+ - **目录随包、离线可查**——155 个底层函数、44 个核心接口、2197 个指标代码随 wheel 分发,
83
+ 断网也能查全部接口合同。类型支持说明:目录命名空间与生成层带类型签名(`py.typed`),
84
+ 44 个核心接口的方法有显式签名;其余底层函数经动态委托访问,IDE 补全以目录为准:
85
+
86
+ ```python
87
+ import finpipe
88
+
89
+ cat = finpipe.load() # 离线数据目录(纯本地读文件,零网络)
90
+ hits = cat.search("股息") # 跨 155 个函数 + 2197 个指标代码混合检索
91
+ cat.function("bonus.snapshot_yield_ttm")["params"] # 任意函数的参数/返回/示例
92
+ ```
93
+
94
+ 目录对象的全部方法见 [docs/API.md](docs/API.md) 的「数据目录(离线)」一节。
95
+ - **单位统一、自动换算**——全库基础单位:比率/涨跌幅=小数(0.332 = 33.2%)、
96
+ 金额/价格/市值=元(报表原币)、股数/成交量=股。上游脚本的原生口径(百分数、手等)
97
+ 由 SDK 统一换算,你不需要再处理「这个接口是百分数、那个是小数」的问题;
98
+ 特殊需要时 `_units="native"` / `_raw=True` 可取脚本原值(见「数据正确性保障」)。
99
+ - **财报按最新会计准则归一**——新旧会计准则的科目差异在平台内部完成适配,输出口径一致,
100
+ 可直接做跨年、跨公司比较。
101
+ - **数据面完整**——K 线、资金流、三大报表、指标、公告、定期报告、业绩预告/快报、分红、
102
+ 公司档案,一个 SDK 覆盖个股研究常用数据。
103
+
104
+ ## 数据能力详解
105
+
106
+ ### 行情 K 线
107
+
108
+ - **三种复权**:不复权 `nr`(默认)、前复权 `qfq`、后复权 `hfq`;复权与不复权输出字段一致
109
+ (date/open/high/low/close/volume/amount/percent),可直接穿插使用。
110
+ - **最新与盘中**:最新一根日 K;盘中快照(单票 `live` / 多标的 `batch_live`,单次请求);
111
+ 当日 1 分钟分时(`min1`,有损合成采样,非逐笔,休市读上一交易日)。
112
+ - **ETF 与指数**:ETF 日线已入库;指数键自动桥接指数点位(指数无复权)。
113
+ - **筛选与全景**(底层目录能力,`cli.call`):均线类(MA20/60/120、突破)、
114
+ 事件类(涨停/跌停/放量/回踩)筛选;全市场涨跌全景、涨跌榜、涨跌幅分桶。
115
+ - **回测口径**:财报季取数不因披露进度截断;日频回测口径按已披露数据截断。
116
+ - **日期区间**:`bars(..., begin="2026-01-01", end="2026-06-30")` 按自然日筛选
117
+ (最多 5 年;单次取数受 `max_limit` 约束,覆盖不足会明确报错,不会静默截断)。
118
+ - 单位:价格=元,量=**股**(脚本原生为手,SDK 自动 ×100 换算,A 股/港美/ETF 同口径),
119
+ 额=元,涨跌幅=小数(0.01 = 1%)。
120
+ - 标的代码自动归一:`sh.600519.SH`、`cn.000001` 均可直接传入。
121
+
122
+ ### 资金流向
123
+
124
+ - 日频主力/超大单/大单/中单/小单净流入;最新一行;盘中快照。
125
+ - **日期区间**:`bars(..., begin=..., end=...)`,规则与 K 线一致(最多 5 年)。
126
+ - 口径说明:单子分级聚合,**非 Level2 逐笔委托**。
127
+
128
+ ### 财务报表
129
+
130
+ - **三大报表**(资产负债 / 利润 / 现金流)多期透视,默认 5 期年报降序,也可指定年份。
131
+ - **合并 vs 母公司**:分别取数(`scope=`);`compare()` 直接返回合并值/母公司值/差额/
132
+ 差额占比(占比 = 差额 / 合并值,**小数**口径,0.078 = 7.8%;母公司未披露的科目差额为空)。
133
+ - **树视图**:`tree()` 按报表树序输出,含派生比率行(流动比率、资产负债率、毛利率等);
134
+ 树视图派生行保留原生口径(pct 行为百分数、`fmt="x"` 行为倍数、科目行为元),
135
+ 适合展示核对,跨接口运算请用 `compare()`。
136
+ - **审计意见**:`audit()` 按年报返回 `{年份: 意见}`。
137
+ - **可用年份**:`years()` 返回该报表可用的年报年份(降序)。
138
+ - **新旧会计准则口径已归一**:跨年比较不需要自己调整科目。
139
+ - 金额=报表原币(A 股为元)。
140
+
141
+ ### 指标层
142
+
143
+ - **11 个指标组、74 个精选常用指标代码**(全量 2197 个指标代码随包):估值、盈利与杜邦、
144
+ 成长、营收与利润规模、现金流、资产负债与偿债、运营效率、分红、行情与风险、公司信息、
145
+ 收入构成。
146
+ - **常用指标开箱即用**:PE/PB/PS/PCF、ROE/ROIC/杜邦分解、TTM 同比与多年年化、
147
+ 周转天数与现金周期、费用率、市值与年化收益。
148
+ - **口径标注**:`_LAST` = 最新截面;指标层比率类为**小数**(0.332 = 33.2%)、
149
+ 金额/市值为**元**(与报表、资金流同口径,可直接混算);业绩预告的同比/幅度字段
150
+ 也已由 SDK 统一换算为小数——全库不再有「有的接口是百分数」的问题。
151
+ - **经营与财务多口径**:合并/母公司、单期/多期/TTM、披露原值/派生指标;
152
+ 收入构成提供境内/境外收入占比与对应毛利率(产品线/业务分部口径一期未纳入)。
153
+
154
+ ### 公告
155
+
156
+ - 检索:单票(`list`)、全市场近期(`recent`)、按类别(`by_category`)、
157
+ 指定日期全市场(`on_date`)、单票日期区间(`find`)。
158
+ - 信号:回购、减持、增持、股权激励的窗口判定,并返回**证据行**(原始公告可回溯)。
159
+ - 时间窗口:`7d` / `1m` / `3m` / `6m` / `1y` / `3y` / `5y` 或天数整数。
160
+
161
+ ### 定期报告
162
+
163
+ - 年报 / 半年报 / 季报清单:报告期、标题、PDF 链接。
164
+ - 分工:结构化科目数字走财务报表,原文链接走本域。
165
+
166
+ ### 业绩披露事件
167
+
168
+ - **业绩预告**:净利/扣非/营收区间 + 同比 + 修正轨迹。
169
+ - **业绩快报**:披露的近似单值。
170
+ - **预约披露日历**:`disclosure_history()` 历史与 `next_disclosure()` 下次披露日期。
171
+
172
+ ### 分红
173
+
174
+ - **历史明细**:扁平规范化字段(公告日/除权日/派息日/每股分红/分红总额/方案摘要),
175
+ 支持按除权日的日期区间筛选(最多 5 年);最近一次;指定报告期。
176
+ - **每股分红**:财报期 DPS(元/股)。
177
+ - **窗口统计**:`window_stats()` 单次返回任意窗口(7d/1m/3m/6m/1y/3y/5y 或天数)的
178
+ 每股股利合计、总分红金额与分红次数(按除权日统计)。
179
+ - **TTM 股息率 / 派息率**:小数口径(0.0396 = 3.96%,0.799 = 79.9%)。
180
+ - **质量筛选**:高股息、派息可持续性、股息稳定性/趋势/改善、低估+高股息。
181
+ - 列表与 DPS 为披露原值,率类与筛选为计算派生(逐函数标注)。
182
+
183
+ ### 股本与公司档案
184
+
185
+ - 公司档案:名称、行业、组织类型、上市日期。
186
+ - 股本变动数据;F10 深度页(十大股东/质押/解禁等)一期未纳入。
187
+
188
+ ## 指标体系:算好的增值数据
189
+
190
+ 2197 个指标代码不只是"字段多"——大量派生口径是平台服务端算好直出的,
191
+ **你不用自己拉原始数据再做计算**。按用途分成 11 组(见 [docs/API.md](docs/API.md) 指标组表),
192
+ 几个最有代表性的能力:
193
+
194
+ **我想做 X → 用哪一行**
195
+
196
+ | 我想做… | 一行接口 | 省掉的计算 |
197
+ |---|---|---|
198
+ | 看 TTM 股息率 | `cli.dividend.yield_ttm(sym)` | 拉全部分红史→截 TTM 窗→查市值→相除 |
199
+ | 判断估值贵不贵 | `cli.indicator.get(sym, "$PCT_PE_TTM_10Y_LAST")` | 拉十年估值史自己算百分位 |
200
+ | 看公司在行业里的位置 | `$CUR_IND_ROE_PCT_LAST`(行业内 ROE 分位) | 拉全行业成分→逐票取 ROE→排序 |
201
+ | 筛高股息且派息可持续 | `cli.dividend.screen_quality(sym)` | 自写股息/派息率质量模型 |
202
+ | 站上 20 日线了吗 | `cli.kline.screen_above_ma20(sym)` | 拉 K 线→算均线→比较 |
203
+ | 全市场今天涨跌如何 | `cli.kline.index_breadth_summary("index.cn.all")` | 全市场扫描→聚合统计 |
204
+ | 近半年有无回购/减持 | `cli.notice.has_buyback(sym, "6m")` | 拉公告列表→分类匹配→截窗 |
205
+ | 合并与母公司差多少 | `cli.statements.compare(sym)` | 双表对齐→逐科目相除 |
206
+
207
+ **示例(输出为预期量级,单位口径与全库一致)**:
208
+
209
+ ```python
210
+ import finpipe
211
+
212
+ cli = finpipe.Client.from_env()
213
+
214
+ # TTM 股息率:小数口径,0.0396 = 3.96%
215
+ print(cli.dividend.yield_ttm("600519")) # 0.0396
216
+
217
+ # 估值温度计:PE(TTM) 处于近 10 年 42% 分位(小数)
218
+ print(cli.indicator.get("600519", "$PCT_PE_TTM_10Y_LAST")) # 0.42
219
+
220
+ # 行业定位:ROE 位于同行业前 8% 分位(小数,越小越靠前)
221
+ print(cli.indicator.get("600519", "$CUR_IND_ROE_PCT_LAST")) # 0.08
222
+
223
+ # 技术面一行布尔:是否站上 20 日均线
224
+ print(cli.kline.screen_above_ma20("600519")) # True
225
+
226
+ # 分红质量:高股息 + 派息可持续
227
+ print(cli.dividend.screen_quality("600519")) # True
228
+
229
+ # 公告信号:近 6 个月是否有回购公告
230
+ print(cli.notice.has_buyback("600519", "6m")) # True
231
+ ```
232
+
233
+ ### 指标体系的四类特色能力
234
+
235
+ 1. **专业的股息计算**——`yield_ttm` / `payout_ttm` 一键快照(TTM 分红总额÷最新市值、
236
+ TTM 分红÷归母净利 TTM);11 个单票质量筛选器(高股息、派息可持续、股息稳定/改善/下滑、
237
+ 低估+高股息…);18 个全市场筛选积木(如 `bonus.index_where_high_yield_5()` = 连续 5 年
238
+ 高股息股票池);背后还有 60 个分红衍生指标(近 3/5/10 年分红均值/最低/趋势)。
239
+ 2. **分位计算**——历史分位:PE/PB/股息率的 3/5/10 年分位(`$PCT_PE_TTM_10Y_LAST` 等,
240
+ 估值温度计);行业分位:192 个 CUR_IND 前缀的行业内相对指标
241
+ (如 `$CUR_IND_ROE_PCT_LAST`:ROE/毛利率/营收/市值分位)。
242
+ 都是服务端一次取数直出,不用拉十年历史或全行业成分自算。
243
+ 3. **窗口化衍生口径**——TTM 口径 586 个、同比 68 个、3/5/10 年年化/均值/最低/趋势 394 个;
244
+ 命名窗口(`7d`…`5y` 或天数)在分红/公告域通用,未知 token 显式报错。
245
+ 4. **服务端算好的筛选与汇总**——14 个技术面筛选(均线/动量/量比/涨跌停,一行布尔)+
246
+ 6 个全市场宽度汇总(涨跌全景/分桶/行业分布/涨跌榜);公告域的回购/减持/增持/股权激励
247
+ 窗口判定与证据行;财报域的合并 vs 母公司差额占比与杜邦分解。
248
+ 另有约 224 个宏观/行业横截面指标(CPI/PPI/M2/用电量/社零…)与 54 个指数加权指标
249
+ (等权/市值/调和加权股息率、相对指数 Alpha/Beta),行业层面数据不必另找源。
250
+
251
+ 以上能力全部在离线目录可查:`cat.search("分位")`、`cat.metrics_in_group("dividend")`。
252
+
253
+ ## 数据正确性保障
254
+
255
+ 单位问题曾让用户把 3.96% 读成 0.04%。finpipe 用三层机制保证你拿到的数据量级正确,
256
+ 而不是靠"文档约定":
257
+
258
+ 1. **脚本原值 → SDK 单点换算**——上游脚本永远输出其原生口径(如差额占比百分数、
259
+ A 股成交量手);SDK 在 `call()` 里按目录声明做**唯一的**一次换算,转成基础单位
260
+ (比率小数、金额元、股数股)。换算规则集中在随包目录的 YAML 声明里,可审计、可追溯。
261
+ 2. **返回前校验**——换算后立即执行目录声明的量级范围守护与关系不变量(如
262
+ `diffp ≈ 差额/合并值`、`volume×close ≈ amount`)。违例直接抛
263
+ `DataError`(含字段/实际值/期望范围),**错误的量级到不了你的代码里**;
264
+ 换算声明写错也会被数据本身自动暴露。
265
+ 3. **持续审计**——`tools/audit_units.py` 对一组覆盖不同板块/行业/规模的样本公司
266
+ 逐家跑全部守护与跨接口一致性(如 `dividend.yield_ttm` 与 `$BONUS_RATE_TTM_LAST`
267
+ 恒等、指标层市值与 K 线快照同量级);CI 每个交易日夜间自动执行,口径漂移会在
268
+ 日志中显式报告。
269
+
270
+ 校验默认开启。三种逃生口(有测试守护其语义):
271
+
272
+ | 参数 | 语义 |
273
+ |---|---|
274
+ | `_units="native"` | 保留脚本输出的原生单位(字段名仍规范化),换算与校验都跳过 |
275
+ | `_raw=True` | 返回 store 原始行(连字段规范化也跳过) |
276
+ | `Client(validate=False)` | 保留换算、关闭量级/不变量校验 |
277
+
278
+ ## 口径速查
279
+
280
+ | 维度 | 取值 | 说明 |
281
+ |---|---|---|
282
+ | 复权 | `nr` / `qfq` / `hfq` | 指数无复权 |
283
+ | 报表范围 | 合并 / 母公司 / 差额 | 差额与占比为派生值(占比已换算为小数) |
284
+ | 期间 | 单期 / 多期 / TTM | TTM = 最近四个季度滚动 |
285
+ | 数据性质 | 原始数据 / 指标 | 逐函数标注,可回溯目录 |
286
+ | 会计准则 | 新旧准则已归一 | 平台内部适配 |
287
+ | 价格 / 金额 / 市值 | 元 | 报表原币;指标层与报表同口径,可直接混算 |
288
+ | 成交量 | 股 | A 股/港美/ETF 同口径(脚本手原值由 SDK 自动 ×100) |
289
+ | 涨跌幅 / 比率 | 小数 | 0.01 = 1%;0.332 = 33.2%(ROE/毛利率/资产负债率等) |
290
+ | 业绩预告同比 | 小数 | 脚本原生百分数已由 SDK 自动换算(1.467 = 146.7%) |
291
+ | 分红率 | 小数 | 0.0396 = 3.96% |
292
+ | 数据守护 | 每次返回默认校验 | 违例抛 `DataError`;逃生口见「数据正确性保障」 |
293
+ | 时间窗口 | `7d`…`5y` 或天数 | 分红/公告;最大 5 年,未知 token 显式报错 |
294
+ | 日期区间 | `begin` / `end` | 含端点,最多 5 年;覆盖不足会报错 |
295
+
296
+ ## 安装
297
+
298
+ 当前尚未发布到 PyPI,请从源码安装:
299
+
300
+ ```bash
301
+ git clone https://github.com/open-winmale/finpipe.git
302
+ cd finpipe
303
+ pip install . # 基础安装
304
+ pip install ".[dataframe]" # 可选:pandas 支持(_df=True)
305
+ ```
306
+
307
+ 开发/贡献者安装:`pip install -e ".[dev,dataframe]"`。
308
+ PyPI 发布后可直接 `pip install wm-finpipe`,届时会更新本节与 README 徽章。
309
+
310
+ ## 免费额度与凭证
311
+
312
+ **个人学习、研究等非商业使用完全免费**。注册开放平台账号即可获得免费额度,个人研究足够使用;
313
+ 具体额度以开放平台为准。商业使用需另行授权(见「使用限制」)。
314
+
315
+ SDK 内置体验 AppID,安装即用,但它是共享池、额度有限,仅供初次体验。正式使用建议申请
316
+ 自己的 AppID(额度更充足):
317
+
318
+ 1. 打开 [赢麻了开放平台](https://open.winmale.com),扫码微信登录注册;
319
+ 2. 点击右上角「我的」,进入「开放平台」;
320
+ 3. 左侧导航「我的应用」→「查看应用信息」,即可查看 `client_id` 与 api-key(即 `client_secret`)。
321
+
322
+ 拿到自己的 AppID 后任选一种配置方式:
323
+
324
+ ```bash
325
+ # 方式一:环境变量
326
+ export FINPIPE_CLIENT_ID=...
327
+ export FINPIPE_CLIENT_SECRET=...
328
+
329
+ # 方式二:凭证文件 ~/.finpipe/credentials.env(KEY=VALUE 每行一条)
330
+ ```
331
+
332
+ 也可以在代码中直接传入:`finpipe.Client(client_id=..., client_secret=...)`。
333
+ 不配置时自动使用内置体验 AppID。
334
+
335
+ ### 遇到 401 / 403 / 429 怎么办
336
+
337
+ 内置体验 AppID 是多人共享池,可能失效、被撤销或被限流。收到这些错误时请申请自己的 AppID:
338
+
339
+ - **401 / 403** → SDK 抛 `AuthError`(带 `status` 与服务端 `code`,如 `POLICY_DENIED`);
340
+ - **429** → SDK 抛 `LimitError(code="rate_limited")`,消息会带 `Retry-After` 建议;
341
+ - 错误消息本身已包含下面 3 步,程序里可直接 `except finpipe.AuthError` / `except finpipe.LimitError`。
342
+
343
+ 申请步骤:打开 [open.winmale.com](https://open.winmale.com) 微信扫码登录 → 右上角「我的」→
344
+ 「开放平台」→「我的应用」→「查看应用信息」→ 复制 `client_id` 与 api-key;然后按上面的
345
+ 环境变量或 `~/.finpipe/credentials.env` 配置。内置 AppID 只适合初次体验,正式研究请使用
346
+ 自己的 AppID。
347
+
348
+ ## 数据范围(一期,9 个数据域)
349
+
350
+ | 分类 | 数据域 | 性质 |
351
+ |------|--------|------|
352
+ | 市场行情 | 行情K线(日K/复权/盘中快照)、资金流向 | 原始数据 |
353
+ | 财务基本面 | 三大报表(资产负债/利润/现金流)、指标层(2197 个指标代码:估值/盈利/成长/现金流/杜邦…) | 报表=原始数据,指标=派生指标 |
354
+ | 信息披露 | 公告、定期报告清单、业绩预告/快报/披露日历、分红 | 原始数据(率类为指标) |
355
+ | 参考数据 | 公司档案 / 股本 | 原始数据 |
356
+
357
+ **原始数据与指标显式分标**:每个接口在目录中标注 `raw`(披露/直采数据,含外部源算好的)
358
+ 或 `computed`(平台公式计算的派生指标),全量见 [docs/API.md](docs/API.md)。
359
+
360
+ 数据经云端 API 运行时获取(代码与目录开源,数据不随包分发)。
361
+
362
+ > **目录是如何来的?** 随包目录由维护者从上游数据平台同步并冻结进发布物
363
+ > (schema 版本治理,详见 [CONTRIBUTING.md](CONTRIBUTING.md)),发布的是上游指标的**策展子集**。
364
+ > 贡献者无需重建目录即可使用全部功能;如需新增数据域或指标,请提 issue。
365
+
366
+ ## 使用限制(必读)
367
+
368
+ 本项目采用 [PolyForm Noncommercial License 1.0.0](LICENSE):
369
+
370
+ - ✅ **仅限非商业目的**:个人学习、研究、教学、学术、爱好者项目、公益组织等,完全免费;
371
+ - ❌ **严禁商业使用**:任何商业目的的使用、再分发或服务化均需另行获得商业授权;
372
+ - 本许可属于 source-available(源码可见)而非 OSI 定义的开源许可。
373
+
374
+ 商业授权请联系项目维护方。数据仅供研究参考,不构成任何投资建议。
375
+
376
+ ## English quick start
377
+
378
+ ```python
379
+ import finpipe
380
+
381
+ cli = finpipe.Client() # zero config: built-in trial appid
382
+
383
+ bars = cli.kline.bars("600519", n=30) # daily k-line (price in CNY, volume in shares)
384
+ yield_ttm = cli.dividend.yield_ttm("600519") # TTM dividend yield (decimal: 0.0396 = 3.96%)
385
+ cat = finpipe.load()
386
+ hits = cat.search("股息") # offline search across 2,197 metric codes
387
+ # + 155 functions (default limit = 20)
388
+ ```
389
+
390
+ For non-commercial use the SDK is free (built-in trial AppID, register for your own quota).
391
+ Commercial use requires a license — see [License](#使用限制必读).
392
+ Units are unified to base units: prices/money in CNY, volume in shares, ratios and price
393
+ changes as decimals (0.332 = 33.2%); every response passes declared magnitude guards and
394
+ relational invariants (violations raise `DataError`).
395
+
396
+ ## 更多
397
+
398
+ - [API 参考](docs/API.md):四大类 44 个核心接口(参数 / 返回字段 / 单位口径 / 示例)+ 指标组
399
+ - **OpenAPI / Swagger**:[docs/openapi.json](docs/openapi.json)(OpenAPI 3.1,可导入
400
+ Apifox / Postman 等工具);[docs/swagger.html](docs/swagger.html)(已内联 spec,浏览器直接打开;
401
+ Swagger UI 资源来自 CDN,若浏览器限制 `file://` 可在 docs 目录起 `python -m http.server`)
402
+ - 类型化门面:全部目录命名空间带类型签名与 docstring(`py.typed`),IDE 直接补全;
403
+ 单次拉取上限 `Client(max_limit=500)` 可调
404
+ - 批量调用:`cli.call_batch("kline.query_bars", ["600519", "000001"])` 单次 HTTP 返回
405
+ `{symbol: 结果}`;`on_error="skip"` 时逐标的隔离错误
406
+ - 数据守护:单位换算、量级守护与关系不变量的声明全部在随包目录 YAML 中,
407
+ 维护者可用 `python tools/audit_units.py` 对样本宇宙做单位口径审计(CI 夜间自动执行)
408
+ - [贡献指南](CONTRIBUTING.md):提交门禁、内容规范、许可政策
409
+ - 运行测试:`pytest`(不联网);`FINPIPE_LIVE=1 pytest tests/test_live.py`(真实冒烟)