akshare 1.14.31__py3-none-any.whl → 1.14.32__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.
akshare/__init__.py CHANGED
@@ -2842,9 +2842,10 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2842
2842
  1.14.29 fix: fix stock_individual_spot_xq interface
2843
2843
  1.14.30 fix: fix stock_us_hist_min_em interface
2844
2844
  1.14.31 fix: fix option_shfe_daily interface
2845
+ 1.14.32 add: add stock_concept_cons_futu interface
2845
2846
  """
2846
2847
 
2847
- __version__ = "1.14.31"
2848
+ __version__ = "1.14.32"
2848
2849
  __author__ = "AKFamily"
2849
2850
 
2850
2851
  import sys
@@ -2866,6 +2867,11 @@ if sys.version_info < (3, 9):
2866
2867
 
2867
2868
  del sys
2868
2869
 
2870
+ """
2871
+ 富途牛牛-主题投资-概念板块-成分股
2872
+ """
2873
+ from akshare.stock_feature.stock_concept_futu import stock_concept_cons_futu
2874
+
2869
2875
  """
2870
2876
  商品期权手续费
2871
2877
  """
@@ -0,0 +1,175 @@
1
+ import json
2
+
3
+ import pandas as pd
4
+ import requests
5
+ from bs4 import BeautifulSoup
6
+
7
+
8
+ def _stock_concept_cons_futu(symbol: str = "巴菲特持仓") -> pd.DataFrame:
9
+ """
10
+ 富途牛牛-主题投资-概念板块-成分股
11
+ https://www.futunn.com/quote/sparks-us?global_content=%7B%22promote_id%22%3A13766,%22sub_promote_id%22%3A24%7D
12
+ :param symbol: 板块名称; choice of {"巴菲特持仓", "佩洛西持仓"}
13
+ :type symbol: str
14
+ :return: 概念板块
15
+ :rtype: pandas.DataFrame
16
+ """
17
+ symbol_map = {
18
+ "巴菲特持仓": "BK2999",
19
+ "佩洛西持仓": "BK20883",
20
+ }
21
+ url = f"https://www.futunn.com/stock/{symbol_map[symbol]}"
22
+ # 定义查询参数
23
+ params = {"global_content": json.dumps({"promote_id": 13766, "sub_promote_id": 24})}
24
+ headers = {
25
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
26
+ "(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
27
+ }
28
+ r = requests.get(url, params=params, headers=headers)
29
+ soup = BeautifulSoup(r.text, features="lxml")
30
+ temp_code_name = [
31
+ item.find_all("div", attrs={"class": "fix-left"})
32
+ for item in soup.find(name="div", attrs={"class": "content-main"}).find_all("a")
33
+ ]
34
+ temp_value_list = [
35
+ item.find_all("div", attrs={"class": "middle"})
36
+ for item in soup.find(name="div", attrs={"class": "content-main"}).find_all("a")
37
+ ]
38
+ code_name_list = [item[0].find_all("span") for item in temp_code_name]
39
+
40
+ quant_list = [item[0].find_all("span") for item in temp_value_list]
41
+ temp_df = pd.DataFrame(
42
+ [
43
+ [item[0]["title"] for item in code_name_list],
44
+ [item[1]["title"] for item in code_name_list],
45
+ [item[0]["title"] for item in quant_list],
46
+ [item[1]["title"] for item in quant_list],
47
+ [item[2]["title"] for item in quant_list],
48
+ [item[3]["title"] for item in quant_list],
49
+ [item[4]["title"] for item in quant_list],
50
+ [item[5]["title"] for item in quant_list],
51
+ [item[6]["title"] for item in quant_list],
52
+ [item[7]["title"] for item in quant_list],
53
+ [item[8]["title"] for item in quant_list],
54
+ [item[9]["title"] for item in quant_list],
55
+ [item[10]["title"] for item in quant_list],
56
+ [item[11]["title"] for item in quant_list],
57
+ [item[12]["title"] for item in quant_list],
58
+ [item[13]["title"] for item in quant_list],
59
+ [item[14]["title"] for item in quant_list],
60
+ ]
61
+ ).T
62
+ temp_df.columns = [
63
+ "代码",
64
+ "股票名称",
65
+ "最新价",
66
+ "涨跌额",
67
+ "涨跌幅",
68
+ "成交量",
69
+ "成交额",
70
+ "-",
71
+ "-",
72
+ "-",
73
+ "-",
74
+ "-",
75
+ "-",
76
+ "-",
77
+ "-",
78
+ "-",
79
+ "-",
80
+ ]
81
+ temp_df = temp_df[
82
+ [
83
+ "代码",
84
+ "股票名称",
85
+ "最新价",
86
+ "涨跌额",
87
+ "涨跌幅",
88
+ "成交量",
89
+ "成交额",
90
+ ]
91
+ ]
92
+ return temp_df
93
+
94
+
95
+ def stock_concept_cons_futu(symbol: str = "特朗普概念股") -> pd.DataFrame:
96
+ """
97
+ 富途牛牛-主题投资-概念板块-成分股
98
+ https://www.futunn.com/quote/sparks-us
99
+ :param symbol: 板块名称; choice of {"巴菲特持仓", "佩洛西持仓", "特朗普概念股"}
100
+ :type symbol: str
101
+ :return: 概念板块
102
+ :rtype: pandas.DataFrame
103
+ """
104
+ if symbol == "特朗普概念股":
105
+ url = "https://www.futunn.com/quote-api/quote-v2/get-plate-stock"
106
+ params = {
107
+ "marketType": "2",
108
+ "plateId": "10102960",
109
+ "page": "0",
110
+ "pageSize": "30",
111
+ }
112
+ headers = {
113
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
114
+ "(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
115
+ "Quote-Token": "7f74cd2a5e",
116
+ }
117
+ r = requests.get(url, params=params, headers=headers)
118
+ data_json = r.json()
119
+ total_page = data_json["data"]["pagination"]["pageCount"]
120
+ big_df = pd.DataFrame()
121
+ for page in range(0, total_page):
122
+ params.update(
123
+ {
124
+ "page": page,
125
+ }
126
+ )
127
+ if page == 1:
128
+ headers.update({"Quote-Token": "a3043d6fed"})
129
+ r = requests.get(url, params=params, headers=headers)
130
+ data_json = r.json()
131
+ temp_df = pd.DataFrame(data_json["data"]["list"])
132
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
133
+
134
+ big_df.rename(
135
+ columns={
136
+ "stockCode": "代码",
137
+ "name": "股票名称",
138
+ "price": "最新价",
139
+ "change": "涨跌额",
140
+ "changeRatio": "涨跌幅",
141
+ "tradeVolumn": "成交量",
142
+ "tradeTrunover": "成交额",
143
+ },
144
+ inplace=True,
145
+ )
146
+ big_df = big_df[
147
+ [
148
+ "代码",
149
+ "股票名称",
150
+ "最新价",
151
+ "涨跌额",
152
+ "涨跌幅",
153
+ "成交量",
154
+ "成交额",
155
+ ]
156
+ ]
157
+ big_df["最新价"] = pd.to_numeric(big_df["最新价"], errors="coerce")
158
+ big_df["涨跌额"] = pd.to_numeric(big_df["涨跌额"], errors="coerce")
159
+ return big_df
160
+ else:
161
+ temp_df = _stock_concept_cons_futu(symbol)
162
+ temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
163
+ temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
164
+ return temp_df
165
+
166
+
167
+ if __name__ == "__main__":
168
+ stock_concept_cons_futu_df = stock_concept_cons_futu(symbol="特朗普概念股")
169
+ print(stock_concept_cons_futu_df)
170
+
171
+ stock_concept_cons_futu_df = stock_concept_cons_futu(symbol="巴菲特持仓")
172
+ print(stock_concept_cons_futu_df)
173
+
174
+ stock_concept_cons_futu_df = stock_concept_cons_futu(symbol="佩洛西持仓")
175
+ print(stock_concept_cons_futu_df)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: akshare
3
- Version: 1.14.31
3
+ Version: 1.14.32
4
4
  Summary: AKShare is an elegant and simple financial data interface library for Python, built for human beings!
5
5
  Home-page: https://github.com/akfamily/akshare
6
6
  Author: AKFamily
@@ -1,4 +1,4 @@
1
- akshare/__init__.py,sha256=g9lqTErgouUMaJcg3ZNsfLIeAWs2AtRsSk_8-2Oifdg,179066
1
+ akshare/__init__.py,sha256=d-y1mQUZJUih4kh5hTFn6l1oVvxrVi3WLAVLtcYZugE,179252
2
2
  akshare/datasets.py,sha256=oIu1zC7o_LMHY22lQmdM7vCnryHibKrJLBqJwQiitlI,1167
3
3
  akshare/air/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
4
4
  akshare/air/air_hebei.py,sha256=xIXNGLK7IGYqrkteM9fxnHAwWqk6PCQs6D9-ggZ7byY,4442
@@ -296,6 +296,7 @@ akshare/stock_feature/stock_board_industry_ths.py,sha256=ZJ-lODgxGNluMp3z72qpXoa
296
296
  akshare/stock_feature/stock_buffett_index_lg.py,sha256=NpNccHmGjtqLz6aUladB6InPzO2pjoImbgCgmNEYUuM,2027
297
297
  akshare/stock_feature/stock_classify_sina.py,sha256=Lg7ROG5W9HioFRplJI2rZ6tAAHM09N3g9qF6kReIQYI,3210
298
298
  akshare/stock_feature/stock_comment_em.py,sha256=3HpMZkCiIC6o6LzLZLNA-rYKBMRPeuTaj6xfuU7o4J0,14252
299
+ akshare/stock_feature/stock_concept_futu.py,sha256=Fut1t3F4gxQvVAhwE1qV6V-csj2UloIx5UAhKcIVHKg,6130
299
300
  akshare/stock_feature/stock_congestion_lg.py,sha256=iTEcmL0HoSqWGfxv_gSM-qA4O23aqUH7qHl9asDtoO0,1299
300
301
  akshare/stock_feature/stock_cyq_em.py,sha256=z670B8Hxkq3iTjzqWoN8w6oQBHwmLLMaa0YERySk60g,11036
301
302
  akshare/stock_feature/stock_disclosure_cninfo.py,sha256=1Eje6abqk6HNOlpCueGnaR_r1-aqTv2f51h4QAHCQzo,10661
@@ -378,8 +379,8 @@ akshare/utils/token_process.py,sha256=K4rGXjh_tgugbRcyOK2h2x0jP3PT65IIK7nxhUKhOe
378
379
  akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
379
380
  tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
380
381
  tests/test_func.py,sha256=tfvy_YnYmDra2dkKZ5JvprU1gNW5X9T634PszdSdH1A,944
381
- akshare-1.14.31.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
382
- akshare-1.14.31.dist-info/METADATA,sha256=YNaH-ozSYrJaTFoK25k78t-JGUjY2PYyw5VJ9WMYRQE,14010
383
- akshare-1.14.31.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
384
- akshare-1.14.31.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
385
- akshare-1.14.31.dist-info/RECORD,,
382
+ akshare-1.14.32.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
383
+ akshare-1.14.32.dist-info/METADATA,sha256=4piFGt54YUfpoLakR6T5cKP_A4wOQJyJanvr1-ImQB4,14010
384
+ akshare-1.14.32.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
385
+ akshare-1.14.32.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
386
+ akshare-1.14.32.dist-info/RECORD,,