sharetop 0.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.
- sharetop-0.1.0/LICENSE +21 -0
- sharetop-0.1.0/MANIFEST.in +4 -0
- sharetop-0.1.0/PKG-INFO +287 -0
- sharetop-0.1.0/README.md +248 -0
- sharetop-0.1.0/pyproject.toml +63 -0
- sharetop-0.1.0/setup.cfg +4 -0
- sharetop-0.1.0/sharetop/__init__.py +38 -0
- sharetop-0.1.0/sharetop/__version__.py +1 -0
- sharetop-0.1.0/sharetop/_base_client.py +330 -0
- sharetop-0.1.0/sharetop/_batch.py +177 -0
- sharetop-0.1.0/sharetop/_cache.py +135 -0
- sharetop-0.1.0/sharetop/_exceptions.py +142 -0
- sharetop-0.1.0/sharetop/_types.py +58 -0
- sharetop-0.1.0/sharetop/aio_utils/__init__.py +1 -0
- sharetop-0.1.0/sharetop/aio_utils/aio_quotes.py +248 -0
- sharetop-0.1.0/sharetop/client.py +126 -0
- sharetop-0.1.0/sharetop/generated_model.py +88 -0
- sharetop-0.1.0/sharetop/py.typed +0 -0
- sharetop-0.1.0/sharetop/resources/__init__.py +15 -0
- sharetop-0.1.0/sharetop/resources/_base.py +19 -0
- sharetop-0.1.0/sharetop/resources/financials.py +641 -0
- sharetop-0.1.0/sharetop/resources/klines.py +362 -0
- sharetop-0.1.0/sharetop/resources/limit_up_resources/__init__.py +94 -0
- sharetop-0.1.0/sharetop/resources/limit_up_resources/_common.py +201 -0
- sharetop-0.1.0/sharetop/resources/limit_up_resources/dragon_tiger_data.py +159 -0
- sharetop-0.1.0/sharetop/resources/limit_up_resources/limit_up_down_pool.py +226 -0
- sharetop-0.1.0/sharetop/resources/limit_up_resources/market_situation.py +110 -0
- sharetop-0.1.0/sharetop/resources/limit_up_resources/sector_quotes_data.py +177 -0
- sharetop-0.1.0/sharetop/resources/market.py +304 -0
- sharetop-0.1.0/sharetop/resources/quotes.py +268 -0
- sharetop-0.1.0/sharetop/utils.py +191 -0
- sharetop-0.1.0/sharetop.egg-info/PKG-INFO +287 -0
- sharetop-0.1.0/sharetop.egg-info/SOURCES.txt +34 -0
- sharetop-0.1.0/sharetop.egg-info/dependency_links.txt +1 -0
- sharetop-0.1.0/sharetop.egg-info/requires.txt +11 -0
- sharetop-0.1.0/sharetop.egg-info/top_level.txt +1 -0
sharetop-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 ShareTop Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
sharetop-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sharetop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: ShareTop Python Client
|
|
5
|
+
Author-email: ShareTop Team <support@sharetop.top>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Documentation, https://docs.sharetop.top
|
|
8
|
+
Project-URL: Repository, https://github.com/sharetop-org/sharetop
|
|
9
|
+
Keywords: finance,stock,market-data,trading,api-client
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Natural Language :: Chinese (Simplified)
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: httpx>=0.25.0
|
|
30
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
31
|
+
Requires-Dist: pandas>=1.5.0
|
|
32
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
33
|
+
Requires-Dist: tqdm>=4.60.0
|
|
34
|
+
Provides-Extra: gevent
|
|
35
|
+
Requires-Dist: gevent>=23.0.0; extra == "gevent"
|
|
36
|
+
Provides-Extra: full
|
|
37
|
+
Requires-Dist: sharetop[gevent]; extra == "full"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# ShareTop Python SDK
|
|
41
|
+
|
|
42
|
+
[](https://pypi.org/project/sharetop/)
|
|
43
|
+
[](https://pypi.org/project/sharetop/)
|
|
44
|
+
[](https://pypi.org/project/sharetop/)
|
|
45
|
+
[](https://docs.sharetop.org)
|
|
46
|
+
[](https://github.com/sharetop-org/sharetop)
|
|
47
|
+
[](LICENSE)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
凡是数据皆有价值,前提是要放到正确位置,同时在正确的时间被使用。
|
|
51
|
+
|
|
52
|
+
ShareTop 是一个开源数据社区,主要为个人及科研团队在金融、宏观、汽车、石油等领域的科学研究提供数据清洗、结构化的API接口服务,它不以盈利为主要目的,不做任何荐股或者推荐。
|
|
53
|
+
|
|
54
|
+
ShareTop Python SDK 是 ShareTop 数据长期维护的 Python 客户端,提供 金融、宏观、汽车等相关行业存量和增量数据。
|
|
55
|
+
|
|
56
|
+
“数据仅供参考,不构成投资建议”
|
|
57
|
+
|
|
58
|
+
> **完整文档**:<https://sharetop.top>
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 安装
|
|
63
|
+
|
|
64
|
+
使用 pip 安装 ShareTop Python SDK:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install sharetop
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
SDK 支持 Python 3.9+,推荐使用 Python 3.10 或更高版本。
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 获取token
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### 关注公众号并点击获取token
|
|
78
|
+
|
|
79
|
+
<img src="img/scan.png" alt="微信公众号二维码" width="300">
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## 初始化客户端
|
|
83
|
+
|
|
84
|
+
### 免费服务
|
|
85
|
+
|
|
86
|
+
如果你只需要日K线数据和股票基础信息,可以直接使用免费服务:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from sharetop import ShareTop
|
|
90
|
+
|
|
91
|
+
# 从微信公众号里面获取token
|
|
92
|
+
token = ""
|
|
93
|
+
|
|
94
|
+
client = ShareTop(token=token)
|
|
95
|
+
|
|
96
|
+
# 查询日K线数据
|
|
97
|
+
symbol = "601717.SH"
|
|
98
|
+
|
|
99
|
+
df = client.klines.get_history_data(symbol=symbol, count=500000, period="d", adjust="before", as_df=True)
|
|
100
|
+
print(df)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**免费服务特点:**
|
|
104
|
+
- ✅ 关注微信公众号,获取token,直接使用
|
|
105
|
+
- ✅ 提供历史日K线数据(d、w、m、q、y)
|
|
106
|
+
- ✅ 提供标的信息、交易所、标的池查询
|
|
107
|
+
- ❌ 不提供实时行情
|
|
108
|
+
- ❌ 不提供分钟级K线(1m、5m、15m、30m、60m、120m)
|
|
109
|
+
- ⚠️ 日K数据为历史数据,盘中不会实时更新
|
|
110
|
+
|
|
111
|
+
如果你需要实时行情、盘中实时更新的K线或更高频率访问,请使用完整服务。
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### 完整服务
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from sharetop import ShareTop
|
|
119
|
+
|
|
120
|
+
# 从微信公众号里面获取token
|
|
121
|
+
token = ""
|
|
122
|
+
|
|
123
|
+
client = ShareTop(token=token)
|
|
124
|
+
|
|
125
|
+
# 获取沪深 A 股实时行情
|
|
126
|
+
df = client.quotes.get(symbols="600000.SH,002522.SZ,000006.SZ,688003.SH,002534.SZ", as_df=True)
|
|
127
|
+
|
|
128
|
+
print(df)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
如果看到股票价格输出,说明 SDK 已配置成功!
|
|
132
|
+
|
|
133
|
+
**完整服务优势:**
|
|
134
|
+
- ✅ 实时行情数据
|
|
135
|
+
- ✅ 分钟级K线(5m、15m、30m、60m、120m)
|
|
136
|
+
- ✅ 日内分时数据
|
|
137
|
+
- ✅ 财报数据
|
|
138
|
+
- ✅ 更高的调用频率
|
|
139
|
+
- ✅ 打板专题数据
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 标的代码格式与支持市场
|
|
144
|
+
|
|
145
|
+
所有按标的查询的接口(行情、K 线等)均使用**统一标的代码**,格式为:**`代码.市场后缀`**(中间为英文点号)。
|
|
146
|
+
|
|
147
|
+
### 标的代码格式
|
|
148
|
+
|
|
149
|
+
- 格式:`代码.市场后缀`
|
|
150
|
+
- 示例:
|
|
151
|
+
- 股票:`600000.SH`(浦发银行)、`000001.SZ`(平安银行)、`920662.BJ`(方盛股份)
|
|
152
|
+
|
|
153
|
+
代码部分使用交易所官方代码(如 6 位 A 股代码、合约代码等),**市场后缀**见下表。
|
|
154
|
+
|
|
155
|
+
### 支持的市场(后缀)
|
|
156
|
+
|
|
157
|
+
| 后缀 | 市场 | 说明 |
|
|
158
|
+
|------|------|------|
|
|
159
|
+
| **SH** | 上海证券交易所 | 沪市 A 股、ETF、债券等 |
|
|
160
|
+
| **SZ** | 深圳证券交易所 | 深市 A 股、创业板、ETF 等 |
|
|
161
|
+
| **BJ** | 北京证券交易所 | 北交所股票 |
|
|
162
|
+
|
|
163
|
+
### 目前支持状态
|
|
164
|
+
|
|
165
|
+
- **A 股(SH / SZ / BJ)**:已支持。可查实时行情、日 K、分钟 K、日内分时、财务数据等。
|
|
166
|
+
|
|
167
|
+
按标的查询时传入上述格式的字符串或列表即可:
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from sharetop import ShareTop
|
|
171
|
+
|
|
172
|
+
token = ""
|
|
173
|
+
|
|
174
|
+
client = ShareTop(token=token)
|
|
175
|
+
|
|
176
|
+
# 上交所整体实时数据
|
|
177
|
+
df = client.quotes.get(exchange=["SSE"], as_df=True)
|
|
178
|
+
|
|
179
|
+
print(df)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 基础用法
|
|
185
|
+
|
|
186
|
+
### K 线获取
|
|
187
|
+
|
|
188
|
+
**单个或者批量获取分钟k线**:
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
from sharetop import ShareTop
|
|
192
|
+
|
|
193
|
+
token = ""
|
|
194
|
+
|
|
195
|
+
client = ShareTop(token=token)
|
|
196
|
+
|
|
197
|
+
symbols = ["601717.SH", "601928.SH"]
|
|
198
|
+
|
|
199
|
+
# 获取分钟 K 线,返回原始数据
|
|
200
|
+
kline_data = client.klines.get_batch_real_time(symbols=symbols, period="1m", count=5, adjust="before", as_df=True)
|
|
201
|
+
print(f"601717.SH最新的1min k线数据: {kline_data['601717.SH']}")
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 获取实时行情
|
|
206
|
+
|
|
207
|
+
**按标的代码查询**
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
from sharetop import ShareTop
|
|
211
|
+
|
|
212
|
+
token = ""
|
|
213
|
+
|
|
214
|
+
client = ShareTop(token=token)
|
|
215
|
+
|
|
216
|
+
symbols = ["600000.SH", "002534.SZ", "688003.SH"]
|
|
217
|
+
|
|
218
|
+
df = client.quotes.get(symbols=symbols, as_df=True)
|
|
219
|
+
|
|
220
|
+
print(df)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**按标的池查询**
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
# 获取全部 上交所 A 股行情
|
|
227
|
+
quotes_a = client.quotes.get(exchange=["SSE"], as_df=True)
|
|
228
|
+
|
|
229
|
+
print(quotes_a)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
# 获取全部 上交所 深交所 A 股行情
|
|
233
|
+
quotes = client.quotes.get(exchange=["SSE", "SZSE"], as_df=True)
|
|
234
|
+
|
|
235
|
+
print(quotes)
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 获取打板数据
|
|
240
|
+
|
|
241
|
+
**炸板池查询**
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
|
|
245
|
+
from sharetop import ShareTop
|
|
246
|
+
|
|
247
|
+
token = ""
|
|
248
|
+
|
|
249
|
+
client = ShareTop(token=token)
|
|
250
|
+
|
|
251
|
+
# 获取实时炸板池数据
|
|
252
|
+
df = client.limit_up.limit_up_down_pool.broken_limit(as_df=True)
|
|
253
|
+
|
|
254
|
+
print(df)
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**强势股池查询**
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
|
|
262
|
+
from sharetop import ShareTop
|
|
263
|
+
|
|
264
|
+
token = ""
|
|
265
|
+
|
|
266
|
+
client = ShareTop(token=token)
|
|
267
|
+
|
|
268
|
+
# 获取实时强势股池数据
|
|
269
|
+
df = client.limit_up.limit_up_down_pool.strong(as_df=True)
|
|
270
|
+
|
|
271
|
+
print(df)
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 更多文档
|
|
278
|
+
|
|
279
|
+
- [完整示例](https://docs.tickflow.org/zh-Hans/sdk/python-examples) — 查看更多使用场景和代码示例
|
|
280
|
+
- [最佳实践](https://docs.tickflow.org/zh-Hans/sdk/python-best-practices) — 了解生产环境的最佳实践
|
|
281
|
+
- [API 参考](https://docs.tickflow.org/zh-Hans/api-reference/introduction) — HTTP API 接口说明
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
MIT
|
sharetop-0.1.0/README.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# ShareTop Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/sharetop/)
|
|
4
|
+
[](https://pypi.org/project/sharetop/)
|
|
5
|
+
[](https://pypi.org/project/sharetop/)
|
|
6
|
+
[](https://docs.sharetop.org)
|
|
7
|
+
[](https://github.com/sharetop-org/sharetop)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
凡是数据皆有价值,前提是要放到正确位置,同时在正确的时间被使用。
|
|
12
|
+
|
|
13
|
+
ShareTop 是一个开源数据社区,主要为个人及科研团队在金融、宏观、汽车、石油等领域的科学研究提供数据清洗、结构化的API接口服务,它不以盈利为主要目的,不做任何荐股或者推荐。
|
|
14
|
+
|
|
15
|
+
ShareTop Python SDK 是 ShareTop 数据长期维护的 Python 客户端,提供 金融、宏观、汽车等相关行业存量和增量数据。
|
|
16
|
+
|
|
17
|
+
“数据仅供参考,不构成投资建议”
|
|
18
|
+
|
|
19
|
+
> **完整文档**:<https://sharetop.top>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 安装
|
|
24
|
+
|
|
25
|
+
使用 pip 安装 ShareTop Python SDK:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install sharetop
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
SDK 支持 Python 3.9+,推荐使用 Python 3.10 或更高版本。
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 获取token
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### 关注公众号并点击获取token
|
|
39
|
+
|
|
40
|
+
<img src="img/scan.png" alt="微信公众号二维码" width="300">
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## 初始化客户端
|
|
44
|
+
|
|
45
|
+
### 免费服务
|
|
46
|
+
|
|
47
|
+
如果你只需要日K线数据和股票基础信息,可以直接使用免费服务:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from sharetop import ShareTop
|
|
51
|
+
|
|
52
|
+
# 从微信公众号里面获取token
|
|
53
|
+
token = ""
|
|
54
|
+
|
|
55
|
+
client = ShareTop(token=token)
|
|
56
|
+
|
|
57
|
+
# 查询日K线数据
|
|
58
|
+
symbol = "601717.SH"
|
|
59
|
+
|
|
60
|
+
df = client.klines.get_history_data(symbol=symbol, count=500000, period="d", adjust="before", as_df=True)
|
|
61
|
+
print(df)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**免费服务特点:**
|
|
65
|
+
- ✅ 关注微信公众号,获取token,直接使用
|
|
66
|
+
- ✅ 提供历史日K线数据(d、w、m、q、y)
|
|
67
|
+
- ✅ 提供标的信息、交易所、标的池查询
|
|
68
|
+
- ❌ 不提供实时行情
|
|
69
|
+
- ❌ 不提供分钟级K线(1m、5m、15m、30m、60m、120m)
|
|
70
|
+
- ⚠️ 日K数据为历史数据,盘中不会实时更新
|
|
71
|
+
|
|
72
|
+
如果你需要实时行情、盘中实时更新的K线或更高频率访问,请使用完整服务。
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### 完整服务
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from sharetop import ShareTop
|
|
80
|
+
|
|
81
|
+
# 从微信公众号里面获取token
|
|
82
|
+
token = ""
|
|
83
|
+
|
|
84
|
+
client = ShareTop(token=token)
|
|
85
|
+
|
|
86
|
+
# 获取沪深 A 股实时行情
|
|
87
|
+
df = client.quotes.get(symbols="600000.SH,002522.SZ,000006.SZ,688003.SH,002534.SZ", as_df=True)
|
|
88
|
+
|
|
89
|
+
print(df)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
如果看到股票价格输出,说明 SDK 已配置成功!
|
|
93
|
+
|
|
94
|
+
**完整服务优势:**
|
|
95
|
+
- ✅ 实时行情数据
|
|
96
|
+
- ✅ 分钟级K线(5m、15m、30m、60m、120m)
|
|
97
|
+
- ✅ 日内分时数据
|
|
98
|
+
- ✅ 财报数据
|
|
99
|
+
- ✅ 更高的调用频率
|
|
100
|
+
- ✅ 打板专题数据
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 标的代码格式与支持市场
|
|
105
|
+
|
|
106
|
+
所有按标的查询的接口(行情、K 线等)均使用**统一标的代码**,格式为:**`代码.市场后缀`**(中间为英文点号)。
|
|
107
|
+
|
|
108
|
+
### 标的代码格式
|
|
109
|
+
|
|
110
|
+
- 格式:`代码.市场后缀`
|
|
111
|
+
- 示例:
|
|
112
|
+
- 股票:`600000.SH`(浦发银行)、`000001.SZ`(平安银行)、`920662.BJ`(方盛股份)
|
|
113
|
+
|
|
114
|
+
代码部分使用交易所官方代码(如 6 位 A 股代码、合约代码等),**市场后缀**见下表。
|
|
115
|
+
|
|
116
|
+
### 支持的市场(后缀)
|
|
117
|
+
|
|
118
|
+
| 后缀 | 市场 | 说明 |
|
|
119
|
+
|------|------|------|
|
|
120
|
+
| **SH** | 上海证券交易所 | 沪市 A 股、ETF、债券等 |
|
|
121
|
+
| **SZ** | 深圳证券交易所 | 深市 A 股、创业板、ETF 等 |
|
|
122
|
+
| **BJ** | 北京证券交易所 | 北交所股票 |
|
|
123
|
+
|
|
124
|
+
### 目前支持状态
|
|
125
|
+
|
|
126
|
+
- **A 股(SH / SZ / BJ)**:已支持。可查实时行情、日 K、分钟 K、日内分时、财务数据等。
|
|
127
|
+
|
|
128
|
+
按标的查询时传入上述格式的字符串或列表即可:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from sharetop import ShareTop
|
|
132
|
+
|
|
133
|
+
token = ""
|
|
134
|
+
|
|
135
|
+
client = ShareTop(token=token)
|
|
136
|
+
|
|
137
|
+
# 上交所整体实时数据
|
|
138
|
+
df = client.quotes.get(exchange=["SSE"], as_df=True)
|
|
139
|
+
|
|
140
|
+
print(df)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 基础用法
|
|
146
|
+
|
|
147
|
+
### K 线获取
|
|
148
|
+
|
|
149
|
+
**单个或者批量获取分钟k线**:
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from sharetop import ShareTop
|
|
153
|
+
|
|
154
|
+
token = ""
|
|
155
|
+
|
|
156
|
+
client = ShareTop(token=token)
|
|
157
|
+
|
|
158
|
+
symbols = ["601717.SH", "601928.SH"]
|
|
159
|
+
|
|
160
|
+
# 获取分钟 K 线,返回原始数据
|
|
161
|
+
kline_data = client.klines.get_batch_real_time(symbols=symbols, period="1m", count=5, adjust="before", as_df=True)
|
|
162
|
+
print(f"601717.SH最新的1min k线数据: {kline_data['601717.SH']}")
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 获取实时行情
|
|
167
|
+
|
|
168
|
+
**按标的代码查询**
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from sharetop import ShareTop
|
|
172
|
+
|
|
173
|
+
token = ""
|
|
174
|
+
|
|
175
|
+
client = ShareTop(token=token)
|
|
176
|
+
|
|
177
|
+
symbols = ["600000.SH", "002534.SZ", "688003.SH"]
|
|
178
|
+
|
|
179
|
+
df = client.quotes.get(symbols=symbols, as_df=True)
|
|
180
|
+
|
|
181
|
+
print(df)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**按标的池查询**
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
# 获取全部 上交所 A 股行情
|
|
188
|
+
quotes_a = client.quotes.get(exchange=["SSE"], as_df=True)
|
|
189
|
+
|
|
190
|
+
print(quotes_a)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
# 获取全部 上交所 深交所 A 股行情
|
|
194
|
+
quotes = client.quotes.get(exchange=["SSE", "SZSE"], as_df=True)
|
|
195
|
+
|
|
196
|
+
print(quotes)
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 获取打板数据
|
|
201
|
+
|
|
202
|
+
**炸板池查询**
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
|
|
206
|
+
from sharetop import ShareTop
|
|
207
|
+
|
|
208
|
+
token = ""
|
|
209
|
+
|
|
210
|
+
client = ShareTop(token=token)
|
|
211
|
+
|
|
212
|
+
# 获取实时炸板池数据
|
|
213
|
+
df = client.limit_up.limit_up_down_pool.broken_limit(as_df=True)
|
|
214
|
+
|
|
215
|
+
print(df)
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**强势股池查询**
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
|
|
223
|
+
from sharetop import ShareTop
|
|
224
|
+
|
|
225
|
+
token = ""
|
|
226
|
+
|
|
227
|
+
client = ShareTop(token=token)
|
|
228
|
+
|
|
229
|
+
# 获取实时强势股池数据
|
|
230
|
+
df = client.limit_up.limit_up_down_pool.strong(as_df=True)
|
|
231
|
+
|
|
232
|
+
print(df)
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 更多文档
|
|
239
|
+
|
|
240
|
+
- [完整示例](https://docs.tickflow.org/zh-Hans/sdk/python-examples) — 查看更多使用场景和代码示例
|
|
241
|
+
- [最佳实践](https://docs.tickflow.org/zh-Hans/sdk/python-best-practices) — 了解生产环境的最佳实践
|
|
242
|
+
- [API 参考](https://docs.tickflow.org/zh-Hans/api-reference/introduction) — HTTP API 接口说明
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
MIT
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sharetop"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "ShareTop Python Client"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.9"
|
|
7
|
+
license = {text = "MIT"}
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "ShareTop Team", email = "support@sharetop.top"}
|
|
10
|
+
]
|
|
11
|
+
keywords = ["finance", "stock", "market-data", "trading", "api-client"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Natural Language :: Chinese (Simplified)",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
27
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
]
|
|
30
|
+
dependencies = [
|
|
31
|
+
"httpx>=0.25.0",
|
|
32
|
+
"typing-extensions>=4.0.0",
|
|
33
|
+
"pandas>=1.5.0",
|
|
34
|
+
"aiohttp>=3.9.0",
|
|
35
|
+
"tqdm>=4.60.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
gevent = ["gevent>=23.0.0"]
|
|
40
|
+
full = ["sharetop[gevent]"]
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Documentation = "https://docs.sharetop.top"
|
|
44
|
+
Repository = "https://github.com/sharetop-org/sharetop"
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
48
|
+
build-backend = "setuptools.build_meta"
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.packages.find]
|
|
51
|
+
include = ["sharetop*"]
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.package-data]
|
|
54
|
+
sharetop = ["py.typed"]
|
|
55
|
+
|
|
56
|
+
[dependency-groups]
|
|
57
|
+
dev = [
|
|
58
|
+
"datamodel-code-generator[http]>=0.45.0",
|
|
59
|
+
"pytest>=7.0.0",
|
|
60
|
+
"pytest-asyncio>=0.21.0",
|
|
61
|
+
"ruff>=0.1.0",
|
|
62
|
+
"mypy>=1.0.0",
|
|
63
|
+
]
|
sharetop-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""ShareTop Python SDK - 高性能行情数据客户端。
|
|
2
|
+
|
|
3
|
+
支持 A股的基础数据和行情数据查询,提供同步和异步两种接口。
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .__version__ import __version__
|
|
8
|
+
from ._exceptions import (
|
|
9
|
+
APIError,
|
|
10
|
+
AuthenticationError,
|
|
11
|
+
BadRequestError,
|
|
12
|
+
ConnectionError,
|
|
13
|
+
InternalServerError,
|
|
14
|
+
NotFoundError,
|
|
15
|
+
PermissionError,
|
|
16
|
+
RateLimitError,
|
|
17
|
+
ShareTopError,
|
|
18
|
+
TimeoutError,
|
|
19
|
+
)
|
|
20
|
+
from .client import ShareTop
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"__version__",
|
|
25
|
+
# Main clients
|
|
26
|
+
"ShareTop",
|
|
27
|
+
# Exceptions
|
|
28
|
+
"ShareTopError",
|
|
29
|
+
"APIError",
|
|
30
|
+
"AuthenticationError",
|
|
31
|
+
"PermissionError",
|
|
32
|
+
"NotFoundError",
|
|
33
|
+
"BadRequestError",
|
|
34
|
+
"RateLimitError",
|
|
35
|
+
"InternalServerError",
|
|
36
|
+
"ConnectionError",
|
|
37
|
+
"TimeoutError",
|
|
38
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|