rquote 0.3.0__tar.gz → 0.3.3__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.0 → rquote-0.3.3}/PKG-INFO +2 -1
- {rquote-0.3.0 → rquote-0.3.3}/pyproject.toml +2 -1
- {rquote-0.3.0 → rquote-0.3.3}/rquote/main.py +26 -4
- {rquote-0.3.0 → rquote-0.3.3}/rquote.egg-info/PKG-INFO +2 -1
- {rquote-0.3.0 → rquote-0.3.3}/rquote.egg-info/requires.txt +1 -0
- {rquote-0.3.0 → rquote-0.3.3}/README.md +0 -0
- {rquote-0.3.0 → rquote-0.3.3}/rquote/__init__.py +0 -0
- {rquote-0.3.0 → rquote-0.3.3}/rquote/plots.py +0 -0
- {rquote-0.3.0 → rquote-0.3.3}/rquote/utils.py +0 -0
- {rquote-0.3.0 → rquote-0.3.3}/rquote.egg-info/SOURCES.txt +0 -0
- {rquote-0.3.0 → rquote-0.3.3}/rquote.egg-info/dependency_links.txt +0 -0
- {rquote-0.3.0 → rquote-0.3.3}/rquote.egg-info/top_level.txt +0 -0
- {rquote-0.3.0 → rquote-0.3.3}/setup.cfg +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rquote
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
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
|
+
Requires-Dist: build>=0.9.0
|
|
7
8
|
Requires-Dist: httpx>=0.20.0
|
|
8
9
|
Requires-Dist: pandas>=1.0.0
|
|
9
10
|
Requires-Dist: setuptools>=42
|
|
@@ -4,11 +4,12 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rquote"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.3"
|
|
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
|
+
"build>=0.9.0",
|
|
12
13
|
"httpx>=0.20.0",
|
|
13
14
|
"pandas>=1.0.0",
|
|
14
15
|
"setuptools>=42",
|
|
@@ -137,6 +137,13 @@ def _check_date_format(date_str):
|
|
|
137
137
|
return date_str
|
|
138
138
|
|
|
139
139
|
|
|
140
|
+
def load_js_var_json(url):
|
|
141
|
+
a = hget(url)
|
|
142
|
+
if a:
|
|
143
|
+
a = json.loads(a.text.split('(')[1].split(')')[0])
|
|
144
|
+
return a
|
|
145
|
+
|
|
146
|
+
|
|
140
147
|
def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
141
148
|
dd=None) -> (str, str, pd.DataFrame):
|
|
142
149
|
'''
|
|
@@ -170,6 +177,8 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
170
177
|
'_var=min_data_{}&code={}'
|
|
171
178
|
sina_future_d = 'https://stock2.finance.sina.com.cn/futures/api/jsonp.php/' + \
|
|
172
179
|
'var%20t1nf_{}=/InnerFuturesNewService.getDailyKLine?symbol={}'
|
|
180
|
+
sina_future_min = 'https://stock2.finance.sina.com.cn/futures/api/jsonp.php/' + \
|
|
181
|
+
'var%20t1nf_{}=/InnerFuturesNewService.getMinLine?symbol={}'
|
|
173
182
|
sina_btc = 'https://quotes.sina.cn/fx/api/openapi.php/BtcService.getDayKLine?' + \
|
|
174
183
|
'symbol=btcbtcusd'
|
|
175
184
|
|
|
@@ -211,9 +220,20 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
211
220
|
columns=['date', 'open', 'high', 'low', 'close', 'vol', 'amount'])
|
|
212
221
|
return i, 'BTC', d
|
|
213
222
|
else:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
223
|
+
ix = i[2:]
|
|
224
|
+
if freq in ('min', '1min', 'minute'):
|
|
225
|
+
url = sina_future_min.format(ix, ix)
|
|
226
|
+
# rtext = hget(url).text
|
|
227
|
+
# d = pd.DataFrame(json.loads(rtext.split(i[2:])[1][2:-2]))
|
|
228
|
+
d = pd.DataFrame(load_js_var_json(url))
|
|
229
|
+
d.columns = ['dtime', 'close', 'avg', 'vol', 'hold','last_close','cur_date']
|
|
230
|
+
d = d.set_index(['dtime'])
|
|
231
|
+
return i[2:], i[2:], d
|
|
232
|
+
else:
|
|
233
|
+
# d = pd.DataFrame(json.loads(hget(sina_future_d.format(
|
|
234
|
+
# ix, ix)).text.split('(')[1][:-2]))
|
|
235
|
+
d = pd.DataFrame(load_js_var_json(sina_future_d.format(ix, ix)))
|
|
236
|
+
d.columns = ['date', 'open', 'high', 'low', 'close', 'vol', 'p', 's']
|
|
217
237
|
d = d.set_index(['date']).astype(float)
|
|
218
238
|
# d.index = pd.DatetimeIndex(d.index)
|
|
219
239
|
return i, ix, d
|
|
@@ -238,7 +258,7 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
238
258
|
#a = json.loads(a.text.replace('kline_dayqfq=', ''))['data'][i]
|
|
239
259
|
if i[:2] == 'us' and freq in ('min', '1min', 'minute'):
|
|
240
260
|
a = json.loads(a.text.split('=')[1])['data'][i]
|
|
241
|
-
nm = a['qt'][
|
|
261
|
+
nm = a['qt'][i][1]
|
|
242
262
|
b = pd.DataFrame([i.split() for i in a['data']['data']],
|
|
243
263
|
columns=['minute','price','volume']).set_index(['minute']).astype(str)
|
|
244
264
|
return i, nm, b
|
|
@@ -470,6 +490,8 @@ def get_hk_stocks_hsi():
|
|
|
470
490
|
if __name__ == "__main__":
|
|
471
491
|
# print(get_cn_stock_list())
|
|
472
492
|
# print(get_price('fuBTC',sdate='20250101'))
|
|
493
|
+
# print(get_price('fuM2601',sdate='20250101', freq='min'))
|
|
494
|
+
# print(get_price('fuM2601',sdate='2025-01-01'))
|
|
473
495
|
# print(get_price('sz000001', sdate='20240101', edate='20250101'))
|
|
474
496
|
print(get_price('usAMZN.OQ', sdate='20250101', edate='20250101', freq='min'))
|
|
475
497
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rquote
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
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
|
+
Requires-Dist: build>=0.9.0
|
|
7
8
|
Requires-Dist: httpx>=0.20.0
|
|
8
9
|
Requires-Dist: pandas>=1.0.0
|
|
9
10
|
Requires-Dist: setuptools>=42
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|