rquote 0.2.6__py3-none-any.whl → 0.2.7__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
@@ -9,7 +9,7 @@ Copyright (c) 2021 Roi ZHAO
9
9
 
10
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
12
+ from .main import get_cn_stock_list, get_hk_stocks_hsi, get_hk_stocks_ggt, get_hk_stocks_500
13
13
  from .main import get_cn_future_list, get_us_stocks_biggest, get_cn_fund_list
14
14
  from .utils import WebUtils, BasicFactors
15
15
  from .plots import PlotUtils
rquote/main.py CHANGED
@@ -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
- # def get_hk_stocks_hotest80():
48
- # a = hget(
49
- # 'http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php' +
50
- # '/Market_Center.getHKStockData?page=1&num=80&sort=amount&asc=0&node=' +
51
- # 'qbgg_hk&_s_r_a=sort').text
52
- # if a:
53
- # a = [['hk'+i['symbol'], i['name'], i['changepercent'], i['amount'],
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):
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rquote
3
- Version: 0.2.6
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.4.0
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
@@ -0,0 +1,8 @@
1
+ rquote/__init__.py,sha256=owCwRRDJoYUuR7-NKb_Nj3-2CCsL7TtrRVp6px_8RGA,470
2
+ rquote/main.py,sha256=BrY6TnYcW2NhphHHD0FBsBTr3C4cFaKUAgM1nQ097-o,17322
3
+ rquote/plots.py,sha256=N8uvD6ju9tow0DllPQiXiM7EoPC2bK8X7QF6NQainKs,2342
4
+ rquote/utils.py,sha256=v8j8R2xoXyTsHSAWXD7x2FUV7w1a4xgfswfSDdfg5p8,6827
5
+ rquote-0.2.7.dist-info/METADATA,sha256=8Ztlu-8Inaa7fw9URPv_eaqw6k3h2yZx64RiEP3elOs,1457
6
+ rquote-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ rquote-0.2.7.dist-info/top_level.txt,sha256=CehAiaZx7Fo8HGoV2zd5GhILUW1jQEN8YS-cWMlrK9Y,7
8
+ rquote-0.2.7.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- rquote/__init__.py,sha256=RmJldXUSwytbaIoML4H4DHU_-oWzrTcwnLGXrLVQFzM,451
2
- rquote/main.py,sha256=2qoFZN1d9TU89rEZj5SEWRh9X86DT6B9xkTY47L4dNs,17083
3
- rquote/plots.py,sha256=N8uvD6ju9tow0DllPQiXiM7EoPC2bK8X7QF6NQainKs,2342
4
- rquote/utils.py,sha256=v8j8R2xoXyTsHSAWXD7x2FUV7w1a4xgfswfSDdfg5p8,6827
5
- rquote-0.2.6.dist-info/METADATA,sha256=zu1H9gPSzD8hARNDK82MWDCR26bYroFMJKDLxE1-s3s,1457
6
- rquote-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- rquote-0.2.6.dist-info/top_level.txt,sha256=CehAiaZx7Fo8HGoV2zd5GhILUW1jQEN8YS-cWMlrK9Y,7
8
- rquote-0.2.6.dist-info/RECORD,,
File without changes