alphafeed 0.1.0.dev0__tar.gz → 0.1.0.dev1__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 (28) hide show
  1. alphafeed-0.1.0.dev1/PKG-INFO +208 -0
  2. alphafeed-0.1.0.dev1/README.md +181 -0
  3. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/_cache.py +4 -1
  4. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/models.py +59 -32
  5. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/resources/instruments.py +25 -21
  6. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/resources/quotes.py +3 -4
  7. alphafeed-0.1.0.dev1/alphafeed.egg-info/PKG-INFO +208 -0
  8. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/pyproject.toml +1 -1
  9. alphafeed-0.1.0.dev0/PKG-INFO +0 -175
  10. alphafeed-0.1.0.dev0/README.md +0 -148
  11. alphafeed-0.1.0.dev0/alphafeed.egg-info/PKG-INFO +0 -175
  12. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/__init__.py +0 -0
  13. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/__version__.py +0 -0
  14. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/_base_client.py +0 -0
  15. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/_batch.py +0 -0
  16. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/_exceptions.py +0 -0
  17. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/_types.py +0 -0
  18. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/client.py +0 -0
  19. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/resources/__init__.py +0 -0
  20. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/resources/_base.py +0 -0
  21. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/resources/depth.py +0 -0
  22. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/resources/klines.py +0 -0
  23. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed/utils.py +0 -0
  24. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed.egg-info/SOURCES.txt +0 -0
  25. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed.egg-info/dependency_links.txt +0 -0
  26. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed.egg-info/requires.txt +0 -0
  27. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/alphafeed.egg-info/top_level.txt +0 -0
  28. {alphafeed-0.1.0.dev0 → alphafeed-0.1.0.dev1}/setup.cfg +0 -0
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: alphafeed
3
+ Version: 0.1.0.dev1
4
+ Summary: AlphaFeed Python SDK
5
+ Author: AlphaFeed
6
+ License: MIT
7
+ Project-URL: Documentation, https://docs.alphafeed.org
8
+ Keywords: finance,stock,market-data,quant,kline,alphafeed,a-share,us-stock,hk-stock,real-time-quotes
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Financial and Insurance Industry
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Office/Business :: Financial :: Investment
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: httpx>=0.25.0
24
+ Requires-Dist: typing-extensions>=4.0.0
25
+ Requires-Dist: pandas>=1.5.0
26
+ Requires-Dist: tqdm>=4.60.0
27
+
28
+ # AlphaFeed Python SDK
29
+
30
+ AlphaFeed Python SDK 是 AlphaFeed 金融市场数据 API 的 Python 客户端,支持 A 股、ETF、美股、港股。
31
+
32
+ > **完整文档**:<https://docs.alphafeed.org>
33
+
34
+ ---
35
+
36
+ ## 安装
37
+
38
+ ```bash
39
+ pip install alphafeed
40
+ ```
41
+
42
+ SDK 支持 Python 3.9+,推荐 3.10 或更高版本。内置 pandas 和 tqdm 支持。
43
+
44
+ ---
45
+
46
+ ## 初始化
47
+
48
+ ```python
49
+ from alphafeed import AlphaFeed
50
+
51
+ af = AlphaFeed(api_key="your-api-key")
52
+ ```
53
+
54
+ 也支持环境变量:
55
+
56
+ ```bash
57
+ export ALPHAFEED_API_KEY="your-api-key"
58
+ ```
59
+
60
+ ```python
61
+ from alphafeed import AlphaFeed
62
+ af = AlphaFeed() # 自动读取 ALPHAFEED_API_KEY
63
+ ```
64
+
65
+ ---
66
+
67
+ ## 标的代码格式
68
+
69
+ | 示例 | 说明 |
70
+ |------|------|
71
+ | `600519.SH` | 上交所 |
72
+ | `000001.SZ` | 深交所 |
73
+ | `AAPL.US` | 美股 |
74
+ | `00700.HK` | 港股 |
75
+
76
+ ---
77
+
78
+ ## 基础用法
79
+
80
+ ### K 线获取
81
+
82
+ ```python
83
+ from alphafeed import AlphaFeed
84
+
85
+ af = AlphaFeed(api_key="your-api-key")
86
+
87
+ # 日 K 线,返回 DataFrame
88
+ df = af.klines.get("600519.SH", period="1d", count=5, to_dataframe=True)
89
+ print(df[["trade_date", "open", "high", "low", "close", "volume"]])
90
+ # trade_date open high low close volume
91
+ # 0 2026-06-02 1372.89 1372.89 1361.00 1361.33 57135
92
+ # 1 2026-06-03 1362.00 1363.58 1350.50 1354.55 50837
93
+ # ...
94
+
95
+ # 前复权(默认)/ 后复权 / 不复权
96
+ df = af.klines.get("600519.SH", adjust="forward", to_dataframe=True)
97
+ df = af.klines.get("600519.SH", adjust="backward", to_dataframe=True)
98
+ df = af.klines.get("600519.SH", adjust="none", to_dataframe=True)
99
+ ```
100
+
101
+ **批量获取**:多只标的一次拉取:
102
+
103
+ ```python
104
+ symbols = ["600519.SH", "000001.SZ", "601318.SH"]
105
+ dfs = af.klines.batch(symbols, period="1d", count=5, to_dataframe=True, show_progress=True)
106
+ # dfs 是 dict: {"600519.SH": DataFrame, "000001.SZ": DataFrame, ...}
107
+ print(dfs["600519.SH"][["trade_date", "close"]])
108
+ ```
109
+
110
+ ### 日内分时
111
+
112
+ ```python
113
+ # 当日 1 分钟线
114
+ df = af.klines.intraday("600519.SH", to_dataframe=True)
115
+ print(df[["trade_time", "close", "volume"]].tail())
116
+ # trade_time close volume
117
+ # 236 2026-06-08 14:57:00 1262.99 126
118
+ # 237 2026-06-08 14:58:00 1263.00 6
119
+ # 238 2026-06-08 14:59:00 1263.00 0
120
+ # 239 2026-06-08 15:00:00 1262.98 254
121
+
122
+ # 5 分钟线
123
+ df = af.klines.intraday("600519.SH", period="5m", to_dataframe=True)
124
+
125
+ # 批量日内分时
126
+ dfs = af.klines.intraday_batch(["600519.SH", "000001.SZ"], to_dataframe=True)
127
+ ```
128
+
129
+ ### 实时行情
130
+
131
+ **按标的代码查询**
132
+
133
+ ```python
134
+ df = af.quotes.get(symbols=["600519.SH", "000001.SZ"], to_dataframe=True)
135
+ print(df[["symbol", "last_price", "volume", "ext.name", "ext.change_pct"]])
136
+ # symbol last_price volume ext.name ext.change_pct
137
+ # 0 600519.SH 1262.98 30828 贵州茅台 -0.007762
138
+ # 1 000001.SZ 11.03 1090926 平安银行 0.004554
139
+ ```
140
+
141
+ **按标的池查询(全量行情)**
142
+
143
+ ```python
144
+ # 全部 A 股实时行情
145
+ df = af.quotes.get(universes="CN_Stock", to_dataframe=True)
146
+ print(f"共 {len(df)} 只标的")
147
+
148
+ # 全部 ETF 行情
149
+ df = af.quotes.get(universes="CN_ETF", to_dataframe=True)
150
+ ```
151
+
152
+ 支持的标的池:`CN_Stock`(A股)、`US_Stock`(美股)、`HK_Stock`(港股)、`CN_ETF`(ETF)
153
+
154
+ ### 五档盘口
155
+
156
+ ```python
157
+ depth = af.depth.get("600519.SH")
158
+ print(f"标的: {depth['symbol']}, 地区: {depth['region']}")
159
+ print(f"买盘价: {depth['bid_prices']}") # [1262.98, 1262.65, ...]
160
+ print(f"买盘量: {depth['bid_volumes']}") # [2, 1, ...]
161
+ print(f"卖盘价: {depth['ask_prices']}") # [1262.99, 1263.0, ...]
162
+ print(f"卖盘量: {depth['ask_volumes']}") # [7, 44, ...]
163
+ ```
164
+
165
+ ### 标的信息
166
+
167
+ ```python
168
+ # 单个标的
169
+ inst = af.instruments.get("600519.SH")
170
+ print(f"{inst['symbol']}: {inst['name']} ({inst['exchange']}, {inst['type']})")
171
+ # 600519.SH: 贵州茅台 (SH, stock)
172
+ print(f"上市日期: {inst['ext']['listing_date']}")
173
+ # 上市日期: 2001-08-27
174
+
175
+ # 批量查询
176
+ insts = af.instruments.batch(["600519.SH", "000001.SZ", "00700.HK"])
177
+ for i in insts:
178
+ print(f"{i['symbol']}: {i['name']} ({i['region']})")
179
+ # 600519.SH: 贵州茅台 (CN)
180
+ # 000001.SZ: 平安银行 (CN)
181
+ # 00700.HK: 腾讯控股 (HK)
182
+ ```
183
+
184
+ ### 复权因子
185
+
186
+ ```python
187
+ df = af.klines.ex_factors(["600519.SH", "000001.SZ"], to_dataframe=True)
188
+ print(df[["symbol", "trade_date", "ex_factor"]].tail())
189
+ # symbol trade_date ex_factor
190
+ # 54 000001.SZ 2025-07-18 1.023364
191
+ # 55 600519.SH 2024-12-20 1.015637
192
+ # 56 600519.SH 2025-06-27 1.019649
193
+ # 57 600519.SH 2026-02-20 1.017003
194
+ ```
195
+
196
+ ---
197
+
198
+ ## 更多文档
199
+
200
+ - [Python SDK 快速开始](https://docs.alphafeed.org/zh-Hans/sdk/python-quickstart)
201
+ - [使用示例](https://docs.alphafeed.org/zh-Hans/sdk/python-examples)
202
+ - [REST API 说明](https://docs.alphafeed.org/zh-Hans/api-reference/introduction)
203
+
204
+ ---
205
+
206
+ ## License
207
+
208
+ MIT
@@ -0,0 +1,181 @@
1
+ # AlphaFeed Python SDK
2
+
3
+ AlphaFeed Python SDK 是 AlphaFeed 金融市场数据 API 的 Python 客户端,支持 A 股、ETF、美股、港股。
4
+
5
+ > **完整文档**:<https://docs.alphafeed.org>
6
+
7
+ ---
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ pip install alphafeed
13
+ ```
14
+
15
+ SDK 支持 Python 3.9+,推荐 3.10 或更高版本。内置 pandas 和 tqdm 支持。
16
+
17
+ ---
18
+
19
+ ## 初始化
20
+
21
+ ```python
22
+ from alphafeed import AlphaFeed
23
+
24
+ af = AlphaFeed(api_key="your-api-key")
25
+ ```
26
+
27
+ 也支持环境变量:
28
+
29
+ ```bash
30
+ export ALPHAFEED_API_KEY="your-api-key"
31
+ ```
32
+
33
+ ```python
34
+ from alphafeed import AlphaFeed
35
+ af = AlphaFeed() # 自动读取 ALPHAFEED_API_KEY
36
+ ```
37
+
38
+ ---
39
+
40
+ ## 标的代码格式
41
+
42
+ | 示例 | 说明 |
43
+ |------|------|
44
+ | `600519.SH` | 上交所 |
45
+ | `000001.SZ` | 深交所 |
46
+ | `AAPL.US` | 美股 |
47
+ | `00700.HK` | 港股 |
48
+
49
+ ---
50
+
51
+ ## 基础用法
52
+
53
+ ### K 线获取
54
+
55
+ ```python
56
+ from alphafeed import AlphaFeed
57
+
58
+ af = AlphaFeed(api_key="your-api-key")
59
+
60
+ # 日 K 线,返回 DataFrame
61
+ df = af.klines.get("600519.SH", period="1d", count=5, to_dataframe=True)
62
+ print(df[["trade_date", "open", "high", "low", "close", "volume"]])
63
+ # trade_date open high low close volume
64
+ # 0 2026-06-02 1372.89 1372.89 1361.00 1361.33 57135
65
+ # 1 2026-06-03 1362.00 1363.58 1350.50 1354.55 50837
66
+ # ...
67
+
68
+ # 前复权(默认)/ 后复权 / 不复权
69
+ df = af.klines.get("600519.SH", adjust="forward", to_dataframe=True)
70
+ df = af.klines.get("600519.SH", adjust="backward", to_dataframe=True)
71
+ df = af.klines.get("600519.SH", adjust="none", to_dataframe=True)
72
+ ```
73
+
74
+ **批量获取**:多只标的一次拉取:
75
+
76
+ ```python
77
+ symbols = ["600519.SH", "000001.SZ", "601318.SH"]
78
+ dfs = af.klines.batch(symbols, period="1d", count=5, to_dataframe=True, show_progress=True)
79
+ # dfs 是 dict: {"600519.SH": DataFrame, "000001.SZ": DataFrame, ...}
80
+ print(dfs["600519.SH"][["trade_date", "close"]])
81
+ ```
82
+
83
+ ### 日内分时
84
+
85
+ ```python
86
+ # 当日 1 分钟线
87
+ df = af.klines.intraday("600519.SH", to_dataframe=True)
88
+ print(df[["trade_time", "close", "volume"]].tail())
89
+ # trade_time close volume
90
+ # 236 2026-06-08 14:57:00 1262.99 126
91
+ # 237 2026-06-08 14:58:00 1263.00 6
92
+ # 238 2026-06-08 14:59:00 1263.00 0
93
+ # 239 2026-06-08 15:00:00 1262.98 254
94
+
95
+ # 5 分钟线
96
+ df = af.klines.intraday("600519.SH", period="5m", to_dataframe=True)
97
+
98
+ # 批量日内分时
99
+ dfs = af.klines.intraday_batch(["600519.SH", "000001.SZ"], to_dataframe=True)
100
+ ```
101
+
102
+ ### 实时行情
103
+
104
+ **按标的代码查询**
105
+
106
+ ```python
107
+ df = af.quotes.get(symbols=["600519.SH", "000001.SZ"], to_dataframe=True)
108
+ print(df[["symbol", "last_price", "volume", "ext.name", "ext.change_pct"]])
109
+ # symbol last_price volume ext.name ext.change_pct
110
+ # 0 600519.SH 1262.98 30828 贵州茅台 -0.007762
111
+ # 1 000001.SZ 11.03 1090926 平安银行 0.004554
112
+ ```
113
+
114
+ **按标的池查询(全量行情)**
115
+
116
+ ```python
117
+ # 全部 A 股实时行情
118
+ df = af.quotes.get(universes="CN_Stock", to_dataframe=True)
119
+ print(f"共 {len(df)} 只标的")
120
+
121
+ # 全部 ETF 行情
122
+ df = af.quotes.get(universes="CN_ETF", to_dataframe=True)
123
+ ```
124
+
125
+ 支持的标的池:`CN_Stock`(A股)、`US_Stock`(美股)、`HK_Stock`(港股)、`CN_ETF`(ETF)
126
+
127
+ ### 五档盘口
128
+
129
+ ```python
130
+ depth = af.depth.get("600519.SH")
131
+ print(f"标的: {depth['symbol']}, 地区: {depth['region']}")
132
+ print(f"买盘价: {depth['bid_prices']}") # [1262.98, 1262.65, ...]
133
+ print(f"买盘量: {depth['bid_volumes']}") # [2, 1, ...]
134
+ print(f"卖盘价: {depth['ask_prices']}") # [1262.99, 1263.0, ...]
135
+ print(f"卖盘量: {depth['ask_volumes']}") # [7, 44, ...]
136
+ ```
137
+
138
+ ### 标的信息
139
+
140
+ ```python
141
+ # 单个标的
142
+ inst = af.instruments.get("600519.SH")
143
+ print(f"{inst['symbol']}: {inst['name']} ({inst['exchange']}, {inst['type']})")
144
+ # 600519.SH: 贵州茅台 (SH, stock)
145
+ print(f"上市日期: {inst['ext']['listing_date']}")
146
+ # 上市日期: 2001-08-27
147
+
148
+ # 批量查询
149
+ insts = af.instruments.batch(["600519.SH", "000001.SZ", "00700.HK"])
150
+ for i in insts:
151
+ print(f"{i['symbol']}: {i['name']} ({i['region']})")
152
+ # 600519.SH: 贵州茅台 (CN)
153
+ # 000001.SZ: 平安银行 (CN)
154
+ # 00700.HK: 腾讯控股 (HK)
155
+ ```
156
+
157
+ ### 复权因子
158
+
159
+ ```python
160
+ df = af.klines.ex_factors(["600519.SH", "000001.SZ"], to_dataframe=True)
161
+ print(df[["symbol", "trade_date", "ex_factor"]].tail())
162
+ # symbol trade_date ex_factor
163
+ # 54 000001.SZ 2025-07-18 1.023364
164
+ # 55 600519.SH 2024-12-20 1.015637
165
+ # 56 600519.SH 2025-06-27 1.019649
166
+ # 57 600519.SH 2026-02-20 1.017003
167
+ ```
168
+
169
+ ---
170
+
171
+ ## 更多文档
172
+
173
+ - [Python SDK 快速开始](https://docs.alphafeed.org/zh-Hans/sdk/python-quickstart)
174
+ - [使用示例](https://docs.alphafeed.org/zh-Hans/sdk/python-examples)
175
+ - [REST API 说明](https://docs.alphafeed.org/zh-Hans/api-reference/introduction)
176
+
177
+ ---
178
+
179
+ ## License
180
+
181
+ MIT
@@ -80,7 +80,10 @@ class InstrumentNameCache:
80
80
  try:
81
81
  for i in range(0, len(symbols), MAX_BATCH_SIZE):
82
82
  chunk = symbols[i : i + MAX_BATCH_SIZE]
83
- response = client.post("/v1/instruments", json={"symbols": chunk})
83
+ symbols_str = ",".join(chunk)
84
+ response = client.get(
85
+ "/v1/instruments", params={"symbols": symbols_str}
86
+ )
84
87
  names = {
85
88
  inst["symbol"]: inst["name"]
86
89
  for inst in response.get("data", [])
@@ -1,12 +1,16 @@
1
+ # generated by datamodel-codegen:
2
+ # filename: openapi.json
3
+ # timestamp: 2026-06-08T08:16:35+00:00
4
+
1
5
  from __future__ import annotations
2
6
 
3
7
  from typing import Any, Dict, List, Literal, TypedDict
4
8
 
5
- from typing_extensions import NotRequired
6
-
7
- Period = Literal["1m", "5m", "15m", "30m", "60m", "1d", "1w", "1M", "1Q", "1Y"]
9
+ from typing_extensions import NotRequired, TypeAlias
8
10
 
9
- AdjustType = Literal["none", "forward", "backward", "forward_additive", "backward_additive"]
11
+ AdjustType: TypeAlias = Literal[
12
+ "none", "forward", "backward", "forward_additive", "backward_additive"
13
+ ]
10
14
 
11
15
 
12
16
  class CompactKlineData(TypedDict):
@@ -34,25 +38,18 @@ class ExFactorsResponse(TypedDict):
34
38
  data: Dict[str, List[ExFactorEntry]]
35
39
 
36
40
 
37
-
38
- class Instrument(TypedDict):
39
- currency: NotRequired[str]
40
- exchange: str
41
- instrument_type: Literal[
42
- "stock", "etf", "index", "bond", "fund", "futures", "options", "other"
43
- ]
44
- list_date: NotRequired[str]
45
- name: str
46
- region: Literal["CN", "US", "HK"]
47
- symbol: str
41
+ class FinancialsResponse(TypedDict):
42
+ data: Dict[str, List[Dict[str, Any]]]
48
43
 
49
44
 
50
- class InstrumentsBatchRequest(TypedDict):
51
- symbols: List[str]
52
-
53
-
54
- class InstrumentsResponse(TypedDict):
55
- data: List[Instrument]
45
+ class InstrumentExt(TypedDict):
46
+ float_shares: NotRequired[float]
47
+ limit_down: NotRequired[float]
48
+ limit_up: NotRequired[float]
49
+ listing_date: NotRequired[str]
50
+ tick_size: NotRequired[float]
51
+ total_shares: NotRequired[float]
52
+ type: NotRequired[str]
56
53
 
57
54
 
58
55
  class KlineBatchResponse(TypedDict):
@@ -73,9 +70,49 @@ class MarketDepth(TypedDict):
73
70
  timestamp: int
74
71
 
75
72
 
73
+ Period: TypeAlias = Literal[
74
+ "1m", "5m", "15m", "30m", "60m", "1d", "1w", "1M", "1Q", "1Y"
75
+ ]
76
+
77
+
78
+ class QuoteExt(TypedDict):
79
+ amplitude: NotRequired[float]
80
+ change_amount: NotRequired[float]
81
+ change_pct: NotRequired[float]
82
+ name: NotRequired[str]
83
+ turnover_rate: NotRequired[float]
84
+ type: NotRequired[str]
85
+
86
+
87
+ class RateLimitResponse(TypedDict):
88
+ code: int
89
+ message: str
90
+ retry_after_ms: int
91
+
92
+
93
+ class DepthResponse(TypedDict):
94
+ data: MarketDepth
95
+
96
+
97
+ class Instrument(TypedDict):
98
+ code: str
99
+ exchange: str
100
+ ext: NotRequired[InstrumentExt]
101
+ name: str
102
+ region: Literal["CN", "US", "HK"]
103
+ symbol: str
104
+ type: Literal[
105
+ "stock", "etf", "index", "bond", "fund", "futures", "options", "other"
106
+ ]
107
+
108
+
109
+ class InstrumentsResponse(TypedDict):
110
+ data: List[Instrument]
111
+
112
+
76
113
  class Quote(TypedDict):
77
114
  amount: float
78
- ext: NotRequired[Dict[str, Any]]
115
+ ext: NotRequired[QuoteExt]
79
116
  high: float
80
117
  last_price: float
81
118
  low: float
@@ -89,13 +126,3 @@ class Quote(TypedDict):
89
126
 
90
127
  class QuotesResponse(TypedDict):
91
128
  data: List[Quote]
92
-
93
-
94
- class RateLimitResponse(TypedDict):
95
- code: int
96
- message: str
97
- retry_after_ms: int
98
-
99
-
100
- class DepthResponse(TypedDict):
101
- data: MarketDepth
@@ -16,7 +16,7 @@ class Instruments(SyncResource):
16
16
  Examples
17
17
  --------
18
18
  >>> client = AlphaFeed(api_key="your-key")
19
- >>> inst = client.instruments.get("600000.SH")
19
+ >>> inst = client.instruments.get("600519.SH")
20
20
  >>> print(f"{inst['symbol']}: {inst['name']}")
21
21
  """
22
22
 
@@ -43,44 +43,46 @@ class Instruments(SyncResource):
43
43
  If a list is provided, returns a list of Instrument dicts.
44
44
 
45
45
  Each Instrument contains:
46
- - symbol: Full symbol code (e.g., "600000.SH")
47
- - code: Exchange-specific code (e.g., "600000")
48
- - exchange: Exchange code (e.g., "SH")
49
- - region: Region code (e.g., "CN")
50
- - name: Instrument name
51
- - instrument_type: Type (stock, etf, index, etc.)
52
- - ext: Market-specific extension data
46
+ - symbol: Full symbol code (e.g., "600519.SH")
47
+ - code: Exchange-specific code (e.g., "600519")
48
+ - exchange: Exchange code (e.g., "SH", "SZ", "HK", "US")
49
+ - region: Region code ("CN", "US", "HK")
50
+ - name: Instrument name (e.g., "贵州茅台")
51
+ - type: Type (stock, etf, index, etc.)
52
+ - ext: Market-specific extension data (listing_date, total_shares, etc.)
53
53
 
54
54
  Examples
55
55
  --------
56
56
  >>> # Single instrument
57
- >>> inst = client.instruments.get("600000.SH")
58
- >>> print(inst['name'])
57
+ >>> inst = client.instruments.get("600519.SH")
58
+ >>> print(f"{inst['name']} ({inst['exchange']})")
59
+ 贵州茅台 (SH)
59
60
 
60
61
  >>> # Multiple instruments
61
- >>> insts = client.instruments.get(["600000.SH", "AAPL.US"])
62
+ >>> insts = client.instruments.get(["600519.SH", "000001.SZ"])
62
63
  >>> for i in insts:
63
64
  ... print(f"{i['symbol']}: {i['name']}")
65
+ 600519.SH: 贵州茅台
66
+ 000001.SZ: 平安银行
64
67
  """
65
68
  if isinstance(symbol, str):
66
69
  response = self._client.get("/v1/instruments", params={"symbols": symbol})
67
70
  data = response["data"]
68
71
  return data[0] if data else {}
69
72
  else:
70
- response = self._client.post(
71
- "/v1/instruments/batch", json={"symbols": symbol}
73
+ symbols_str = ",".join(symbol)
74
+ response = self._client.get(
75
+ "/v1/instruments", params={"symbols": symbols_str}
72
76
  )
73
77
  return response["data"]
74
78
 
75
79
  def batch(self, symbols: List[str]) -> List["Instrument"]:
76
80
  """Get metadata for multiple instruments.
77
81
 
78
- This method uses POST to handle large batches without URL length limits.
79
-
80
82
  Parameters
81
83
  ----------
82
84
  symbols : list of str
83
- List of symbol codes (up to 1000).
85
+ List of symbol codes.
84
86
 
85
87
  Returns
86
88
  -------
@@ -89,11 +91,13 @@ class Instruments(SyncResource):
89
91
 
90
92
  Examples
91
93
  --------
92
- >>> insts = client.instruments.batch(["600000.SH", "000001.SZ", "AAPL.US"])
94
+ >>> insts = client.instruments.batch(["600519.SH", "000001.SZ", "00700.HK"])
93
95
  >>> for i in insts:
94
- ... print(f"{i['symbol']}: {i['name']}")
96
+ ... print(f"{i['symbol']}: {i['name']} ({i['region']})")
97
+ 600519.SH: 贵州茅台 (CN)
98
+ 000001.SZ: 平安银行 (CN)
99
+ 00700.HK: 腾讯控股 (HK)
95
100
  """
96
- response = self._client.post(
97
- "/v1/instruments/batch", json={"symbols": symbols}
98
- )
101
+ symbols_str = ",".join(symbols)
102
+ response = self._client.get("/v1/instruments", params={"symbols": symbols_str})
99
103
  return response["data"]
@@ -120,16 +120,15 @@ class Quotes(SyncResource):
120
120
  Quote data for the requested symbols.
121
121
 
122
122
  Each Quote contains:
123
- - symbol: Symbol code
124
- - name: Symbol name
125
- - region: Region code
123
+ - symbol: Symbol code (e.g., "600519.SH")
124
+ - region: Region code ("CN", "US", "HK")
126
125
  - last_price: Latest price
127
126
  - prev_close: Previous close
128
127
  - open, high, low: OHLC prices
129
128
  - volume: Trading volume
130
129
  - amount: Trading amount
131
130
  - timestamp: Quote timestamp (milliseconds)
132
- - ext: Market-specific extension data
131
+ - ext: Extension data (name, change_pct, change_amount, amplitude, turnover_rate)
133
132
 
134
133
  Raises
135
134
  ------