rquote 0.4.8__py3-none-any.whl → 0.4.9__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.
rquote/api/lists.py CHANGED
@@ -191,8 +191,11 @@ def get_cnindex_stocks(index_type='hs300'):
191
191
  # 指数类型到 TYPE 值的映射
192
192
  index_type_map = {
193
193
  'hs300': '1',
194
+ 'sz50': '2',
194
195
  'zz500': '3',
195
- 'zz1000': '7'
196
+ 'kc500': '4',
197
+ 'zz1000': '7',
198
+ 'zz2000': '13'
196
199
  }
197
200
 
198
201
  if index_type not in index_type_map:
@@ -202,6 +205,10 @@ def get_cnindex_stocks(index_type='hs300'):
202
205
 
203
206
  # 构建 URL
204
207
  base_url = 'https://datacenter-web.eastmoney.com/api/data/v1/get'
208
+ page_size = 500
209
+ all_data = []
210
+
211
+ # 先获取第一页,确定总数
205
212
  params = {
206
213
  'callback': 'jQuery112308471143523381743_1763517709888',
207
214
  'sortColumns': 'SECURITY_CODE',
@@ -232,7 +239,34 @@ def get_cnindex_stocks(index_type='hs300'):
232
239
 
233
240
  # 返回 result.data 中的数据列表
234
241
  if data.get('result') and data['result'].get('data'):
235
- return data['result']['data']
242
+ all_data.extend(data['result']['data'])
243
+ total = int(index_type[2:])
244
+
245
+ # 如果总数超过 page_size,需要分页获取
246
+ if total > page_size:
247
+ total_pages = (total + page_size - 1) // page_size # 向上取整
248
+
249
+ # 从第二页开始获取
250
+ for page_num in range(2, total_pages + 1):
251
+ params['pageNumber'] = str(page_num)
252
+ url = f'{base_url}?{urlencode(params)}'
253
+
254
+ a = hget(url)
255
+ if not a:
256
+ logger.warning(f'Failed to fetch page {page_num} for {index_type}')
257
+ continue
258
+
259
+ json_str = a.text.split('(', 1)[1].rstrip(');')
260
+ page_data = json.loads(json_str)
261
+
262
+ if page_data.get('result') and page_data['result'].get('data'):
263
+ all_data.extend(page_data['result']['data'])
264
+
265
+ # 避免请求过快
266
+ time.sleep(0.1)
267
+
268
+ logger.debug(f'Fetched {len(all_data)} stocks for {index_type} (total: {total})')
269
+ return all_data
236
270
  else:
237
271
  logger.warning(f'No data found in response for {index_type}')
238
272
  return []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rquote
3
- Version: 0.4.8
3
+ Version: 0.4.9
4
4
  Summary: Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch
5
5
  Requires-Python: >=3.9.0
6
6
  Description-Content-Type: text/markdown
@@ -18,7 +18,7 @@ Requires-Dist: duckdb>=0.9.0; extra == "persistent"
18
18
 
19
19
  ## 版本信息
20
20
 
21
- 当前版本:**0.4.8**
21
+ 当前版本:**0.4.9**
22
22
 
23
23
  ## 主要特性
24
24
 
@@ -4,7 +4,7 @@ rquote/exceptions.py,sha256=lJH2GC5dDhMoW_OtlBc03wlUn684-7jNPyF1NjmfVIE,569
4
4
  rquote/plots.py,sha256=UQn4sjhIzVwagfhUDM738b2HHjKo4tRdU2UCs_1-FbY,2341
5
5
  rquote/utils.py,sha256=bH0ZFIo-ZelNztzPS6BXFShXE3yGA9USI_P9INN0Y-s,310
6
6
  rquote/api/__init__.py,sha256=17VgPOKsbQX8kKcuU8fKqn4qOHxMamV9GBTXTCcbdvw,706
7
- rquote/api/lists.py,sha256=WGyliA9pkpPrN019xkhKL-5nzrmTGrsb8bnG8Zz4cRs,7395
7
+ rquote/api/lists.py,sha256=uCOESePsrWGfY8gZE70aqk8xJS8nMqOK1dD8zTPrpi4,8676
8
8
  rquote/api/price.py,sha256=I5lZl6cUQRlE4AtzNbR-uGZt1ho9vgP1cgNFDjaigMA,3575
9
9
  rquote/api/stock_info.py,sha256=h_AbgsR8CLWz5zA2PtGsS3ROQ3qcw_hnRAtG3USeMos,2988
10
10
  rquote/api/tick.py,sha256=nEcjuAjtBHUaD8KPRLg643piVa21PhKDQvkVWNwvvME,1431
@@ -33,7 +33,7 @@ rquote/utils/helpers.py,sha256=V07n9BtRS8bEJH023Kca78-unk7iD3B9hn2UjELetYs,354
33
33
  rquote/utils/http.py,sha256=X0Alhnu0CNqyQeOt6ivUWmh2XwrWxXd2lSpQOKDdnzw,3249
34
34
  rquote/utils/logging.py,sha256=fs2YF1Srux4LLTdk_Grjm5g1f4mzewI38VVSAI82goA,1471
35
35
  rquote/utils/web.py,sha256=I8_pcThW6VUvahuRHdtp32iZwr85hEt1hB6TgznMy_U,3854
36
- rquote-0.4.8.dist-info/METADATA,sha256=qZGWiccqGzatqJTn5pAgAvzk3OHIj2QqCJAziMuxFQU,14478
37
- rquote-0.4.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
- rquote-0.4.8.dist-info/top_level.txt,sha256=CehAiaZx7Fo8HGoV2zd5GhILUW1jQEN8YS-cWMlrK9Y,7
39
- rquote-0.4.8.dist-info/RECORD,,
36
+ rquote-0.4.9.dist-info/METADATA,sha256=QjWXGAaetxCapZOpA6GZHR-NykNLKSnZRJ6hStkVNwc,14478
37
+ rquote-0.4.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
+ rquote-0.4.9.dist-info/top_level.txt,sha256=CehAiaZx7Fo8HGoV2zd5GhILUW1jQEN8YS-cWMlrK9Y,7
39
+ rquote-0.4.9.dist-info/RECORD,,
File without changes