rquote 0.2.5__tar.gz → 0.2.7__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.5 → rquote-0.2.7}/PKG-INFO +6 -8
- {rquote-0.2.5 → rquote-0.2.7}/README.md +2 -6
- {rquote-0.2.5 → rquote-0.2.7}/pyproject.toml +4 -2
- {rquote-0.2.5 → rquote-0.2.7}/rquote/__init__.py +3 -1
- {rquote-0.2.5 → rquote-0.2.7}/rquote/main.py +34 -22
- {rquote-0.2.5 → rquote-0.2.7}/rquote/utils.py +3 -2
- {rquote-0.2.5 → rquote-0.2.7}/rquote.egg-info/PKG-INFO +6 -8
- rquote-0.2.7/rquote.egg-info/requires.txt +4 -0
- {rquote-0.2.5 → rquote-0.2.7}/setup.py +3 -5
- rquote-0.2.5/rquote.egg-info/requires.txt +0 -2
- {rquote-0.2.5 → rquote-0.2.7}/rquote/plots.py +0 -0
- {rquote-0.2.5 → rquote-0.2.7}/rquote.egg-info/SOURCES.txt +0 -0
- {rquote-0.2.5 → rquote-0.2.7}/rquote.egg-info/dependency_links.txt +0 -0
- {rquote-0.2.5 → rquote-0.2.7}/rquote.egg-info/top_level.txt +0 -0
- {rquote-0.2.5 → rquote-0.2.7}/setup.cfg +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rquote
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch
|
|
5
5
|
Home-page: https://github.com/kids/rquote
|
|
6
6
|
Author: Roizhao
|
|
7
7
|
Author-email: roizhao@gmail.com
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.6.1
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
Requires-Dist: httpx>=0.20.0
|
|
11
11
|
Requires-Dist: pandas>=1.0.0
|
|
12
|
+
Requires-Dist: setuptools>=59.6.0
|
|
13
|
+
Requires-Dist: twine>=3.8.0
|
|
12
14
|
Dynamic: author
|
|
13
15
|
Dynamic: author-email
|
|
14
16
|
Dynamic: home-page
|
|
@@ -16,11 +18,11 @@ Dynamic: requires-python
|
|
|
16
18
|
|
|
17
19
|
# rquote
|
|
18
20
|
|
|
19
|
-
`get_price`方法提供 A股/港股/美股/ETF基金/期货
|
|
21
|
+
`get_price`方法提供 A股/港股/美股/ETF基金/期货 日线历史数据获取
|
|
20
22
|
|
|
21
23
|
使用新浪/腾讯的id形式,如`sh000001`表示上证指数,`sz000001`表示深市000001股票`平安银行`,`sh510050`表示上证50指数ETF,`hk00700`表示港股腾讯。
|
|
22
24
|
期货代码需加`fu`前缀,如`fuAP2110`,美股需加对应交易所后缀,如`usBABA.N`,`usC.N`,`usAAPL.OQ`等
|
|
23
|
-
BTC/USD
|
|
25
|
+
BTC/USD也放在fu下面,i.d.`fuBTC`
|
|
24
26
|
|
|
25
27
|
e.g.
|
|
26
28
|
```
|
|
@@ -36,7 +38,3 @@ df.head() # 数据为pandas dataframe
|
|
|
36
38
|
> 2024-02-19 2886.59 2910.54 2910.54 2867.71 458967704.0
|
|
37
39
|
> 2024-02-20 2902.88 2922.73 2927.31 2887.47 350138735.0
|
|
38
40
|
|
|
39
|
-
Notes:
|
|
40
|
-
使用GenImage需要补充依赖
|
|
41
|
-
> kaleido>=1.0.0rc0
|
|
42
|
-
> plolty>=5.0.0
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# rquote
|
|
2
2
|
|
|
3
|
-
`get_price`方法提供 A股/港股/美股/ETF基金/期货
|
|
3
|
+
`get_price`方法提供 A股/港股/美股/ETF基金/期货 日线历史数据获取
|
|
4
4
|
|
|
5
5
|
使用新浪/腾讯的id形式,如`sh000001`表示上证指数,`sz000001`表示深市000001股票`平安银行`,`sh510050`表示上证50指数ETF,`hk00700`表示港股腾讯。
|
|
6
6
|
期货代码需加`fu`前缀,如`fuAP2110`,美股需加对应交易所后缀,如`usBABA.N`,`usC.N`,`usAAPL.OQ`等
|
|
7
|
-
BTC/USD
|
|
7
|
+
BTC/USD也放在fu下面,i.d.`fuBTC`
|
|
8
8
|
|
|
9
9
|
e.g.
|
|
10
10
|
```
|
|
@@ -20,7 +20,3 @@ df.head() # 数据为pandas dataframe
|
|
|
20
20
|
> 2024-02-19 2886.59 2910.54 2910.54 2867.71 458967704.0
|
|
21
21
|
> 2024-02-20 2902.88 2922.73 2927.31 2887.47 350138735.0
|
|
22
22
|
|
|
23
|
-
Notes:
|
|
24
|
-
使用GenImage需要补充依赖
|
|
25
|
-
> kaleido>=1.0.0rc0
|
|
26
|
-
> plolty>=5.0.0
|
|
@@ -4,11 +4,13 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rquote"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.7"
|
|
8
8
|
description = "Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.6.1"
|
|
11
11
|
dependencies = [
|
|
12
12
|
"httpx>=0.20.0",
|
|
13
13
|
"pandas>=1.0.0",
|
|
14
|
+
"setuptools>=59.6.0",
|
|
15
|
+
"twine>=3.8.0",
|
|
14
16
|
]
|
|
@@ -7,7 +7,9 @@ Copyright (c) 2021 Roi ZHAO
|
|
|
7
7
|
|
|
8
8
|
'''
|
|
9
9
|
|
|
10
|
-
from .main import get_price, get_stock_concepts, get_concept_stocks
|
|
10
|
+
from .main import get_price, get_stock_concepts, get_concept_stocks, get_bk_stocks
|
|
11
11
|
from .main import get_all_concepts, get_all_industries
|
|
12
|
+
from .main import get_cn_stock_list, get_hk_stocks_hsi, get_hk_stocks_ggt, get_hk_stocks_500
|
|
13
|
+
from .main import get_cn_future_list, get_us_stocks_biggest, get_cn_fund_list
|
|
12
14
|
from .utils import WebUtils, BasicFactors
|
|
13
15
|
from .plots import PlotUtils
|
|
@@ -8,11 +8,16 @@ import pandas as pd
|
|
|
8
8
|
from .utils import WebUtils, hget, logger
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def make_tgts(mkts=['ch', 'hk', 'us', 'fund', 'future'], money_min=2e8) -> []:
|
|
12
|
-
cands = []
|
|
13
|
-
|
|
14
11
|
|
|
15
12
|
def get_cn_stock_list(money_min=2e8):
|
|
13
|
+
ret = []
|
|
14
|
+
try:
|
|
15
|
+
ret = get_cn_stock_list_eastmoney(money_min)
|
|
16
|
+
except Exception as e:
|
|
17
|
+
ret = get_cn_stock_list_qq(money_min)
|
|
18
|
+
return ret
|
|
19
|
+
|
|
20
|
+
def get_cn_stock_list_eastmoney(money_min=2e8):
|
|
16
21
|
'''
|
|
17
22
|
Return sorted stock list ordered by latest amount of money, cut at `money_min`
|
|
18
23
|
item in returned list are [code, name, change, amount, mktcap]
|
|
@@ -28,31 +33,39 @@ def get_cn_stock_list(money_min=2e8):
|
|
|
28
33
|
if a:
|
|
29
34
|
a = json.loads(a.text.split(
|
|
30
35
|
'jQuery112409458761844374801_1627288489961(')[1][:-2])
|
|
31
|
-
|
|
32
|
-
# cdir = os.path.dirname(__file__)
|
|
33
|
-
# with open(os.path.join(cdir, 'ranka'), 'wb') as f:
|
|
34
|
-
# f.write(a.content)
|
|
35
|
-
# a = pd.read_excel(os.path.join(cdir, 'ranka'), header=1)
|
|
36
|
-
# os.remove(os.path.join(cdir, 'ranka'))
|
|
37
|
-
# a.columns = ['code', 'name', 'close', 'p_change', 'change', '_', '_', '_',
|
|
38
|
-
# 'money', 'open', 'yest_close', 'high', 'low']
|
|
39
|
-
# a = a[a.money > money_min]
|
|
40
36
|
a = [ ['sh'+i['f12'] if i['f12'][0]=='6' else 'sz'+i['f12'],
|
|
41
37
|
i['f14'], i['f3'], i['f6'], i['f21']] for i in a['data']['diff']
|
|
42
38
|
if i['f6']!='-' and float(i['f6']) > money_min]
|
|
43
39
|
#cands=[(i.code,i.name) for i in a[['code','name']].itertuples()]
|
|
44
40
|
return a
|
|
45
41
|
|
|
42
|
+
def get_cn_stock_list_qq(money_min=2e8):
|
|
43
|
+
offset = 0
|
|
44
|
+
count = 200 # max, or error
|
|
45
|
+
df = []
|
|
46
|
+
while not df or float(df[-1]['turnover'])*1e4 > money_min:
|
|
47
|
+
a = hget(
|
|
48
|
+
f'https://proxy.finance.qq.com/cgi/cgi-bin/rank/hs/getBoardRankList?_appver=11.17.0'+
|
|
49
|
+
f'&board_code=aStock&sort_type=turnover&direct=down&offset={offset}&count={count}'
|
|
50
|
+
)
|
|
51
|
+
if a:
|
|
52
|
+
a = json.loads(a.text)
|
|
53
|
+
print('===',a)
|
|
54
|
+
if a['data']['rank_list']:
|
|
55
|
+
df.extend(a['data']['rank_list'])
|
|
56
|
+
offset += count
|
|
57
|
+
else:
|
|
58
|
+
break
|
|
59
|
+
return df
|
|
60
|
+
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# i['market_value']] for i in json.loads(a)]
|
|
55
|
-
# return a
|
|
62
|
+
def get_hk_stocks_500():
|
|
63
|
+
a = hget(
|
|
64
|
+
'https://stock.gtimg.cn/data/hk_rank.php?board=main_all&metric=amount&' +
|
|
65
|
+
'pageSize=500&reqPage=1&order=desc&var_name=list_data').text
|
|
66
|
+
if a:
|
|
67
|
+
a = [i.split('~') for i in json.loads(a.split('list_data=')[1])['data']['page_data']]
|
|
68
|
+
return a
|
|
56
69
|
|
|
57
70
|
|
|
58
71
|
def get_us_stocks_biggest(k=60):
|
|
@@ -192,7 +205,6 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
192
205
|
raise ValueError('target market not supported')
|
|
193
206
|
a = hget(url)
|
|
194
207
|
#a = json.loads(a.text.replace('kline_dayqfq=', ''))['data'][i]
|
|
195
|
-
print('=====',url,a)
|
|
196
208
|
a = json.loads(a.text)['data'][i]
|
|
197
209
|
name = ''
|
|
198
210
|
try:
|
|
@@ -52,7 +52,7 @@ class WebUtils:
|
|
|
52
52
|
return header
|
|
53
53
|
|
|
54
54
|
@classmethod
|
|
55
|
-
def
|
|
55
|
+
def http_get(cls, url, headers, method, proxy=None):
|
|
56
56
|
'''
|
|
57
57
|
request.get() wrapper
|
|
58
58
|
'''
|
|
@@ -187,7 +187,8 @@ class hget:
|
|
|
187
187
|
self.url = url
|
|
188
188
|
try:
|
|
189
189
|
r = httpx.get(
|
|
190
|
-
self.url, follow_redirects=True,
|
|
190
|
+
self.url, follow_redirects=True, headers=WebUtils.headers(),
|
|
191
|
+
*args, **kwargs)
|
|
191
192
|
self.text = r.text
|
|
192
193
|
self.content = r.content
|
|
193
194
|
except Exception as e:
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rquote
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch
|
|
5
5
|
Home-page: https://github.com/kids/rquote
|
|
6
6
|
Author: Roizhao
|
|
7
7
|
Author-email: roizhao@gmail.com
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.6.1
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
Requires-Dist: httpx>=0.20.0
|
|
11
11
|
Requires-Dist: pandas>=1.0.0
|
|
12
|
+
Requires-Dist: setuptools>=59.6.0
|
|
13
|
+
Requires-Dist: twine>=3.8.0
|
|
12
14
|
Dynamic: author
|
|
13
15
|
Dynamic: author-email
|
|
14
16
|
Dynamic: home-page
|
|
@@ -16,11 +18,11 @@ Dynamic: requires-python
|
|
|
16
18
|
|
|
17
19
|
# rquote
|
|
18
20
|
|
|
19
|
-
`get_price`方法提供 A股/港股/美股/ETF基金/期货
|
|
21
|
+
`get_price`方法提供 A股/港股/美股/ETF基金/期货 日线历史数据获取
|
|
20
22
|
|
|
21
23
|
使用新浪/腾讯的id形式,如`sh000001`表示上证指数,`sz000001`表示深市000001股票`平安银行`,`sh510050`表示上证50指数ETF,`hk00700`表示港股腾讯。
|
|
22
24
|
期货代码需加`fu`前缀,如`fuAP2110`,美股需加对应交易所后缀,如`usBABA.N`,`usC.N`,`usAAPL.OQ`等
|
|
23
|
-
BTC/USD
|
|
25
|
+
BTC/USD也放在fu下面,i.d.`fuBTC`
|
|
24
26
|
|
|
25
27
|
e.g.
|
|
26
28
|
```
|
|
@@ -36,7 +38,3 @@ df.head() # 数据为pandas dataframe
|
|
|
36
38
|
> 2024-02-19 2886.59 2910.54 2910.54 2867.71 458967704.0
|
|
37
39
|
> 2024-02-20 2902.88 2922.73 2927.31 2887.47 350138735.0
|
|
38
40
|
|
|
39
|
-
Notes:
|
|
40
|
-
使用GenImage需要补充依赖
|
|
41
|
-
> kaleido>=1.0.0rc0
|
|
42
|
-
> plolty>=5.0.0
|
|
@@ -14,8 +14,8 @@ def read_requirements(filename):
|
|
|
14
14
|
|
|
15
15
|
setup(
|
|
16
16
|
name='rquote',
|
|
17
|
-
python_requires='>=3.
|
|
18
|
-
version='0.2.
|
|
17
|
+
python_requires='>=3.6.1',
|
|
18
|
+
version='0.2.7',
|
|
19
19
|
description='Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch',
|
|
20
20
|
long_description=read_file('README.md'),
|
|
21
21
|
long_description_content_type="text/markdown",
|
|
@@ -25,9 +25,7 @@ setup(
|
|
|
25
25
|
packages=[
|
|
26
26
|
'rquote'
|
|
27
27
|
],
|
|
28
|
-
install_requires=
|
|
29
|
-
"httpx>=0.20.0",
|
|
30
|
-
"pandas>=1.0.0"],
|
|
28
|
+
install_requires=read_requirements('requirements.txt'),
|
|
31
29
|
include_package_data=True,
|
|
32
30
|
license="MIT",
|
|
33
31
|
keywords=['quotes', 'stock', 'rquote'],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|