rquote 0.3.5__tar.gz → 0.3.6__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.
- {rquote-0.3.5 → rquote-0.3.6}/PKG-INFO +1 -1
- {rquote-0.3.5 → rquote-0.3.6}/pyproject.toml +1 -1
- {rquote-0.3.5 → rquote-0.3.6}/rquote/__init__.py +1 -1
- {rquote-0.3.5 → rquote-0.3.6}/rquote/data_sources/sina.py +6 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/data_sources/tencent.py +7 -4
- {rquote-0.3.5 → rquote-0.3.6}/rquote/markets/cn_stock.py +1 -1
- {rquote-0.3.5 → rquote-0.3.6}/rquote/utils/web.py +5 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote.egg-info/PKG-INFO +1 -1
- {rquote-0.3.5 → rquote-0.3.6}/tests/test_api.py +1 -1
- {rquote-0.3.5 → rquote-0.3.6}/README.md +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/api/__init__.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/api/lists.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/api/price.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/api/stock_info.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/api/tick.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/cache/__init__.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/cache/base.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/cache/memory.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/config.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/data_sources/__init__.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/data_sources/base.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/exceptions.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/factors/__init__.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/factors/technical.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/markets/__init__.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/markets/base.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/markets/factory.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/markets/future.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/markets/hk_stock.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/markets/us_stock.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/parsers/__init__.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/parsers/kline.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/plots.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/utils/__init__.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/utils/date.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/utils/helpers.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/utils/http.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/utils/logging.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote/utils.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote.egg-info/SOURCES.txt +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote.egg-info/dependency_links.txt +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote.egg-info/requires.txt +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/rquote.egg-info/top_level.txt +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/setup.cfg +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/tests/test_cache.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/tests/test_config.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/tests/test_exceptions.py +0 -0
- {rquote-0.3.5 → rquote-0.3.6}/tests/test_utils.py +0 -0
|
@@ -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 = "
|
|
16
|
-
BASE_URL_HK = "
|
|
17
|
-
BASE_URL_US = "
|
|
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'
|
|
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}')
|
|
@@ -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
|
|
|
@@ -4,7 +4,7 @@ API测试(集成测试)
|
|
|
4
4
|
"""
|
|
5
5
|
import unittest
|
|
6
6
|
from rquote import get_price, get_cn_stock_list, get_all_industries
|
|
7
|
-
from rquote.exceptions import SymbolError, DataSourceError
|
|
7
|
+
from rquote.exceptions import SymbolError, DataSourceError, NetworkError
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class TestAPI(unittest.TestCase):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|