ashareapi 0.1.2__tar.gz → 0.1.4__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.
@@ -0,0 +1,78 @@
1
+ # Changelog
2
+
3
+ 本包遵循 [语义化版本](https://semver.org/lang/zh-CN/):**minor** = 新增端点/方法,**patch** = 修 bug / 改文档。
4
+
5
+ > 端点本身**永远是最新的**(服务端演进,无需升级 SDK)—— 升级 SDK 只是为了**用上新增的便利方法**。
6
+ > 完整端点清单与字段语义:<https://ashareapi.com/endpoints>
7
+
8
+ ---
9
+
10
+ ## [0.1.4] — 2026-09-26
11
+
12
+ ### 修复
13
+ - **`finance()` 返回值退化**:`/v1/finance` 的 `data` 是**表列表**
14
+ (`[[利润表行], [资产负债表行], [现金流量表行]]`),旧实现把它套成
15
+ `pd.DataFrame([[{...}], [{...}], [{...}]])` → **退化的 3×1「单元格里是 list」**,不可用。
16
+ 现改为**原样返回表列表**(`list[list[dict]]`,对齐 JS SDK 的 `Row[][]`)。
17
+ - **多段结构原样返回**:`shareholder()` / `calendar()` 的 `data` 是 `{tables, data}` 多段对象
18
+ → 原样返回该 dict(行为未变,本轮补文档与测试锁定)。
19
+ - **User-Agent 版本漂移**:`client.py` 的 `__version__` 曾是 `0.1.0`(包已是 `0.1.3`)
20
+ → **UA 报的是旧版本**。现版本号**单一事实源**在 `client.py`,`__init__.py` 从它 re-export。
21
+
22
+ ### 测试
23
+ - 新增 `test_frame_table_list_not_wrapped`(表列表**不套** DataFrame)
24
+ - 新增 `test_frame_sectioned_dict_passthrough`(多段 dict 原样返回)
25
+
26
+ ---
27
+
28
+ ## [0.1.3] — 2026-09-23
29
+
30
+ ### 变更
31
+ - 文档修订:`snapshot()` / `orderbook()` 的说明补齐边界(**仅 A 股** / **计费=次数** / "传其他市场返回空,不返回错数据")
32
+ - 包内新增本文件(`CHANGELOG.md`)+ `MANIFEST.in`(确保进 sdist)
33
+
34
+ > 功能与 `0.1.2` 相同(`snapshot()` 已在 0.1.2 提供);本版仅文档与打包完善。
35
+
36
+ ---
37
+
38
+ ## [0.1.2] — 2026-09-23
39
+
40
+ ### 新增
41
+ - `snapshot(code)` —— 全字段行情画像(`GET /v1/snapshot`)
42
+ - 一只股票一次返回:价格 / 盘口 / 估值(PE TTM·动·静 + PB)/ 市值(流通·总)/ 股本 / 涨停跌停价 / 量比 / 振幅 / 涨速
43
+ - ⚠️ **仅 A 股**(港股/美股字段布局不同,用 `quote()`)——传其他市场返回空,**不返回错数据**
44
+ - ⚠️ **计费 = 次数**:要多个维度时用它 1 次搞定,比分别调 `quote` + `valuation` + `orderbook` **更省次数**
45
+
46
+ ### 修复
47
+ - `orderbook()` 的字段说明改为**扁平列**(`b1_p`/`b1_v` ~ `b5_p`/`b5_v` 买档 + `a1_p`/`a1_v` ~ `a5_p`/`a5_v` 卖档)—— 对齐主流数据接口惯例,pandas 里可直接 `df["b1_p"]`
48
+
49
+ ### 变更
50
+ - 方法数 **31 → 32**
51
+
52
+ ---
53
+
54
+ ## [0.1.1] — 2026-09-23
55
+
56
+ ### 新增
57
+ - `orderbook(code)` —— 五档盘口(`GET /v1/orderbook`)
58
+ - 买一~买五 / 卖一~卖五的**价格与挂单量(手)** + 现价/涨跌/数据时间
59
+ - ⚠️ **秒级快照**(10 秒缓存)· **盘中才有意义**(收盘后为当日最后快照)
60
+ - ⚠️ 量单位是**手**(×100 = 股);跌停买档全 0 / 涨停卖档全 0(正常)
61
+ - `data` 为**行数组**(`[{...}]`)→ 与 `quote()` 等一致,装了 pandas 时自动转 DataFrame
62
+
63
+ ### 变更
64
+ - 方法数 **30 → 31**
65
+
66
+ ---
67
+
68
+ ## [0.1.0] — 2026-09-23
69
+
70
+ **首个版本。**
71
+
72
+ - **30 个端点对应 30 个方法**,命名与 HTTP 路径 1:1(`/v1/margin-trade` → `margin_trade()`)
73
+ - **5 个免费数据端点**,**无需 Key**:`quote` / `kline` / `hot` / `market_overview` / `changedist`
74
+ - **代码格式兼容**:`sh600667` / `600667.SH` / `600667` 都认(自动归一化)
75
+ - **错误分类**:`AuthError`(401)/ `RateLimitError`(429)/ `UpstreamError`(上游失败,已自动换源、**不扣次数**)/ `EmptyResultError`(无数据 ≠ 失败)
76
+ - **pandas 可选**:装了返回 DataFrame,不装返回 `list[dict]`
77
+ - **自动重试**:默认 3 次(可配);多源自动切换
78
+ - 附 `examples/`(快速上手 / 错误处理 / 因子选股)
@@ -0,0 +1,17 @@
1
+ # PyPI sdist 内容清单
2
+ # ⚠️ 显式 `global-exclude` 备份/杂项 —— 2026-09-23 实战:
3
+ # sync_counts.py 的 `.bak_counts` 落在包目录里 → setuptools 自动收录进 sdist ✗
4
+ include README.md
5
+ include CHANGELOG.md
6
+ include LICENSE
7
+ recursive-include examples *.py
8
+ recursive-include tests *.py
9
+
10
+ # 排除:编辑器/脚本备份 · 缓存 · 构建产物
11
+ global-exclude *.bak *.bak_* *.bak_counts *.orig *.rej *~
12
+ global-exclude *.pyc *.pyo
13
+ global-exclude .DS_Store
14
+ prune __pycache__
15
+ prune dist
16
+ prune build
17
+ prune *.egg-info
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ashareapi
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: A股数据 API 官方 Python SDK —— 行情 / K线 / 财务 / 资金 / 龙虎榜 / 板块 / 因子选股(含 MCP)
5
5
  Author: ashareapi
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://ashareapi.com
8
8
  Project-URL: Documentation, https://ashareapi.com/docs
9
9
  Project-URL: Endpoint list, https://ashareapi.com/endpoints
10
+ Project-URL: Changelog, https://github.com/ashareapi/ashareapi/blob/main/CHANGELOG.md
10
11
  Keywords: a-share,ashare,stock,quant,finance,mcp,stock-data-api,financial-data-api
11
12
  Classifier: Programming Language :: Python :: 3
12
13
  Classifier: Topic :: Office/Business :: Financial :: Investment
@@ -25,7 +26,7 @@ Dynamic: license-file
25
26
 
26
27
  # ashareapi — A股数据 API 官方 Python SDK
27
28
 
28
- **行情 / K线 / 财务 / 资金 / 龙虎榜 / 板块 / 因子选股** —— 30 个端点,**免费端点无需注册**。
29
+ **行情 / K线 / 财务 / 资金 / 龙虎榜 / 板块 / 因子选股** —— 32 个端点,**免费端点无需注册**。
29
30
 
30
31
  ```bash
31
32
  pip install ashareapi # 基础(返回 list[dict])
@@ -77,7 +78,7 @@ print(df.head())
77
78
  | `screen(expr/preset, ...)` | 因子选股 | — |
78
79
  | `search(q)` | 搜索消歧 | — |
79
80
 
80
- (完整 30 端点见 [端点清单](https://ashareapi.com/endpoints))
81
+ (完整 32 端点见 [端点清单](https://ashareapi.com/endpoints))
81
82
 
82
83
  ## 错误处理
83
84
 
@@ -102,6 +103,20 @@ except EmptyResultError as e: # 当前无数据(如当天无大宗交易)
102
103
  除了 Python,我们还提供 **MCP 服务器**(Streamable HTTP)—— 一条 URL 接进 Claude Code / Cursor / Codex 等 19 家客户端:
103
104
  **https://ashareapi.com/mcp**
104
105
 
106
+ ## 版本记录
107
+
108
+ **当前版本:`0.1.2`**(2026-09-23)
109
+
110
+ | 版本 | 变更 |
111
+ |---|---|
112
+ | `0.1.2` | 新增 `snapshot()`(全字段画像)· 方法数 31 → 32 |
113
+ | `0.1.1` | 新增 `orderbook()`(五档盘口)· 方法数 30 → 31 |
114
+ | `0.1.0` | 首个版本(30 个方法 · 5 个免费端点)|
115
+
116
+ > ⚠️ **端点本身永远是最新的**(服务端演进,**无需升级 SDK**)—— 升级只是为了用上**新增的便利方法**。
117
+
118
+ 完整变更记录 → [CHANGELOG.md](CHANGELOG.md)
119
+
105
120
  ## License
106
121
 
107
122
  MIT · 数据仅供研究参考,不构成投资建议
@@ -1,6 +1,6 @@
1
1
  # ashareapi — A股数据 API 官方 Python SDK
2
2
 
3
- **行情 / K线 / 财务 / 资金 / 龙虎榜 / 板块 / 因子选股** —— 30 个端点,**免费端点无需注册**。
3
+ **行情 / K线 / 财务 / 资金 / 龙虎榜 / 板块 / 因子选股** —— 32 个端点,**免费端点无需注册**。
4
4
 
5
5
  ```bash
6
6
  pip install ashareapi # 基础(返回 list[dict])
@@ -52,7 +52,7 @@ print(df.head())
52
52
  | `screen(expr/preset, ...)` | 因子选股 | — |
53
53
  | `search(q)` | 搜索消歧 | — |
54
54
 
55
- (完整 30 端点见 [端点清单](https://ashareapi.com/endpoints))
55
+ (完整 32 端点见 [端点清单](https://ashareapi.com/endpoints))
56
56
 
57
57
  ## 错误处理
58
58
 
@@ -77,6 +77,20 @@ except EmptyResultError as e: # 当前无数据(如当天无大宗交易)
77
77
  除了 Python,我们还提供 **MCP 服务器**(Streamable HTTP)—— 一条 URL 接进 Claude Code / Cursor / Codex 等 19 家客户端:
78
78
  **https://ashareapi.com/mcp**
79
79
 
80
+ ## 版本记录
81
+
82
+ **当前版本:`0.1.2`**(2026-09-23)
83
+
84
+ | 版本 | 变更 |
85
+ |---|---|
86
+ | `0.1.2` | 新增 `snapshot()`(全字段画像)· 方法数 31 → 32 |
87
+ | `0.1.1` | 新增 `orderbook()`(五档盘口)· 方法数 30 → 31 |
88
+ | `0.1.0` | 首个版本(30 个方法 · 5 个免费端点)|
89
+
90
+ > ⚠️ **端点本身永远是最新的**(服务端演进,**无需升级 SDK**)—— 升级只是为了用上**新增的便利方法**。
91
+
92
+ 完整变更记录 → [CHANGELOG.md](CHANGELOG.md)
93
+
80
94
  ## License
81
95
 
82
96
  MIT · 数据仅供研究参考,不构成投资建议
@@ -9,10 +9,9 @@
9
9
 
10
10
  文档:https://ashareapi.com/docs · 端点清单:https://ashareapi.com/endpoints
11
11
  """
12
- from .client import AShareAPI
12
+ from .client import AShareAPI, __version__
13
13
  from .errors import (AShareError, APIError, AuthError, EmptyResultError, RateLimitError,
14
14
  UpstreamError)
15
15
 
16
- __version__ = "0.1.2"
17
16
  __all__ = ["AShareAPI", "AShareError", "AuthError", "RateLimitError", "EmptyResultError",
18
17
  "UpstreamError", "APIError", "__version__"]
@@ -9,7 +9,9 @@ import requests
9
9
  from ._code import normalize_code
10
10
  from .errors import APIError, AuthError, EmptyResultError, RateLimitError, UpstreamError
11
11
 
12
- __version__ = "0.1.0"
12
+ # ⚠️ 版本**单一事实源**(`__init__.py` 从这里 re-export;`_request` 的 User-Agent 也用它)
13
+ # 2026-09-26 修正:此前这里是 `0.1.0`(包已 0.1.3)→ **UA 报的是 0.1.0**,版本漂移。
14
+ __version__ = "0.1.4"
13
15
 
14
16
  DEFAULT_BASE = "https://api.ashareapi.com"
15
17
  FREE_ENDPOINTS = (
@@ -89,6 +91,15 @@ class AShareAPI:
89
91
 
90
92
  2026-09-23 实测:部分端点 ``data`` 直接是数组,部分是 Markdown 但都带 **``structured``**
91
93
  结构化数组 → 这里**零 Markdown 解析** ✓
94
+
95
+ ⚠️ **2026-09-26 修正 —— 三种返回形态,不能一律套 DataFrame**:
96
+ · 单表(多数端点)→ ``DataFrame``(未装 pandas → ``list[dict]``)
97
+ · **表列表**(``/v1/finance``:``[[利润表行],[资产负债行],[现金流行]]``)
98
+ → 返回**列表**(``list[list[dict]]``,对齐 JS SDK 的 ``Row[][]``)。
99
+ 旧实现会 ``pd.DataFrame([[{...}],[{...}],[{...}]])`` → **退化的 3×1「单元格里是 list」**,
100
+ 不是可用结果(2026-09-26 实测确认)。
101
+ · **多段结构**(``/v1/shareholder``、``/v1/calendar``:``{tables, data}``)
102
+ → 原样返回该 dict(与 JS SDK 一致)。
92
103
  """
93
104
  if self.raw:
94
105
  return body
@@ -97,6 +108,9 @@ class AShareAPI:
97
108
  rows = body["data"]
98
109
  if rows is None:
99
110
  return body.get("data", body) # 无表格字段(health / challenge / usage)→ 返回整个信封
111
+ # ⭐ 表列表(首元素是 list)→ 不套 DataFrame(套了就是退化的 3×1 单元格为 list)
112
+ if rows and isinstance(rows[0], list):
113
+ return rows # list[list[dict]],对齐 JS SDK 的 Row[][]
100
114
  try:
101
115
  import pandas as pd
102
116
  return pd.DataFrame(rows)
@@ -106,7 +120,7 @@ class AShareAPI:
106
120
  def _get(self, path: str, **params):
107
121
  return self._frame(self._request(path, **params))
108
122
 
109
- # ── 端点方法(30 个 —— 签名对齐 /openapi.json)─────────────────────
123
+ # ── 端点方法(32 个 —— 签名对齐 /openapi.json)─────────────────────
110
124
  # 【基础 / 工具】
111
125
  def health(self):
112
126
  """服务健康检查(数据源就绪状态)"""
@@ -172,6 +186,17 @@ class AShareAPI:
172
186
  """
173
187
  return self._get("/v1/orderbook", code=normalize_code(code))
174
188
 
189
+ def snapshot(self, code: str):
190
+ """全字段行情画像(价格 + 盘口 + 估值 + 市值 + 股本 + 涨停跌停价 + 量比 + 振幅 + 涨速)
191
+
192
+ ⚠️ **与 `quote()` 的分工**:`quote()` 轻(8 字段,**免费**);本方法全(24+ 字段,**付费**)
193
+ —— **只要现价用 `quote()` 更轻(字段少、响应快)**。
194
+ ⚠️ **仅 A 股**(港股/美股字段布局不同,用 `quote()`)—— **传其他市场返回空,不返回错数据**。
195
+ **计费 = 次数**:本方法 1 次拿全 24+ 字段 —— **要估值+市值+股本+涨停价多项时,比分别调 quote/valuation/orderbook 更省次数**(3 次 → 1 次)。
196
+ 单位:``amount`` 万元 · ``volume`` 手 · 市值 亿元 · 股本 股 · 比率 百分数。
197
+ """
198
+ return self._get("/v1/snapshot", code=normalize_code(code))
199
+
175
200
  def events(self, code: str):
176
201
  """个股事件标签(42 类)"""
177
202
  return self._get("/v1/events", code=normalize_code(code))
@@ -0,0 +1,12 @@
1
+ CHANGELOG.md
2
+ LICENSE
3
+ MANIFEST.in
4
+ README.md
5
+ pyproject.toml
6
+ ashareapi/__init__.py
7
+ ashareapi/_code.py
8
+ ashareapi/client.py
9
+ ashareapi/errors.py
10
+ examples/quickstart.py
11
+ tests/test_convert.py
12
+ tests/test_endpoint_coverage.py
@@ -0,0 +1,19 @@
1
+ """3 行拿数据(免费端点无需 Key)"""
2
+ from ashareapi import AShareAPI
3
+
4
+ cli = AShareAPI() # 免费端点:无需注册、无需 Key
5
+
6
+ bar = cli.quote("sh600667") # 行情快照
7
+ print("最新行情:")
8
+ print(bar[["date", "last", "exchange"]].to_string(index=False) if hasattr(bar, "columns") else bar)
9
+
10
+ print("\n最近 5 根日线:")
11
+ k = cli.kline("600667.SH", count=5) # 代码格式随便写(自动归一化)
12
+ print(k.to_string(index=False) if hasattr(k, "columns") else k)
13
+
14
+ print("\n热搜 Top 5:")
15
+ print(cli.hot(limit=5).to_string(index=False))
16
+
17
+ # 付费端点(需 Key)—— 取消注释并填入你的 Key:
18
+ # cli = AShareAPI("ct-你的Key")
19
+ # print(cli.screen(expr="intersect([PE_TTM > 0, PE_TTM < 20, ROETTM > 15])", orderby="ROETTM", limit=10))
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ashareapi"
7
- version = "0.1.2"
7
+ version = "0.1.4"
8
8
  description = "A股数据 API 官方 Python SDK —— 行情 / K线 / 财务 / 资金 / 龙虎榜 / 板块 / 因子选股(含 MCP)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -27,3 +27,8 @@ dev = ["pytest>=7", "build", "twine"]
27
27
  Homepage = "https://ashareapi.com"
28
28
  Documentation = "https://ashareapi.com/docs"
29
29
  "Endpoint list" = "https://ashareapi.com/endpoints"
30
+ Changelog = "https://github.com/ashareapi/ashareapi/blob/main/CHANGELOG.md"
31
+
32
+ [tool.setuptools]
33
+ # CHANGELOG.md 要进 sdist(PyPI 页面会渲染 README,但 changelog 供查阅)
34
+ include-package-data = true
@@ -49,6 +49,27 @@ def test_frame_non_table_passthrough():
49
49
  assert cli._frame({"ok": True, "data": {"k": "v"}}) == {"k": "v"}
50
50
 
51
51
 
52
+ def test_frame_table_list_not_wrapped():
53
+ """表列表(/v1/finance)→ 原样返回 list[list[dict]],**不套 DataFrame**
54
+
55
+ 旧实现会 pd.DataFrame([[{...}],[{...}],[{...}]]) → 退化的 3×1「单元格里是 list」。
56
+ """
57
+ cli = AShareAPI()
58
+ tabs = [[{"EndDate": "2026-06-30", "OperatingRevenue": 1}],
59
+ [{"EndDate": "2026-06-30", "TotalAssets": 2}]]
60
+ r = cli._frame({"ok": True, "data": tabs})
61
+ assert r == tabs
62
+ assert isinstance(r[0], list) # 仍是表列表,不是 DataFrame
63
+
64
+
65
+ def test_frame_sectioned_dict_passthrough():
66
+ """多段结构(/v1/shareholder、/v1/calendar)→ 原样返回 dict(含 tables/data)"""
67
+ cli = AShareAPI()
68
+ sec = {"tables": [{"title": "十大股东", "slug": "top10_holders", "rows": [{"name": "A"}]}],
69
+ "data": {"top10_holders": [{"name": "A"}]}}
70
+ assert cli._frame({"ok": True, "data": sec}) == sec
71
+
72
+
52
73
  def test_raw_mode_returns_envelope():
53
74
  cli = AShareAPI(raw=True)
54
75
  b = {"ok": True, "data": [{"x": 1}], "elapsed_ms": 12}
@@ -1,107 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: ashareapi
3
- Version: 0.1.2
4
- Summary: A股数据 API 官方 Python SDK —— 行情 / K线 / 财务 / 资金 / 龙虎榜 / 板块 / 因子选股(含 MCP)
5
- Author: ashareapi
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://ashareapi.com
8
- Project-URL: Documentation, https://ashareapi.com/docs
9
- Project-URL: Endpoint list, https://ashareapi.com/endpoints
10
- Keywords: a-share,ashare,stock,quant,finance,mcp,stock-data-api,financial-data-api
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Topic :: Office/Business :: Financial :: Investment
13
- Classifier: Operating System :: OS Independent
14
- Requires-Python: >=3.9
15
- Description-Content-Type: text/markdown
16
- License-File: LICENSE
17
- Requires-Dist: requests>=2.28
18
- Provides-Extra: pandas
19
- Requires-Dist: pandas>=1.5; extra == "pandas"
20
- Provides-Extra: dev
21
- Requires-Dist: pytest>=7; extra == "dev"
22
- Requires-Dist: build; extra == "dev"
23
- Requires-Dist: twine; extra == "dev"
24
- Dynamic: license-file
25
-
26
- # ashareapi — A股数据 API 官方 Python SDK
27
-
28
- **行情 / K线 / 财务 / 资金 / 龙虎榜 / 板块 / 因子选股** —— 30 个端点,**免费端点无需注册**。
29
-
30
- ```bash
31
- pip install ashareapi # 基础(返回 list[dict])
32
- pip install "ashareapi[pandas]" # 加 DataFrame 支持(推荐)
33
- ```
34
-
35
- ## 30 秒上手
36
-
37
- ```python
38
- from ashareapi import AShareAPI
39
-
40
- cli = AShareAPI() # 免费端点无需 Key
41
- df = cli.quote("sh600667") # 实时行情 → DataFrame
42
- print(df[["date", "last", "exchange"]])
43
-
44
- print(cli.kline("600667.SH", count=5)) # 代码格式随便写(自动归一化)
45
- print(cli.hot(limit=10)) # 热搜榜
46
- ```
47
-
48
- **付费端点**(财务 / 资金 / 龙虎榜 / 选股等)需要 Key([获取](https://ashareapi.com/pricing),¥9.9 起):
49
-
50
- ```python
51
- cli = AShareAPI("ct-你的Key") # 或设环境变量 ASHARE_API_KEY
52
- df = cli.screen(preset="low_pe", orderby="ROETTM", limit=10)
53
- print(df.head())
54
- ```
55
-
56
- ## 为什么用它
57
-
58
- - **免费端点真的免 Key**:`quote / kline / hot / market-overview / changedist` 直接调,无需注册
59
- - **代码格式兼容**:`sh600667` / `600667.SH` / `600667` 都认(不同写法的项目都能直接用)
60
- - **多源自动切换**:后端 67 个数据源互为备份,取数失败会自动换源且**不扣调用次数**
61
- - **错误分类清楚**:`AuthError` / `RateLimitError` / `UpstreamError` / `EmptyResultError`(无数据 ≠ 失败)—— 每类都告诉你该做什么
62
- - **pandas 可选**:不想装 pandas 也能用(返回 `list[dict]`)
63
-
64
- ## 端点一览
65
-
66
- | 方法 | 说明 | 免 Key |
67
- |---|---|---|
68
- | `quote(code)` | 实时行情快照 | ✅ |
69
- | `kline(code, period, count)` | K 线(日/周/月)| ✅ |
70
- | `hot(limit)` | 热搜榜 | ✅ |
71
- | `market_overview(type)` | 市场总览(画像/估值/风格轮动)| ✅ |
72
- | `changedist()` | 涨跌分布(市场广度)| ✅ |
73
- | `finance(code, num)` | 三大报表 | — |
74
- | `fund(code)` | 资金流 + 龙虎榜 + 大宗 + 两融 | — |
75
- | `technical(code)` | MA / MACD / KDJ / RSI / BOLL | — |
76
- | `lhb(type)` | 龙虎榜分榜(机构 / 游资 / 活跃席位)| — |
77
- | `screen(expr/preset, ...)` | 因子选股 | — |
78
- | `search(q)` | 搜索消歧 | — |
79
-
80
- (完整 30 端点见 [端点清单](https://ashareapi.com/endpoints))
81
-
82
- ## 错误处理
83
-
84
- ```python
85
- from ashareapi import AShareAPI, AuthError, RateLimitError, UpstreamError, EmptyResultError
86
-
87
- cli = AShareAPI()
88
- try:
89
- df = cli.fund("sh600667")
90
- except AuthError as e: # 401 / 缺 Key → 去拿 Key
91
- print(e)
92
- except RateLimitError as e: # 429 → 降频 / 解 PoW 挑战提额 / 升级档位
93
- print(e)
94
- except UpstreamError as e: # 上游取数失败(已自动换源、不扣次数)→ 重试一次通常就好
95
- print(e)
96
- except EmptyResultError as e: # 当前无数据(如当天无大宗交易)→ 不计费,换条件或稍后再试
97
- print(e)
98
- ```
99
-
100
- ## 也用 AI Agent(MCP)
101
-
102
- 除了 Python,我们还提供 **MCP 服务器**(Streamable HTTP)—— 一条 URL 接进 Claude Code / Cursor / Codex 等 19 家客户端:
103
- **https://ashareapi.com/mcp**
104
-
105
- ## License
106
-
107
- MIT · 数据仅供研究参考,不构成投资建议
@@ -1,14 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- ashareapi/__init__.py
5
- ashareapi/_code.py
6
- ashareapi/client.py
7
- ashareapi/errors.py
8
- ashareapi.egg-info/PKG-INFO
9
- ashareapi.egg-info/SOURCES.txt
10
- ashareapi.egg-info/dependency_links.txt
11
- ashareapi.egg-info/requires.txt
12
- ashareapi.egg-info/top_level.txt
13
- tests/test_convert.py
14
- tests/test_endpoint_coverage.py
@@ -1,9 +0,0 @@
1
- requests>=2.28
2
-
3
- [dev]
4
- pytest>=7
5
- build
6
- twine
7
-
8
- [pandas]
9
- pandas>=1.5
@@ -1 +0,0 @@
1
- ashareapi
File without changes
File without changes
File without changes
File without changes