rquote 0.3.5__py3-none-any.whl → 0.3.6__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/__init__.py CHANGED
@@ -34,7 +34,7 @@ from . import exceptions
34
34
  from .cache import MemoryCache, Cache
35
35
  from .utils.http import HTTPClient
36
36
 
37
- __version__ = '0.3.5'
37
+ __version__ = '0.3.6'
38
38
 
39
39
  __all__ = [
40
40
  # API函数
@@ -57,6 +57,9 @@ class SinaDataSource(DataSource):
57
57
  return {'data': data}
58
58
  except json.JSONDecodeError as e:
59
59
  raise ParseError(f"Parse error: {e}")
60
+ finally:
61
+ # 确保响应对象被关闭,释放SSL连接
62
+ response.close()
60
63
 
61
64
  def fetch_tick(self, symbols: List[str]) -> Dict[str, Any]:
62
65
  """
@@ -89,4 +92,7 @@ class SinaDataSource(DataSource):
89
92
  return {'data': result}
90
93
  except Exception as e:
91
94
  raise ParseError(f"Parse tick error: {e}")
95
+ finally:
96
+ # 确保响应对象被关闭,释放SSL连接
97
+ response.close()
92
98
 
@@ -12,9 +12,9 @@ from ..exceptions import DataSourceError, ParseError
12
12
  class TencentDataSource(DataSource):
13
13
  """腾讯数据源"""
14
14
 
15
- BASE_URL = "http://web.ifzq.gtimg.cn/appstock/app/newfqkline/get"
16
- BASE_URL_HK = "http://web.ifzq.gtimg.cn/appstock/app/hkfqkline/get"
17
- BASE_URL_US = "http://web.ifzq.gtimg.cn/appstock/app/usfqkline/get"
15
+ BASE_URL = "https://web.ifzq.gtimg.cn/appstock/app/newfqkline/get"
16
+ BASE_URL_HK = "https://web.ifzq.gtimg.cn/appstock/app/hkfqkline/get"
17
+ BASE_URL_US = "https://web.ifzq.gtimg.cn/appstock/app/usfqkline/get"
18
18
 
19
19
  def __init__(self, http_client: HTTPClient = None):
20
20
  """
@@ -56,7 +56,7 @@ class TencentDataSource(DataSource):
56
56
  if not response:
57
57
  raise DataSourceError(f"Failed to fetch from Tencent: {symbol}")
58
58
 
59
- # 解析响应
59
+ # 解析响应,确保响应对象被正确关闭
60
60
  try:
61
61
  text = response.text
62
62
  # 处理不同的响应格式
@@ -83,6 +83,9 @@ class TencentDataSource(DataSource):
83
83
  return data
84
84
  except json.JSONDecodeError as e:
85
85
  raise ParseError(f"Parse error: {e}")
86
+ finally:
87
+ # 确保响应对象被关闭,释放SSL连接
88
+ response.close()
86
89
 
87
90
  def fetch_tick(self, symbols: List[str]) -> Dict[str, Any]:
88
91
  """获取实时行情(暂未实现)"""
@@ -159,7 +159,7 @@ class CNStockMarket(Market):
159
159
  from ..utils import hget
160
160
  import json
161
161
 
162
- url = f'http://web.ifzq.gtimg.cn/appstock/app/newfqkline/get?param={symbol},{freq},{sdate},{edate},{days},{fq}'
162
+ url = f'https://web.ifzq.gtimg.cn/appstock/app/newfqkline/get?param={symbol},{freq},{sdate},{edate},{days},{fq}'
163
163
  response = hget(url)
164
164
  if not response:
165
165
  raise DataSourceError(f'Failed to fetch data for {symbol}')
rquote/utils/web.py CHANGED
@@ -91,6 +91,7 @@ class hget:
91
91
  """
92
92
  def __init__(self, url, *args, **kwargs):
93
93
  self.url = url
94
+ r = None
94
95
  try:
95
96
  r = httpx.get(
96
97
  self.url, follow_redirects=True, headers=WebUtils.headers(),
@@ -101,4 +102,8 @@ class hget:
101
102
  logger.error(f'fetch {self.url} err: {e}')
102
103
  self.text = ''
103
104
  self.content = b''
105
+ finally:
106
+ # 确保响应对象被关闭,释放SSL连接
107
+ if r is not None:
108
+ r.close()
104
109
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rquote
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch
5
5
  Requires-Python: >=3.6.1
6
6
  Description-Content-Type: text/markdown
@@ -1,4 +1,4 @@
1
- rquote/__init__.py,sha256=3FBv99rWXPeBk5g7iGA-X7bgl5DVBh01oiVLL9ugxXI,1159
1
+ rquote/__init__.py,sha256=l0zLfBtpfQB401d5EE4GLja3EAWu03LwWXopqFtwMmY,1159
2
2
  rquote/config.py,sha256=noep_VzY_nJehnkPQb4mkwzpeYLwkU1riqofQJ6Hhw0,1108
3
3
  rquote/exceptions.py,sha256=lJH2GC5dDhMoW_OtlBc03wlUn684-7jNPyF1NjmfVIE,569
4
4
  rquote/plots.py,sha256=UQn4sjhIzVwagfhUDM738b2HHjKo4tRdU2UCs_1-FbY,2341
@@ -13,13 +13,13 @@ rquote/cache/base.py,sha256=orzG4Yo-6gzVG027j1-LTZPT718JohnCdLDnOLoLUQ4,515
13
13
  rquote/cache/memory.py,sha256=7z4keb3q91pzI4ASQWy1MU8T5nbWLCEUjJcStv_3hvk,1933
14
14
  rquote/data_sources/__init__.py,sha256=WCe1aam4677jM5G6wP4a-dQFTeBzcU5PJqsKieAVMBo,215
15
15
  rquote/data_sources/base.py,sha256=JuKsTMxH7y8yRxHg3JbLzQwXPr43rS4pnwc5625u2U4,443
16
- rquote/data_sources/sina.py,sha256=Ab14I7KLaBCZd9peLvv5H38C41qPnsBgIZ5kETi6lA8,3088
17
- rquote/data_sources/tencent.py,sha256=yRVtIt2RNe8zPMt_vgjeY0aTZCvUklVmfpzD6xyu7rc,3225
16
+ rquote/data_sources/sina.py,sha256=T_3Dl0Mwlhx8CKRJll_UKobYecRWltGaIOiGkpHS43Q,3300
17
+ rquote/data_sources/tencent.py,sha256=ayt1O85pheLwzX3z5c6Qij1NrmUywcsz6YcSVzdDoME,3370
18
18
  rquote/factors/__init__.py,sha256=_ZbH2XxYtXwCJpvRVdNvGncoPSpMqrtlYmf1_fMGIjM,116
19
19
  rquote/factors/technical.py,sha256=dPDs3pDEDRV9iQJBrSoKpGFLQMjOqyoBdN2rUntpOUU,4235
20
20
  rquote/markets/__init__.py,sha256=k4F8cZgb-phqemMqhZXFPdOKsR4P--DD3d5i21vKhbg,365
21
21
  rquote/markets/base.py,sha256=DjvxRcJqwUsBTxnsE28Gd-zJLFsCGwdQpezLRAZ_9sQ,1347
22
- rquote/markets/cn_stock.py,sha256=5qy7w5ouUqrP7VmMPO-dhmgCk4gLI5qlYCQoE3fFuwc,8063
22
+ rquote/markets/cn_stock.py,sha256=xf-uXDvkdPBPuc-4-VhEsX0OrxSsaMVsCl1wmSqnVl0,8064
23
23
  rquote/markets/factory.py,sha256=4Txpuok0LBOLT_vAiIU-NslwVnYF7sKHCdlacAboxpo,2875
24
24
  rquote/markets/future.py,sha256=AbA-gpmBhbyrRJn8Vu-ouQLCd-TlacXSVZQ2VHYn2pg,3907
25
25
  rquote/markets/hk_stock.py,sha256=iz0BriBDNGLkUCPExcCbe2jmuoqJinxx_cbDtKblABc,1445
@@ -31,8 +31,8 @@ rquote/utils/date.py,sha256=nhK3xQ2kFvKhdkPw-2HR2V0PSzBfXmX8L7laG7VmG2E,913
31
31
  rquote/utils/helpers.py,sha256=V07n9BtRS8bEJH023Kca78-unk7iD3B9hn2UjELetYs,354
32
32
  rquote/utils/http.py,sha256=X0Alhnu0CNqyQeOt6ivUWmh2XwrWxXd2lSpQOKDdnzw,3249
33
33
  rquote/utils/logging.py,sha256=cbeRH4ODazn7iyQmGoEBT2lH5LX4Ca3zDfs_20J1T28,566
34
- rquote/utils/web.py,sha256=rjDTbF34U0A0kP6_iD7gQstEIvTvI-b4zUw9kcY_FJk,3704
35
- rquote-0.3.5.dist-info/METADATA,sha256=QOI97iovyW1IrfbctXHV4t2YqadvUshl7A-rylzaFZY,11248
36
- rquote-0.3.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- rquote-0.3.5.dist-info/top_level.txt,sha256=CehAiaZx7Fo8HGoV2zd5GhILUW1jQEN8YS-cWMlrK9Y,7
38
- rquote-0.3.5.dist-info/RECORD,,
34
+ rquote/utils/web.py,sha256=I8_pcThW6VUvahuRHdtp32iZwr85hEt1hB6TgznMy_U,3854
35
+ rquote-0.3.6.dist-info/METADATA,sha256=IJ2xLFbl5KeQ_LktJ58cXTvmUC48ua4xzO2q6obGTN4,11248
36
+ rquote-0.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
+ rquote-0.3.6.dist-info/top_level.txt,sha256=CehAiaZx7Fo8HGoV2zd5GhILUW1jQEN8YS-cWMlrK9Y,7
38
+ rquote-0.3.6.dist-info/RECORD,,
File without changes