alphakit-sdk 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.
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: alphakit-sdk
3
+ Version: 0.1.0
4
+ Summary: AlphaKit — 简洁的金融数据 API 工具包
5
+ Author: AlphaKit Team
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/alphakit
8
+ Keywords: finance,data,api,quant,alpha
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: Topic :: Office/Business :: Financial
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: requests>=2.28.0
21
+ Requires-Dist: pandas>=1.3.0
22
+
23
+ # AlphaKit
24
+
25
+ 简洁的金融数据 API 工具包,提供类似 tushare 的使用体验。
26
+
27
+ ## 安装
28
+
29
+ ```bash
30
+ pip install alphakit
31
+ ```
32
+
33
+ 本地开发安装:
34
+ ```bash
35
+ cd TokenAuth
36
+ pip install -e .
37
+ ```
38
+
39
+ ## 快速开始
40
+
41
+ ### 方式一:全局 token(推荐)
42
+
43
+ ```python
44
+ import alphakit as ak
45
+
46
+ # 设置全局 token
47
+ ak.set_token('your_token_here')
48
+
49
+ # 创建 API 实例
50
+ api = ak.AlphaKit()
51
+
52
+ # 查询数据
53
+ df = api.daily_basic(trade_date='20260101')
54
+ print(df.head())
55
+ ```
56
+
57
+ ### 方式二:实例化时传入 token
58
+
59
+ ```python
60
+ from alphakit import AlphaKit
61
+
62
+ api = AlphaKit(token='your_token_here')
63
+ df = api.opt_daily(ts_code='10004355.SH', start_date='20260101', end_date='20260131')
64
+ ```
65
+
66
+ ### 方式三:自定义服务器地址
67
+
68
+ ```python
69
+ import alphakit as ak
70
+
71
+ ak.set_token('your_token')
72
+ api = ak.AlphaKit(base_url='http://your-server.com:8002')
73
+ df = api.etf_daily(ts_code='510050.SH', trade_date='20260101')
74
+ ```
75
+
76
+ ## API 方法
77
+
78
+ 所有方法返回 pandas DataFrame。
79
+
80
+ ### 日线基础数据
81
+ ```python
82
+ df = api.daily_basic(
83
+ ts_code='000001.SZ', # 可选
84
+ trade_date='20260101', # 可选
85
+ start_date='20260101', # 可选
86
+ end_date='20260131' # 可选
87
+ )
88
+ ```
89
+
90
+ ### 期权数据
91
+ ```python
92
+ # 期权基础信息
93
+ df = api.opt_basic(ts_code='10004355.SH')
94
+
95
+ # 期权日线
96
+ df = api.opt_daily(
97
+ ts_code='10004355.SH',
98
+ start_date='20260101',
99
+ end_date='20260131'
100
+ )
101
+ ```
102
+
103
+ ### ETF 数据
104
+ ```python
105
+ # ETF 基础信息
106
+ df = api.etf_basic(market='SSE')
107
+
108
+ # ETF 日线
109
+ df = api.etf_daily(ts_code='510050.SH', trade_date='20260101')
110
+
111
+ # ETF 净值
112
+ df = api.etf_nav(ts_code='510050.SH', nav_date='20260101')
113
+
114
+ # ETF 份额
115
+ df = api.etf_share(ts_code='510050.SH', trade_date='20260101')
116
+
117
+ # ETF 主题
118
+ df = api.etf_theme_map(theme='科技')
119
+ ```
120
+
121
+ ### 通用查询(支持所有表)
122
+ ```python
123
+ df = api.query('daily_basic', ts_code='000001.SZ', trade_date='20260101')
124
+ ```
125
+
126
+ ## 错误处理
127
+
128
+ ```python
129
+ from alphakit import AlphaKit, AlphaKitError
130
+
131
+ api = AlphaKit(token='your_token')
132
+
133
+ try:
134
+ df = api.daily_basic(trade_date='20260101')
135
+ except AlphaKitError as e:
136
+ print(f"错误码: {e.code}")
137
+ print(f"错误信息: {e.message}")
138
+ ```
139
+
140
+ 常见错误码:
141
+ - `1001`: Token 无效 / 过期 / 吊销
142
+ - `1002`: 无权限访问该表
143
+ - `1003`: IP 超限 / 封禁
144
+ - `1004`: 每分钟限频
145
+ - `1005`: 每日配额用尽
146
+ - `1006`: 查询参数错误
147
+
148
+ ## 注意事项
149
+
150
+ 1. **大表必须带过滤条件**:`daily_basic`、`opt_daily`、`etf_daily` 等大表必须带 `ts_code` 或日期过滤,否则报错 1006
151
+ 2. **日期格式**:`YYYYMMDD`(如 `20260101`)
152
+ 3. **IP 限制**:每个 token 默认最多绑定 3 个 IP,超限拒绝
153
+ 4. **限流配额**:默认每分钟 60 次、每日 500 次
154
+
155
+ ## 示例脚本
156
+
157
+ ```python
158
+ import alphakit as ak
159
+
160
+ ak.set_token('your_64_char_token_here')
161
+ api = ak.AlphaKit()
162
+
163
+ # 查某股票某天的数据
164
+ df = api.daily_basic(ts_code='000001.SZ', trade_date='20260101')
165
+ print(df)
166
+
167
+ # 查某期权某月的行情
168
+ df = api.opt_daily(ts_code='10004355.SH', start_date='20260101', end_date='20260131')
169
+ print(df.tail())
170
+
171
+ # 查所有 ETF 基础信息(小表可不带过滤)
172
+ df = api.etf_basic()
173
+ print(f"共 {len(df)} 只 ETF")
174
+ ```