tickflow 0.1.0.dev0__py3-none-any.whl → 0.1.0.dev1__py3-none-any.whl
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.
- tickflow/__init__.py +18 -79
- tickflow/_base_client.py +213 -70
- tickflow/client.py +20 -13
- tickflow/generated_model.py +86 -84
- tickflow/resources/__init__.py +3 -3
- tickflow/resources/exchanges.py +49 -23
- tickflow/resources/instruments.py +180 -0
- tickflow/resources/klines.py +263 -29
- tickflow-0.1.0.dev1.dist-info/METADATA +109 -0
- tickflow-0.1.0.dev1.dist-info/RECORD +17 -0
- tickflow/resources/symbols.py +0 -176
- tickflow-0.1.0.dev0.dist-info/METADATA +0 -36
- tickflow-0.1.0.dev0.dist-info/RECORD +0 -17
- {tickflow-0.1.0.dev0.dist-info → tickflow-0.1.0.dev1.dist-info}/WHEEL +0 -0
- {tickflow-0.1.0.dev0.dist-info → tickflow-0.1.0.dev1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tickflow
|
|
3
|
+
Version: 0.1.0.dev1
|
|
4
|
+
Summary: TickFlow Python Client
|
|
5
|
+
Author: TickFlow Team
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Documentation, https://docs.tickflow.org
|
|
8
|
+
Project-URL: Repository, https://github.com/tickflow/tickflow-python
|
|
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: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
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
|
+
Provides-Extra: pandas
|
|
26
|
+
Requires-Dist: pandas>=1.5.0; extra == "pandas"
|
|
27
|
+
Provides-Extra: progress
|
|
28
|
+
Requires-Dist: tqdm>=4.60.0; extra == "progress"
|
|
29
|
+
Provides-Extra: all
|
|
30
|
+
Requires-Dist: pandas>=1.5.0; extra == "all"
|
|
31
|
+
Requires-Dist: tqdm>=4.60.0; extra == "all"
|
|
32
|
+
|
|
33
|
+
# TickFlow Python SDK
|
|
34
|
+
|
|
35
|
+
高性能行情数据 Python 客户端,支持 A股、美股、港股。
|
|
36
|
+
|
|
37
|
+
## 安装
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install tickflow
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
如需 DataFrame 支持和进度条功能:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install tickflow[all]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 快速开始
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from tickflow import TickFlow
|
|
53
|
+
|
|
54
|
+
# 初始化客户端
|
|
55
|
+
client = TickFlow(api_key="your-api-key")
|
|
56
|
+
|
|
57
|
+
# 获取 K 线数据
|
|
58
|
+
df = client.klines.get("600000.SH", period="1d", count=100, as_dataframe=True)
|
|
59
|
+
print(df.tail())
|
|
60
|
+
|
|
61
|
+
# 获取实时行情
|
|
62
|
+
quotes = client.quotes.get(symbols=["600000.SH", "AAPL.US"])
|
|
63
|
+
for q in quotes:
|
|
64
|
+
print(f"{q['symbol']}: {q['last_price']}")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 异步使用
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
import asyncio
|
|
71
|
+
from tickflow import AsyncTickFlow
|
|
72
|
+
|
|
73
|
+
async def main():
|
|
74
|
+
async with AsyncTickFlow(api_key="your-api-key") as client:
|
|
75
|
+
df = await client.klines.get("600000.SH", as_dataframe=True)
|
|
76
|
+
print(df.tail())
|
|
77
|
+
|
|
78
|
+
asyncio.run(main())
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 批量获取
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
# 批量获取大量股票数据,自动分批并发请求
|
|
85
|
+
symbols = client.exchanges.get_symbols("SH")[:500]
|
|
86
|
+
df = client.klines.batch(
|
|
87
|
+
symbols,
|
|
88
|
+
period="1d",
|
|
89
|
+
as_dataframe=True,
|
|
90
|
+
show_progress=True # 显示进度条
|
|
91
|
+
)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 特性
|
|
95
|
+
|
|
96
|
+
- ✅ 同步/异步双接口
|
|
97
|
+
- ✅ DataFrame 原生支持
|
|
98
|
+
- ✅ 自动重试(网络错误、服务器错误)
|
|
99
|
+
- ✅ 批量请求自动分片
|
|
100
|
+
- ✅ 进度条支持
|
|
101
|
+
- ✅ 完整类型注解
|
|
102
|
+
|
|
103
|
+
## 文档
|
|
104
|
+
|
|
105
|
+
完整文档请访问:https://docs.tickflow.org
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
tickflow/__init__.py,sha256=DirYoqzbnLlaMuzUVyXTCH1glwLKETbItwpUIag6Kdc,1540
|
|
2
|
+
tickflow/_base_client.py,sha256=wjOG2BYYYn_SN97zm9bIWXSYJjPxgHJYbLlDgW9hrFw,15494
|
|
3
|
+
tickflow/_exceptions.py,sha256=ckzZdwZQHwZOQD-nstsh8vIneUun2J3KU6i49TZ6UrI,3024
|
|
4
|
+
tickflow/_types.py,sha256=bewfzijcLJwjQNRs6WXv_i62wUu5Vtn4XFeRkc15ch0,1371
|
|
5
|
+
tickflow/client.py,sha256=O5a-W1A6-U5Ftdwp41f7itU3-iwyjvLgWW3pydVj6ps,8109
|
|
6
|
+
tickflow/generated_model.py,sha256=yRFZqmQMbhn3WwQ4U_cRTPYB1WDX3NSKwPEm2e3uUUg,5656
|
|
7
|
+
tickflow/resources/__init__.py,sha256=JayIwwlrRnSAI83fy97LfFstiYGz3qzdmbxApiIJNtU,477
|
|
8
|
+
tickflow/resources/_base.py,sha256=KcaNDouymvPp9FC4QJuYzBdioYB2wTIIdmLKoomtb58,667
|
|
9
|
+
tickflow/resources/exchanges.py,sha256=EtWBcOA_3VG9OaCHwXJ0HMjZIxylFoJu6XS8nzvv7_w,4580
|
|
10
|
+
tickflow/resources/instruments.py,sha256=xE0IK42MuyWQAhlObC_9Xecm-JnrDHu281t_NzqoPis,5863
|
|
11
|
+
tickflow/resources/klines.py,sha256=h13Ptou-d074gl0BB9irUnJ_iwaTxK0B-l7LXrH3tsE,23674
|
|
12
|
+
tickflow/resources/quotes.py,sha256=nC4xniwOtQbkgixCrl-wheJarGXxIG2hjwkLNBmwbxk,12161
|
|
13
|
+
tickflow/resources/universes.py,sha256=Pk--9Zlt6vfq9SzzkuJENkDAUUGmqiq4kdeOjMKXWQU,4542
|
|
14
|
+
tickflow-0.1.0.dev1.dist-info/METADATA,sha256=uc0c3JSIkInbvuc42bMFyKr-cNenJAJKkLT86A9srsU,2682
|
|
15
|
+
tickflow-0.1.0.dev1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
16
|
+
tickflow-0.1.0.dev1.dist-info/top_level.txt,sha256=_0JOxGpAnD-wmnVj9CKo6Bwp2qNC0xWdbDXJX8B1jrs,9
|
|
17
|
+
tickflow-0.1.0.dev1.dist-info/RECORD,,
|
tickflow/resources/symbols.py
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"""Symbol metadata resources for TickFlow API."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from typing import TYPE_CHECKING, List, Union, overload
|
|
6
|
-
|
|
7
|
-
from ._base import AsyncResource, SyncResource
|
|
8
|
-
|
|
9
|
-
if TYPE_CHECKING:
|
|
10
|
-
from ..generated_model import SymbolMeta
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class Symbols(SyncResource):
|
|
14
|
-
"""Synchronous interface for symbol metadata endpoints.
|
|
15
|
-
|
|
16
|
-
Examples
|
|
17
|
-
--------
|
|
18
|
-
>>> client = TickFlow(api_key="your-key")
|
|
19
|
-
>>> meta = client.symbols.get("600000.SH")
|
|
20
|
-
>>> print(f"{meta['symbol']}: {meta['name']}")
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
@overload
|
|
24
|
-
def get(self, symbol: str) -> "SymbolMeta": ...
|
|
25
|
-
|
|
26
|
-
@overload
|
|
27
|
-
def get(self, symbol: List[str]) -> List["SymbolMeta"]: ...
|
|
28
|
-
|
|
29
|
-
def get(
|
|
30
|
-
self, symbol: Union[str, List[str]]
|
|
31
|
-
) -> Union["SymbolMeta", List["SymbolMeta"]]:
|
|
32
|
-
"""Get metadata for one or more symbols.
|
|
33
|
-
|
|
34
|
-
Parameters
|
|
35
|
-
----------
|
|
36
|
-
symbol : str or list of str
|
|
37
|
-
Symbol code(s). Can be a single symbol string or a list of symbols.
|
|
38
|
-
|
|
39
|
-
Returns
|
|
40
|
-
-------
|
|
41
|
-
SymbolMeta or list of SymbolMeta
|
|
42
|
-
If a single symbol is provided, returns a single SymbolMeta dict.
|
|
43
|
-
If a list is provided, returns a list of SymbolMeta dicts.
|
|
44
|
-
|
|
45
|
-
Each SymbolMeta 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: Symbol name
|
|
51
|
-
- symbol_type: Type (stock, etf, index, etc.)
|
|
52
|
-
- ext: Market-specific extension data
|
|
53
|
-
|
|
54
|
-
Examples
|
|
55
|
-
--------
|
|
56
|
-
>>> # Single symbol
|
|
57
|
-
>>> meta = client.symbols.get("600000.SH")
|
|
58
|
-
>>> print(meta['name'])
|
|
59
|
-
|
|
60
|
-
>>> # Multiple symbols
|
|
61
|
-
>>> metas = client.symbols.get(["600000.SH", "AAPL.US"])
|
|
62
|
-
>>> for m in metas:
|
|
63
|
-
... print(f"{m['symbol']}: {m['name']}")
|
|
64
|
-
"""
|
|
65
|
-
if isinstance(symbol, str):
|
|
66
|
-
response = self._client.get("/v1/symbols", params={"symbols": symbol})
|
|
67
|
-
data = response["data"]
|
|
68
|
-
return data[0] if data else {}
|
|
69
|
-
else:
|
|
70
|
-
# Use POST for batch queries
|
|
71
|
-
response = self._client.post("/v1/symbols", json={"symbols": symbol})
|
|
72
|
-
return response["data"]
|
|
73
|
-
|
|
74
|
-
def batch(self, symbols: List[str]) -> List["SymbolMeta"]:
|
|
75
|
-
"""Get metadata for multiple symbols.
|
|
76
|
-
|
|
77
|
-
This method uses POST to handle large batches without URL length limits.
|
|
78
|
-
|
|
79
|
-
Parameters
|
|
80
|
-
----------
|
|
81
|
-
symbols : list of str
|
|
82
|
-
List of symbol codes (up to 1000).
|
|
83
|
-
|
|
84
|
-
Returns
|
|
85
|
-
-------
|
|
86
|
-
list of SymbolMeta
|
|
87
|
-
List of symbol metadata dicts.
|
|
88
|
-
|
|
89
|
-
Examples
|
|
90
|
-
--------
|
|
91
|
-
>>> metas = client.symbols.batch(["600000.SH", "000001.SZ", "AAPL.US"])
|
|
92
|
-
>>> for m in metas:
|
|
93
|
-
... print(f"{m['symbol']}: {m['name']}")
|
|
94
|
-
"""
|
|
95
|
-
response = self._client.post("/v1/symbols", json={"symbols": symbols})
|
|
96
|
-
return response["data"]
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
class AsyncSymbols(AsyncResource):
|
|
100
|
-
"""Asynchronous interface for symbol metadata endpoints.
|
|
101
|
-
|
|
102
|
-
Examples
|
|
103
|
-
--------
|
|
104
|
-
>>> async with AsyncTickFlow(api_key="your-key") as client:
|
|
105
|
-
... meta = await client.symbols.get("600000.SH")
|
|
106
|
-
"""
|
|
107
|
-
|
|
108
|
-
@overload
|
|
109
|
-
async def get(self, symbol: str) -> "SymbolMeta": ...
|
|
110
|
-
|
|
111
|
-
@overload
|
|
112
|
-
async def get(self, symbol: List[str]) -> List["SymbolMeta"]: ...
|
|
113
|
-
|
|
114
|
-
async def get(
|
|
115
|
-
self, symbol: Union[str, List[str]]
|
|
116
|
-
) -> Union["SymbolMeta", List["SymbolMeta"]]:
|
|
117
|
-
"""Get metadata for one or more symbols.
|
|
118
|
-
|
|
119
|
-
Parameters
|
|
120
|
-
----------
|
|
121
|
-
symbol : str or list of str
|
|
122
|
-
Symbol code(s). Can be a single symbol string or a list of symbols.
|
|
123
|
-
|
|
124
|
-
Returns
|
|
125
|
-
-------
|
|
126
|
-
SymbolMeta or list of SymbolMeta
|
|
127
|
-
If a single symbol is provided, returns a single SymbolMeta dict.
|
|
128
|
-
If a list is provided, returns a list of SymbolMeta dicts.
|
|
129
|
-
|
|
130
|
-
Each SymbolMeta contains:
|
|
131
|
-
- symbol: Full symbol code (e.g., "600000.SH")
|
|
132
|
-
- code: Exchange-specific code (e.g., "600000")
|
|
133
|
-
- exchange: Exchange code (e.g., "SH")
|
|
134
|
-
- region: Region code (e.g., "CN")
|
|
135
|
-
- name: Symbol name
|
|
136
|
-
- symbol_type: Type (stock, etf, index, etc.)
|
|
137
|
-
- ext: Market-specific extension data
|
|
138
|
-
|
|
139
|
-
Examples
|
|
140
|
-
--------
|
|
141
|
-
>>> # Single symbol
|
|
142
|
-
>>> meta = await client.symbols.get("600000.SH")
|
|
143
|
-
>>> print(meta['name'])
|
|
144
|
-
|
|
145
|
-
>>> # Multiple symbols
|
|
146
|
-
>>> metas = await client.symbols.get(["600000.SH", "AAPL.US"])
|
|
147
|
-
"""
|
|
148
|
-
if isinstance(symbol, str):
|
|
149
|
-
response = await self._client.get("/v1/symbols", params={"symbols": symbol})
|
|
150
|
-
data = response["data"]
|
|
151
|
-
return data[0] if data else {}
|
|
152
|
-
else:
|
|
153
|
-
response = await self._client.post("/v1/symbols", json={"symbols": symbol})
|
|
154
|
-
return response["data"]
|
|
155
|
-
|
|
156
|
-
async def batch(self, symbols: List[str]) -> List["SymbolMeta"]:
|
|
157
|
-
"""Get metadata for multiple symbols.
|
|
158
|
-
|
|
159
|
-
This method uses POST to handle large batches without URL length limits.
|
|
160
|
-
|
|
161
|
-
Parameters
|
|
162
|
-
----------
|
|
163
|
-
symbols : list of str
|
|
164
|
-
List of symbol codes (up to 1000).
|
|
165
|
-
|
|
166
|
-
Returns
|
|
167
|
-
-------
|
|
168
|
-
list of SymbolMeta
|
|
169
|
-
List of symbol metadata dicts.
|
|
170
|
-
|
|
171
|
-
Examples
|
|
172
|
-
--------
|
|
173
|
-
>>> metas = await client.symbols.batch(["600000.SH", "000001.SZ", "AAPL.US"])
|
|
174
|
-
"""
|
|
175
|
-
response = await self._client.post("/v1/symbols", json={"symbols": symbols})
|
|
176
|
-
return response["data"]
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: tickflow
|
|
3
|
-
Version: 0.1.0.dev0
|
|
4
|
-
Summary: TickFlow Python Client - High-performance market data API for A-shares, US stocks, and Hong Kong stocks
|
|
5
|
-
Author: TickFlow Team
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://tickflow.org
|
|
8
|
-
Project-URL: Documentation, https://docs.tickflow.org
|
|
9
|
-
Project-URL: Repository, https://github.com/tickflow/tickflow-python
|
|
10
|
-
Keywords: finance,market-data,stocks,trading,api-client,async
|
|
11
|
-
Classifier: Development Status :: 4 - Beta
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
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: Topic :: Office/Business :: Financial :: Investment
|
|
22
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
-
Classifier: Typing :: Typed
|
|
24
|
-
Requires-Python: >=3.9
|
|
25
|
-
Description-Content-Type: text/markdown
|
|
26
|
-
Requires-Dist: httpx>=0.28.1
|
|
27
|
-
Requires-Dist: pandas>=1.3.0
|
|
28
|
-
Requires-Dist: typing-extensions>=4.0.0
|
|
29
|
-
Provides-Extra: pandas
|
|
30
|
-
Requires-Dist: pandas>=1.3.0; extra == "pandas"
|
|
31
|
-
Provides-Extra: all
|
|
32
|
-
Requires-Dist: pandas>=1.3.0; extra == "all"
|
|
33
|
-
Provides-Extra: dev
|
|
34
|
-
Requires-Dist: datamodel-code-generator[http]>=0.45.0; extra == "dev"
|
|
35
|
-
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
36
|
-
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
tickflow/__init__.py,sha256=ZP7_vxm2g-PEMDJAxRjUIDB0S5WQ7DRIKjBJVFvD3uc,3061
|
|
2
|
-
tickflow/_base_client.py,sha256=akiDPhdQUjxJU_xaBvlUmo4LnGKLaq6_WIVlEX9DHzM,10622
|
|
3
|
-
tickflow/_exceptions.py,sha256=ckzZdwZQHwZOQD-nstsh8vIneUun2J3KU6i49TZ6UrI,3024
|
|
4
|
-
tickflow/_types.py,sha256=bewfzijcLJwjQNRs6WXv_i62wUu5Vtn4XFeRkc15ch0,1371
|
|
5
|
-
tickflow/client.py,sha256=PZdWYGRYWF-xUkn1s2qHdrlmDBASludadcH1T9jy5B0,7674
|
|
6
|
-
tickflow/generated_model.py,sha256=YNvz4TG9Fajh_s_Cfn40_pkAnndI81r6clB5OR9Fdkk,5410
|
|
7
|
-
tickflow/resources/__init__.py,sha256=RLaTibvIPX4GSATttmzJfoiFg81p4S_b4pgfFx0pP8c,457
|
|
8
|
-
tickflow/resources/_base.py,sha256=KcaNDouymvPp9FC4QJuYzBdioYB2wTIIdmLKoomtb58,667
|
|
9
|
-
tickflow/resources/exchanges.py,sha256=qPVvjsZLuISuMfElD_BSYSNS2CIuLqm_dsfeI6OrXOs,3414
|
|
10
|
-
tickflow/resources/klines.py,sha256=Wx11iX9AK1qOIAxxkcTqI36FpnK--BUzNLydks4342E,15632
|
|
11
|
-
tickflow/resources/quotes.py,sha256=nC4xniwOtQbkgixCrl-wheJarGXxIG2hjwkLNBmwbxk,12161
|
|
12
|
-
tickflow/resources/symbols.py,sha256=T33FX3FzM6h2JebXMJVNcjM5eSWiQ2vp63DJk4PmYcA,5664
|
|
13
|
-
tickflow/resources/universes.py,sha256=Pk--9Zlt6vfq9SzzkuJENkDAUUGmqiq4kdeOjMKXWQU,4542
|
|
14
|
-
tickflow-0.1.0.dev0.dist-info/METADATA,sha256=98ipSJKIB7cpOKy8tJVcNjYP1d7ntC-VEte74qot2nY,1587
|
|
15
|
-
tickflow-0.1.0.dev0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
16
|
-
tickflow-0.1.0.dev0.dist-info/top_level.txt,sha256=_0JOxGpAnD-wmnVj9CKo6Bwp2qNC0xWdbDXJX8B1jrs,9
|
|
17
|
-
tickflow-0.1.0.dev0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|