rquote 0.2.8__tar.gz → 0.2.9__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.2.8 → rquote-0.2.9}/PKG-INFO +2 -2
- {rquote-0.2.8 → rquote-0.2.9}/pyproject.toml +2 -2
- {rquote-0.2.8 → rquote-0.2.9}/rquote/main.py +34 -2
- {rquote-0.2.8 → rquote-0.2.9}/rquote.egg-info/PKG-INFO +2 -2
- {rquote-0.2.8 → rquote-0.2.9}/rquote.egg-info/requires.txt +1 -1
- {rquote-0.2.8 → rquote-0.2.9}/README.md +0 -0
- {rquote-0.2.8 → rquote-0.2.9}/rquote/__init__.py +0 -0
- {rquote-0.2.8 → rquote-0.2.9}/rquote/plots.py +0 -0
- {rquote-0.2.8 → rquote-0.2.9}/rquote/utils.py +0 -0
- {rquote-0.2.8 → rquote-0.2.9}/rquote.egg-info/SOURCES.txt +0 -0
- {rquote-0.2.8 → rquote-0.2.9}/rquote.egg-info/dependency_links.txt +0 -0
- {rquote-0.2.8 → rquote-0.2.9}/rquote.egg-info/top_level.txt +0 -0
- {rquote-0.2.8 → rquote-0.2.9}/setup.cfg +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rquote
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
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
|
|
7
7
|
Requires-Dist: httpx>=0.20.0
|
|
8
8
|
Requires-Dist: pandas>=1.0.0
|
|
9
|
-
Requires-Dist: setuptools>=
|
|
9
|
+
Requires-Dist: setuptools>=42
|
|
10
10
|
Requires-Dist: twine>=3.8.0
|
|
11
11
|
|
|
12
12
|
# rquote
|
|
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rquote"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.9"
|
|
8
8
|
description = "Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.6.1"
|
|
11
11
|
dependencies = [
|
|
12
12
|
"httpx>=0.20.0",
|
|
13
13
|
"pandas>=1.0.0",
|
|
14
|
-
"setuptools>=
|
|
14
|
+
"setuptools>=42",
|
|
15
15
|
"twine>=3.8.0",
|
|
16
16
|
]
|
|
@@ -114,6 +114,29 @@ def get_cn_future_list():
|
|
|
114
114
|
return futurelist_active
|
|
115
115
|
|
|
116
116
|
|
|
117
|
+
def _check_date_format(date_str):
|
|
118
|
+
# 允许格式: 2099-01-01
|
|
119
|
+
if not re.match(r'^\d{4}-\d{2}-\d{2}$', date_str):
|
|
120
|
+
# 尝试转换
|
|
121
|
+
try:
|
|
122
|
+
# 常见格式尝试
|
|
123
|
+
t_struct = None
|
|
124
|
+
for fmt in ("%Y/%m/%d", "%Y%m%d", "%Y.%m.%d", "%Y_%m_%d", "%Y-%m-%d"):
|
|
125
|
+
try:
|
|
126
|
+
t_struct = time.strptime(date_str, fmt)
|
|
127
|
+
break
|
|
128
|
+
except Exception:
|
|
129
|
+
continue
|
|
130
|
+
if t_struct is None:
|
|
131
|
+
raise ValueError(f"date format not recognized: {date_str}")
|
|
132
|
+
# 转换为标准格式
|
|
133
|
+
date_str_std = time.strftime("%Y-%m-%d", t_struct)
|
|
134
|
+
return date_str_std
|
|
135
|
+
except Exception as e:
|
|
136
|
+
raise ValueError(f"date format error: {date_str}, {e}")
|
|
137
|
+
return date_str
|
|
138
|
+
|
|
139
|
+
|
|
117
140
|
def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
118
141
|
dd=None) -> (str, str, pd.DataFrame):
|
|
119
142
|
'''
|
|
@@ -131,6 +154,12 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
131
154
|
logger.debug('loading price from dd {}'.format(i))
|
|
132
155
|
return i, n, d
|
|
133
156
|
logger.debug('fetching price of {}'.format(i))
|
|
157
|
+
|
|
158
|
+
# 检查sdate和edate格式
|
|
159
|
+
sdate = _check_date_format(sdate) if sdate else ''
|
|
160
|
+
edate = _check_date_format(edate) if edate else ''
|
|
161
|
+
|
|
162
|
+
|
|
134
163
|
qtimg_stock = 'http://web.ifzq.gtimg.cn/appstock/app/newfqkline/get?param=' + \
|
|
135
164
|
'{},{},{},{},{},{}'
|
|
136
165
|
qtimg_stock_hk = 'http://web.ifzq.gtimg.cn/appstock/app/hkfqkline/get?' + \
|
|
@@ -173,8 +202,7 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
173
202
|
|
|
174
203
|
if i[:2] == 'fu':
|
|
175
204
|
try:
|
|
176
|
-
|
|
177
|
-
if ix == 'btc' or ix == 'BTC':
|
|
205
|
+
if i[2:5].lower() == 'btc':
|
|
178
206
|
url = sina_btc
|
|
179
207
|
d = json.loads(hget(url).text)['result']['data'].split('|')
|
|
180
208
|
d = pd.DataFrame([i.split(',') for i in d],
|
|
@@ -430,4 +458,8 @@ def get_hk_stocks_hsi():
|
|
|
430
458
|
|
|
431
459
|
|
|
432
460
|
|
|
461
|
+
if __name__ == "__main__":
|
|
462
|
+
# print(get_cn_stock_list())
|
|
463
|
+
# print(get_price('fuBTC'))
|
|
464
|
+
print(get_price('sz000001', sdate='20240101', edate='20250101'))
|
|
433
465
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rquote
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
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
|
|
7
7
|
Requires-Dist: httpx>=0.20.0
|
|
8
8
|
Requires-Dist: pandas>=1.0.0
|
|
9
|
-
Requires-Dist: setuptools>=
|
|
9
|
+
Requires-Dist: setuptools>=42
|
|
10
10
|
Requires-Dist: twine>=3.8.0
|
|
11
11
|
|
|
12
12
|
# rquote
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|