akshare 1.15.51__py3-none-any.whl → 1.15.53__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.

Potentially problematic release.


This version of akshare might be problematic. Click here for more details.

akshare/__init__.py CHANGED
@@ -2961,9 +2961,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2961
2961
  1.15.49 fix: fix option_dce_daily interface
2962
2962
  1.15.50 fix: fix stock_gpzy_profile_em interface
2963
2963
  1.15.51 fix: fix stock_gpzy_pledge_ratio_em interface
2964
+ 1.15.52 fix: fix stock_zh_index_hist_csindex interface
2965
+ 1.15.53 fix: fix futures_inventory_99 interface
2964
2966
  """
2965
2967
 
2966
- __version__ = "1.15.51"
2968
+ __version__ = "1.15.53"
2967
2969
  __author__ = "AKFamily"
2968
2970
 
2969
2971
  import sys
@@ -3147,11 +3149,6 @@ from akshare.stock_feature.stock_hist_tx import stock_zh_a_hist_tx
3147
3149
  """
3148
3150
  from akshare.stock_feature.stock_cyq_em import stock_cyq_em
3149
3151
 
3150
- """
3151
- funddb-工具-估值情绪-恐贪指数
3152
- """
3153
- from akshare.index.index_fear_greed_funddb import index_fear_greed_funddb
3154
-
3155
3152
  """
3156
3153
  东财财富-分时数据
3157
3154
  """
@@ -3728,14 +3725,6 @@ from akshare.stock_feature.stock_hsgt_em import (
3728
3725
  stock_hsgt_fund_flow_summary_em,
3729
3726
  )
3730
3727
 
3731
- """
3732
- 指数估值
3733
- """
3734
- from akshare.index.index_stock_zh_csindex import (
3735
- index_value_hist_funddb,
3736
- index_value_name_funddb,
3737
- )
3738
-
3739
3728
  """
3740
3729
  基金规模
3741
3730
  """
akshare/futures/cons.py CHANGED
@@ -64,30 +64,6 @@ inventory_temp_headers = {
64
64
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
65
65
  }
66
66
 
67
- sample_headers = {
68
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
69
- "Host": "service.99qh.com",
70
- "Origin": "http://service.99qh.com",
71
- "Referer": "http://www.99qh.com/d/store.aspx",
72
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
73
- }
74
-
75
- qh_headers = {
76
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
77
- "Accept-Encoding": "gzip, deflate",
78
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
79
- "Cache-Control": "no-cache",
80
- "Connection": "keep-alive",
81
- "Content-Length": "8429",
82
- "Content-Type": "application/x-www-form-urlencoded",
83
- "Host": "service.99qh.com",
84
- "Origin": "http://service.99qh.com",
85
- "Pragma": "no-cache",
86
- "Cookie": "__utma=181566328.985082941.1656754961.1656754961.1656754961.1; __utmc=181566328; __utmz=181566328.1656754961.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ASP.NET_SessionId=42k0mpzfu3fv5cxqmtrwc20y; tgw_l7_route=b26adbec28f4b4e1f7290033d59c43a7; __utmt=1; __utmb=181566328.2.10.1656754961",
87
- "Referer": "http://service.99qh.com/Storage/Storage.aspx?page=99qh",
88
- "Upgrade-Insecure-Requests": "1",
89
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
90
- }
91
67
  # 奇货可查
92
68
  QHKC_INDEX_URL = "https://www.qhkch.com/ajax/index_show.php"
93
69
  QHKC_INDEX_TREND_URL = "https://qhkch.com/ajax/indexes_trend.php"
@@ -1,297 +1,86 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2024/1/10 19:00
4
+ Date: 2024/12/23 20:00
5
5
  Desc: 99 期货网-大宗商品库存数据
6
- http://www.99qh.com/d/store.aspx
6
+ https://www.99qh.com/
7
7
  """
8
- from io import StringIO
9
8
 
9
+ import json
10
+ from functools import lru_cache
11
+ from datetime import datetime
10
12
  import pandas as pd
11
13
  import requests
12
14
  from bs4 import BeautifulSoup
13
15
 
14
- from akshare.futures.cons import (
15
- qh_headers,
16
- sample_headers,
17
- )
16
+
17
+ @lru_cache(maxsize=32)
18
+ def __get_99_symbol_map() -> pd.DataFrame:
19
+ """
20
+ 99 期货网-品种代码对照表
21
+ https://www.99qh.com/data/stockIn?productId=12
22
+ :return: 品种代码对照表
23
+ :rtype: pandas.DataFrame
24
+ """
25
+ url = "https://www.99qh.com/data/stockIn"
26
+ r = requests.get(url)
27
+ soup = BeautifulSoup(r.text, features="lxml")
28
+ raw_data = soup.find(attrs={"id": "__NEXT_DATA__"}).text
29
+ data_json = json.loads(raw_data)
30
+ df_list = []
31
+ for i, item in enumerate(
32
+ data_json["props"]["pageProps"]["data"]["varietyListData"]
33
+ ):
34
+ temp_df = pd.DataFrame(
35
+ data_json["props"]["pageProps"]["data"]["varietyListData"][i]["productList"]
36
+ )
37
+ df_list.append(temp_df)
38
+
39
+ big_df = pd.concat(df_list, ignore_index=True)
40
+ return big_df
18
41
 
19
42
 
20
- def futures_inventory_99(
21
- exchange: str = "大连商品交易所", symbol: str = "豆一"
22
- ) -> pd.DataFrame:
43
+ def futures_inventory_99(symbol: str = "豆一") -> pd.DataFrame:
23
44
  """
24
45
  99 期货网-大宗商品库存数据
25
- http://www.99qh.com/d/store.aspx
26
- :param exchange: 交易所名称; choice of {"上海期货交易所", "郑州商品交易所", "大连商品交易所", "LME", "NYMEX", "CBOT", "NYBOT", "TOCOM", "上海国际能源交易中心", "OSE"}
27
- :type exchange: str
46
+ https://www.99qh.com/data/stockIn?productId=12
28
47
  :param symbol: 交易所对应的具体品种; 如:大连商品交易所的 豆一
29
48
  :type symbol: str
30
49
  :return: 大宗商品库存数据
31
50
  :rtype: pandas.DataFrame
32
51
  """
33
- data_code = {
34
- "1": [
35
- "1",
36
- "2",
37
- "3",
38
- "12",
39
- "32",
40
- "36",
41
- "37",
42
- "40",
43
- "42",
44
- "47",
45
- "56",
46
- "63",
47
- "69",
48
- "70",
49
- "79",
50
- "85",
51
- ],
52
- "2": [
53
- "4",
54
- "14",
55
- "29",
56
- "31",
57
- "33",
58
- "38",
59
- "44",
60
- "45",
61
- "50",
62
- "51",
63
- "52",
64
- "55",
65
- "59",
66
- "64",
67
- "66",
68
- "67",
69
- "75",
70
- "76",
71
- "81",
72
- "82",
73
- "87",
74
- "92",
75
- "95",
76
- ],
77
- "3": [
78
- "6",
79
- "7",
80
- "8",
81
- "15",
82
- "30",
83
- "34",
84
- "35",
85
- "39",
86
- "43",
87
- "53",
88
- "57",
89
- "58",
90
- "61",
91
- "62",
92
- "68",
93
- "80",
94
- "84",
95
- "86",
96
- "88",
97
- "89",
98
- "94",
99
- ],
100
- "4": ["9", "10", "16", "17", "18", "23", "28"],
101
- "5": ["11", "20", "21"],
102
- "6": ["13", "24", "25", "26", "27"],
103
- "7": ["19"],
104
- "8": ["22"],
105
- "10": ["78", "83", "90", "93"],
106
- "11": ["91"],
107
- }
108
- data_name = {
109
- "1": [
110
- "铜",
111
- "铝",
112
- "橡胶",
113
- "燃料油",
114
- "锌",
115
- "黄金",
116
- "螺纹钢",
117
- "线材",
118
- "铅",
119
- "白银",
120
- "石油沥青",
121
- "热轧卷板",
122
- "锡",
123
- "镍",
124
- "纸浆",
125
- "不锈钢",
126
- ],
127
- "2": [
128
- "强麦",
129
- "一号棉",
130
- "白糖",
131
- "PTA",
132
- "菜籽油",
133
- "早籼稻",
134
- "甲醇",
135
- "普麦",
136
- "玻璃",
137
- "油菜籽",
138
- "菜籽粕",
139
- "动力煤",
140
- "粳稻",
141
- "晚籼稻",
142
- "硅铁",
143
- "锰硅",
144
- "棉纱",
145
- "苹果",
146
- "红枣",
147
- "尿素",
148
- "纯碱",
149
- "短纤",
150
- "花生",
151
- ],
152
- "3": [
153
- "豆一",
154
- "豆二",
155
- "豆粕",
156
- "玉米",
157
- "豆油",
158
- "聚乙烯",
159
- "棕榈油",
160
- "聚氯乙烯",
161
- "焦炭",
162
- "焦煤",
163
- "铁矿石",
164
- "鸡蛋",
165
- "胶合板",
166
- "聚丙烯",
167
- "玉米淀粉",
168
- "乙二醇",
169
- "粳米",
170
- "苯乙烯",
171
- "纤维板",
172
- "液化石油气",
173
- "生猪",
174
- ],
175
- "4": ["LME铜", "LME铝", "LME镍", "LME铅", "LME锌", "LME锡", "LME铝合金"],
176
- "5": ["COMEX铜", "COMEX金", "COMEX银"],
177
- "6": ["CBOT大豆", "CBOT小麦", "CBOT玉米", "CBOT燕麦", "CBOT糙米"],
178
- "7": ["NYBOT2号棉"],
179
- "8": ["TOCOM橡胶"],
180
- "10": ["原油", "20号胶", "低硫燃料油", "国际铜"],
181
- "11": ["OSE橡胶"],
182
- }
183
- temp_out_exchange_name = {
184
- "1": "上海期货交易所",
185
- "2": "郑州商品交易所",
186
- "3": "大连商品交易所",
187
- "4": "LME",
188
- "5": "NYMEX",
189
- "6": "CBOT",
190
- "7": "NYBOT",
191
- "8": "TOCOM",
192
- "10": "上海国际能源交易中心",
193
- "11": "OSE",
194
- }
195
- exchange_map = {
196
- value: key for key, value in temp_out_exchange_name.items()
52
+ temp_df = __get_99_symbol_map()
53
+ symbol_map = dict(zip(temp_df["name"], temp_df["productId"]))
54
+
55
+ url = "https://centerapi.fx168api.com/app/qh/api/stock/trend"
56
+ headers = {
57
+ "Content-Type": "application/json;charset=UTF-8",
58
+ "_pcc": "SGkj5avwu2h8Rs8/41r2LUwDHeEbaMKWe06+hWcEOO/uAQVbckWBHbwAvFbEI1eBBSvmTNqyjHKfFAn/kCpZ"
59
+ "IU7QNDvTrL2xGkQyuu+EVMU6RnZb/drmVGJRR6VhoHYMmzJvDuR6d43LnY219r44mGeL5x8qSUdh+cHjs0dm0AI=",
60
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
61
+ "Chrome/58.0.3029.110 Safari/537.3",
62
+ "referer": "https://www.99qh.com",
197
63
  }
198
- exchange = exchange_map[exchange]
199
- temp_symbol_code_map = dict(zip(data_name[exchange], data_code[exchange]))
200
- symbol = temp_symbol_code_map[symbol]
201
- out_exchange_name = {
202
- "1": "上海期货交易所",
203
- "2": "郑州商品交易所",
204
- "3": "大连商品交易所",
205
- "4": "LME",
206
- "5": "NYMEX",
207
- "6": "CBOT",
208
- "7": "NYBOT",
209
- "8": "TOCOM",
210
- "10": "上海国际能源交易中心",
211
- "11": "OSE",
64
+ params = {
65
+ "productId": symbol_map[symbol],
66
+ "type": "1",
67
+ "pageNo": "1",
68
+ "pageSize": "4000",
69
+ "startDate": "",
70
+ "endDate": f"{datetime.now().date().isoformat()}",
71
+ "appCategory": "web",
212
72
  }
213
- name_temp_dict = {}
214
- code_temp_dict = {}
215
- for num in data_code.keys():
216
- name_temp_dict[out_exchange_name[num]] = dict(
217
- zip(data_code[num], data_name[num])
218
- )
219
- code_temp_dict[num] = dict(zip(data_code[num], data_name[num]))
220
- n = 10
221
- while n != 0:
222
- try:
223
- n -= 1
224
- session = requests.Session()
225
- url = "http://service.99qh.com/Storage/Storage.aspx"
226
- params = {"page": "99qh"}
227
- r = session.post(url, params=params, headers=sample_headers)
228
- cookie = r.cookies.get_dict()
229
- url = "http://service.99qh.com/Storage/Storage.aspx"
230
- params = {"page": "99qh"}
231
- r = requests.post(
232
- url, params=params, headers=sample_headers, cookies=cookie
233
- )
234
- soup = BeautifulSoup(r.text, "lxml")
235
- view_state = soup.find_all(attrs={"id": "__VIEWSTATE"})[0]["value"]
236
- even_validation = soup.find_all(attrs={"id": "__EVENTVALIDATION"})[
237
- 0
238
- ]["value"]
239
- payload = {
240
- "__EVENTTARGET": "ddlExchName",
241
- "__EVENTARGUMENT": "",
242
- "__LASTFOCUS": "",
243
- "__VIEWSTATE": view_state,
244
- "__VIEWSTATEGENERATOR": "6EAC22FA",
245
- "__EVENTVALIDATION": even_validation,
246
- "ddlExchName": int(exchange),
247
- "ddlGoodsName": 1,
248
- }
249
- res = requests.post(
250
- url,
251
- params={"page": "99qh"},
252
- data=payload,
253
- headers=qh_headers,
254
- cookies=cookie,
255
- )
256
- soup = BeautifulSoup(res.text, "lxml")
257
- view_state = soup.find_all(attrs={"id": "__VIEWSTATE"})[0]["value"]
258
- even_validation = soup.find_all(attrs={"id": "__EVENTVALIDATION"})[
259
- 0
260
- ]["value"]
261
- payload = {
262
- "__EVENTTARGET": "ddlGoodsName",
263
- "__EVENTARGUMENT": "",
264
- "__LASTFOCUS": "",
265
- "__VIEWSTATE": view_state,
266
- "__VIEWSTATEGENERATOR": "6EAC22FA",
267
- "__EVENTVALIDATION": even_validation,
268
- "ddlExchName": int(exchange),
269
- "ddlGoodsName": int(symbol),
270
- }
271
- res = requests.post(
272
- url,
273
- params=params,
274
- data=payload,
275
- headers=qh_headers,
276
- cookies=cookie,
277
- )
278
- data_df = pd.read_html(StringIO(res.text))[-1].T
279
- data_df.columns = data_df.iloc[0, :]
280
- data_df = data_df.iloc[1:, :]
281
- data_df.reset_index(inplace=True, drop=True)
282
- data_df.columns.name = None
283
- data_df["日期"] = pd.to_datetime(data_df["日期"]).dt.date
284
- data_df["库存"] = pd.to_numeric(data_df["库存"])
285
- data_df["增减"] = pd.to_numeric(data_df["增减"])
286
- data_df.sort_values("日期", inplace=True)
287
- data_df.reset_index(inplace=True, drop=True)
288
- return data_df
289
- except:
290
- continue
73
+ r = requests.get(url, params, headers=headers)
74
+ data_json = r.json()
75
+ temp_df = pd.DataFrame(data_json["data"]["list"])
76
+ temp_df.columns = ["日期", "收盘价", "库存"]
77
+ temp_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
78
+ temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
79
+ temp_df["收盘价"] = pd.to_numeric(temp_df["收盘价"], errors="coerce")
80
+ temp_df["库存"] = pd.to_numeric(temp_df["库存"], errors="coerce")
81
+ return temp_df
291
82
 
292
83
 
293
84
  if __name__ == "__main__":
294
- futures_inventory_99_df = futures_inventory_99(
295
- exchange="郑州商品交易所", symbol="菜籽油"
296
- )
85
+ futures_inventory_99_df = futures_inventory_99(symbol="豆一")
297
86
  print(futures_inventory_99_df)
@@ -1,203 +1,15 @@
1
1
  # -*- coding:utf-8 -*-
2
2
  # !/usr/bin/env python
3
3
  """
4
- Date: 2023/7/6 17:00
4
+ Date: 2024/12/23 17:00
5
5
  Desc: 中证指数-所有指数-历史行情数据
6
6
  https://www.csindex.com.cn/zh-CN/indices/index-detail/H30374#/indices/family/list?index_series=1
7
7
  """
8
8
 
9
- import hashlib
10
- import time
11
- from functools import lru_cache
12
-
13
9
  import pandas as pd
14
10
  import requests
15
11
 
16
12
 
17
- def __get_current_timestamp_ms() -> int:
18
- """
19
- 生成时间戳
20
- :return: 时间戳
21
- :rtype: int
22
- """
23
- timestamp_seconds = time.time()
24
- timestamp_ms = int(timestamp_seconds * 1000)
25
- return timestamp_ms
26
-
27
-
28
- def __md5_hash(input_string) -> str:
29
- """
30
- 生成 md5 加密后的值
31
- :return: 生成 md5 加密后的值
32
- :rtype: str
33
- """
34
- md5 = hashlib.md5()
35
- md5.update(input_string.encode("utf-8"))
36
- return md5.hexdigest()
37
-
38
-
39
- def __create_encode(
40
- act_time="1688635494326",
41
- authtoken="",
42
- gu_code="399808.SZ",
43
- pe_category="pb",
44
- type="pc",
45
- ver="new",
46
- version="2.2.7",
47
- year=-1,
48
- ) -> dict:
49
- """
50
- 生成 post 密文,需要 JS 观察如下文件:
51
- https://funddb.cn/static/js/app.1c429c670c72542fb4fd.js
52
- :return: 生成 post 密文
53
- :rtype: str
54
- """
55
- input_string = f"{act_time}{authtoken}{gu_code}{pe_category}{type}{ver}{version}{year}EWf45rlv#kfsr@k#gfksgkr"
56
- hash_value = __md5_hash(input_string)
57
- l = hash_value # noqa: E741
58
- c = l[29:31]
59
- d = l[2:4]
60
- f = l[5:6]
61
- h = l[26:27]
62
- m = l[6:8]
63
- v = l[1:2]
64
- y = l[0:2]
65
- k = l[6:8]
66
- w = l[8:9]
67
- x = l[30:31]
68
- P = l[11:14]
69
- z = l[11:12]
70
- j = l[2:5]
71
- q = l[9:11]
72
- H = l[23:25]
73
- O = l[31:32] # noqa: E741
74
- C = l[25:27]
75
- E = l[9:11]
76
- A = l[27:29]
77
- T = l[17:19]
78
- F = l[26:27]
79
- U = l[12:14]
80
- S = l[25:26]
81
- R = l[16:19]
82
- K = l[17:21]
83
- I = l[18:19] # noqa: E741
84
- D = l[21:23]
85
- _ = l[
86
- 14:16
87
- ] # $ is not a valid variable name in Python, so I replaced it with an underscore
88
- B = l[29:32]
89
- N = l[21:23]
90
- V = l[24:26]
91
- Y = l[16:17]
92
-
93
- def b(
94
- t,
95
- e,
96
- n,
97
- i,
98
- a,
99
- r,
100
- o,
101
- l, # noqa: E741
102
- u,
103
- c,
104
- s,
105
- d,
106
- _,
107
- f,
108
- h,
109
- p,
110
- m,
111
- g,
112
- v,
113
- y,
114
- b,
115
- k,
116
- w,
117
- x,
118
- P,
119
- z,
120
- j,
121
- q,
122
- H,
123
- O, # noqa: E741
124
- C,
125
- E,
126
- A,
127
- ):
128
- t["data"]["tirgkjfs"] = f
129
- t["data"]["abiokytke"] = _
130
- t["data"]["u54rg5d"] = e
131
- t["data"]["kf54ge7"] = q
132
- t["data"]["tiklsktr4"] = d
133
- t["data"]["lksytkjh"] = z
134
- t["data"]["sbnoywr"] = j
135
- t["data"]["bgd7h8tyu54"] = w
136
- t["data"]["y654b5fs3tr"] = C
137
- t["data"]["bioduytlw"] = n
138
- t["data"]["bd4uy742"] = P
139
- t["data"]["h67456y"] = o
140
- t["data"]["bvytikwqjk"] = s
141
- t["data"]["ngd4uy551"] = b
142
- t["data"]["bgiuytkw"] = v
143
- t["data"]["nd354uy4752"] = g
144
- t["data"]["ghtoiutkmlg"] = x
145
- t["data"]["bd24y6421f"] = i
146
- t["data"]["tbvdiuytk"] = l
147
- t["data"]["ibvytiqjek"] = p
148
- t["data"]["jnhf8u5231"] = A
149
- t["data"]["fjlkatj"] = E
150
- t["data"]["hy5641d321t"] = H
151
- t["data"]["iogojti"] = r
152
- t["data"]["ngd4yut78"] = a
153
- t["data"]["nkjhrew"] = c
154
- t["data"]["yt447e13f"] = O
155
- t["data"]["n3bf4uj7y7"] = k
156
- t["data"]["nbf4uj7y432"] = h
157
- t["data"]["yi854tew"] = u
158
- t["data"]["h13ey474"] = m
159
- t["data"]["quikgdky"] = y
160
-
161
- t = {"data": {}}
162
-
163
- b(
164
- t,
165
- d,
166
- f,
167
- V,
168
- U,
169
- S,
170
- R,
171
- Y,
172
- c,
173
- h,
174
- m,
175
- v,
176
- N,
177
- y,
178
- D,
179
- _,
180
- B,
181
- x,
182
- E,
183
- A,
184
- T,
185
- I,
186
- k,
187
- P,
188
- F,
189
- K,
190
- H,
191
- O,
192
- C,
193
- w,
194
- z,
195
- j,
196
- q,
197
- )
198
- return t["data"]
199
-
200
-
201
13
  def stock_zh_index_hist_csindex(
202
14
  symbol: str = "000928",
203
15
  start_date: str = "20180526",
@@ -243,7 +55,7 @@ def stock_zh_index_hist_csindex(
243
55
  "样本数量",
244
56
  "滚动市盈率",
245
57
  ]
246
- temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date
58
+ temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
247
59
  temp_df["开盘"] = pd.to_numeric(temp_df["开盘"], errors="coerce")
248
60
  temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
249
61
  temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
@@ -293,176 +105,6 @@ def stock_zh_index_value_csindex(symbol: str = "H30374") -> pd.DataFrame:
293
105
  return temp_df
294
106
 
295
107
 
296
- @lru_cache()
297
- def index_value_name_funddb() -> pd.DataFrame:
298
- """
299
- funddb-指数估值-指数代码
300
- https://funddb.cn/site/index
301
- :return: pandas.DataFrame
302
- :rtype: 指数代码
303
- """
304
- url = "https://api.jiucaishuo.com/v2/guzhi/showcategory"
305
- get_current_timestamp_ms_str = __get_current_timestamp_ms()
306
- encode_params = __create_encode(
307
- act_time=str(get_current_timestamp_ms_str),
308
- authtoken="",
309
- gu_code="",
310
- pe_category="",
311
- type="pc",
312
- ver="",
313
- version="2.2.7",
314
- year="",
315
- )
316
- payload = {
317
- "type": "pc",
318
- "version": "2.2.7",
319
- "authtoken": "",
320
- "act_time": str(get_current_timestamp_ms_str),
321
- }
322
- payload.update(encode_params)
323
- r = requests.post(url, json=payload)
324
- data_json = r.json()
325
- temp_df = pd.DataFrame(data_json["data"]["right_list"])
326
- temp_df.columns = [
327
- "指数开始时间",
328
- "-",
329
- "指数名称",
330
- "指数代码",
331
- "最新PE",
332
- "最新PB",
333
- "PE分位",
334
- "PB分位",
335
- "股息率",
336
- "-",
337
- "-",
338
- "-",
339
- "更新时间",
340
- "股息率分位",
341
- "-",
342
- "-",
343
- "-",
344
- "-",
345
- "-",
346
- "-",
347
- "-",
348
- "-",
349
- "-",
350
- "-",
351
- "-",
352
- "-",
353
- "-",
354
- "-",
355
- "-",
356
- "-",
357
- ]
358
- temp_df = temp_df[
359
- [
360
- "指数名称",
361
- "最新PE",
362
- "PE分位",
363
- "最新PB",
364
- "PB分位",
365
- "股息率",
366
- "股息率分位",
367
- "指数代码",
368
- "指数开始时间",
369
- "更新时间",
370
- ]
371
- ]
372
- temp_df["指数开始时间"] = pd.to_datetime(
373
- temp_df["指数开始时间"], errors="coerce"
374
- ).dt.date
375
- temp_df["最新PE"] = pd.to_numeric(temp_df["最新PE"], errors="coerce")
376
- temp_df["PE分位"] = pd.to_numeric(temp_df["PE分位"], errors="coerce")
377
- temp_df["最新PB"] = pd.to_numeric(temp_df["最新PB"], errors="coerce")
378
- temp_df["PB分位"] = pd.to_numeric(temp_df["PB分位"], errors="coerce")
379
- temp_df["股息率"] = pd.to_numeric(temp_df["股息率"], errors="coerce")
380
- temp_df["股息率分位"] = pd.to_numeric(temp_df["股息率分位"], errors="coerce")
381
- return temp_df
382
-
383
-
384
- def index_value_hist_funddb(
385
- symbol: str = "大盘成长", indicator: str = "市盈率", year: str = "-1"
386
- ) -> pd.DataFrame:
387
- """
388
- funddb-指数估值-估值信息
389
- https://funddb.cn/site/index
390
- :param symbol: 指数名称; 通过调用 ak.index_value_name_funddb() 来获取
391
- :type symbol: str
392
- :param indicator: choice of {'市盈率', '市净率', '股息率', '风险溢价'}
393
- :type indicator: str
394
- :param year: choice of {'-1': "所有", '3': "近3年", '5': "近5年", '10': "近10年"}
395
- :type year: str
396
- :return: 估值信息
397
- :rtype: pandas.DataFrame
398
- """
399
- indicator_map = {
400
- "市盈率": "pe",
401
- "市净率": "pb",
402
- "股息率": "xilv",
403
- "风险溢价": "fed",
404
- }
405
- index_value_name_funddb_df = index_value_name_funddb()
406
- name_code_map = dict(
407
- zip(
408
- index_value_name_funddb_df["指数名称"],
409
- index_value_name_funddb_df["指数代码"],
410
- )
411
- )
412
- url = "https://api.jiucaishuo.com/v2/guzhi/newtubiaolinedata"
413
- get_current_timestamp_ms_str = __get_current_timestamp_ms()
414
- encode_params = __create_encode(
415
- act_time=str(get_current_timestamp_ms_str),
416
- authtoken="",
417
- gu_code=name_code_map[symbol],
418
- pe_category=indicator_map[indicator],
419
- type="pc",
420
- ver="new",
421
- version="2.2.7",
422
- year=int(year),
423
- )
424
- payload = {
425
- "gu_code": name_code_map[symbol],
426
- "pe_category": indicator_map[indicator],
427
- "year": int(year),
428
- "ver": "new",
429
- "type": "pc",
430
- "version": "2.2.7",
431
- "authtoken": "",
432
- "act_time": str(get_current_timestamp_ms_str),
433
- }
434
- payload.update(encode_params)
435
- r = requests.post(url, json=payload)
436
- data_json = r.json()
437
- big_df = pd.DataFrame()
438
- temp_df = pd.DataFrame(
439
- data_json["data"]["tubiao"]["series"][0]["data"],
440
- columns=["timestamp", "value"],
441
- )
442
- big_df["日期"] = (
443
- pd.to_datetime(temp_df["timestamp"], unit="ms", utc=True)
444
- .dt.tz_convert("Asia/Shanghai")
445
- .dt.date
446
- )
447
- big_df["平均值"] = pd.to_numeric(temp_df["value"])
448
- big_df[indicator] = pd.to_numeric(
449
- [item[1] for item in data_json["data"]["tubiao"]["series"][1]["data"]]
450
- )
451
- big_df["最低30"] = pd.to_numeric(
452
- [item[1] for item in data_json["data"]["tubiao"]["series"][2]["data"]]
453
- )
454
- big_df["最低10"] = pd.to_numeric(
455
- [item[1] for item in data_json["data"]["tubiao"]["series"][3]["data"]]
456
- )
457
- big_df["最高30"] = pd.to_numeric(
458
- [item[1] for item in data_json["data"]["tubiao"]["series"][4]["data"]]
459
- )
460
- big_df["最高10"] = pd.to_numeric(
461
- [item[1] for item in data_json["data"]["tubiao"]["series"][5]["data"]]
462
- )
463
- return big_df
464
-
465
-
466
108
  if __name__ == "__main__":
467
109
  stock_zh_index_hist_csindex_df = stock_zh_index_hist_csindex(
468
110
  symbol="000928", start_date="20100101", end_date="20240604"
@@ -471,11 +113,3 @@ if __name__ == "__main__":
471
113
 
472
114
  stock_zh_index_value_csindex_df = stock_zh_index_value_csindex(symbol="H30374")
473
115
  print(stock_zh_index_value_csindex_df)
474
-
475
- index_value_name_funddb_df = index_value_name_funddb()
476
- print(index_value_name_funddb_df)
477
-
478
- index_value_hist_funddb_df = index_value_hist_funddb(
479
- symbol="大盘成长", indicator="市盈率", year="-1"
480
- )
481
- print(index_value_hist_funddb_df)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: akshare
3
- Version: 1.15.51
3
+ Version: 1.15.53
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=enlu3yvTdssFK9ultKiulg2pjakyGFCiirI0id7EBcs,184737
1
+ akshare/__init__.py,sha256=2SaACef3zm3ubS7l_7DNebqR6iQAKIv1ILNe87vi0iI,184584
2
2
  akshare/datasets.py,sha256=-qdwaQjgBlftX84uM74KJqCYJYkQ50PV416_neA4uls,995
3
3
  akshare/exceptions.py,sha256=WEJjIhSmJ_xXNW6grwV4nufE_cfmmyuhmueVGiN1VAg,878
4
4
  akshare/request.py,sha256=HtFFf9MhfEibR-ETWe-1Tts6ELU4VKSqA-ghaXjegQM,4252
@@ -102,7 +102,7 @@ akshare/fund/fund_scale_em.py,sha256=8XLZpz9DzsAnJCo1moBmzf3u7mfZNZHsb3cPKJ-gCJM
102
102
  akshare/fund/fund_scale_sina.py,sha256=A0qIzWBQdE3IGS9-cxO9_FNpuH-BAG5HhPk5KzTFTFc,8167
103
103
  akshare/fund/fund_xq.py,sha256=AxMZB-940bNY7-BatVLZiseHNxiWA17hQzTfuxGibPU,11306
104
104
  akshare/futures/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
105
- akshare/futures/cons.py,sha256=zD2uRQK3v-mywcDZfL28sDdRl6WIeWthHTfu8nrcQAo,16252
105
+ akshare/futures/cons.py,sha256=swjc7oENcgqtFobdSLozErxyl2xVlWLVwMx8_Q1jFac,14765
106
106
  akshare/futures/cot.py,sha256=Kkza2slS7JQpXndKrQEEykzIjZIT3vhvtZHVJ7P1yac,58573
107
107
  akshare/futures/futures_basis.py,sha256=pmXNXdWnfvJCRs6xKJ0Ed9R2v92-NK2Sp3AjlwecErc,15691
108
108
  akshare/futures/futures_comex_em.py,sha256=V-mkKQkH5N8PyaZWKdyggb2lTnY8DDDxiUPt-1leQu0,3171
@@ -114,7 +114,7 @@ akshare/futures/futures_foreign.py,sha256=oSIoAg5oy-CIlPWHkQffcvZGu02Y2GWOrt-6aP
114
114
  akshare/futures/futures_hf_em.py,sha256=jne-wUYr2QTUkDq3qAxYKE0Hm90L3H8qUDu3JavKiUg,3338
115
115
  akshare/futures/futures_hq_sina.py,sha256=eK1gEan4DPvpYmln8-tNnzh_J_733s95DBr--NqNYVA,9576
116
116
  akshare/futures/futures_index_ccidx.py,sha256=9Rhk3ps-H69tU-NIV0W2NdLFUDTSUx0bwtePA6gLMZA,4566
117
- akshare/futures/futures_inventory_99.py,sha256=Nvw39obGGhgOkk_C4jOrV4gdq78dtHPOnits_B0Ljxk,8450
117
+ akshare/futures/futures_inventory_99.py,sha256=xdX8GSCEcRWYnbw0XS22rcblXOvlzUvfUltv7oyRh3Y,2990
118
118
  akshare/futures/futures_inventory_em.py,sha256=C5nt4F51WB-oc8o3GrMvEGo0SO2mIq_H1vHVl42vzT0,2340
119
119
  akshare/futures/futures_news_baidu.py,sha256=uqXUgQa7_aNjj1g4IBt6Ic4DhlsuBvjEEYC3OTPeqmA,1544
120
120
  akshare/futures/futures_news_shmet.py,sha256=NQXUo6bwsDwxWID-5CUgJxENWtiaDK4JgMaTEmurYvM,2464
@@ -126,7 +126,6 @@ akshare/futures/futures_stock_js.py,sha256=BV_1Hm9osxWQmNSt24DQ52hAMrfMqP6eud657
126
126
  akshare/futures/futures_to_spot.py,sha256=0MCVcZoZoOMd7DSR357K2UHoRBCeHyONyRCu8oWVWuw,12841
127
127
  akshare/futures/futures_warehouse_receipt.py,sha256=wF98kwKsIc0GCcwgwoup2m76Pg800HdXY29Wf1jvDNc,9116
128
128
  akshare/futures/futures_zh_sina.py,sha256=NMzqFbLkrUaeO1AouZUFqgekYBAm7j5ew2LTlruapFE,26197
129
- akshare/futures/inventory_data.py,sha256=m1DCzClDudj4qQLjgl5i6Lbazu0wIm9R3RerHCPcp38,4097
130
129
  akshare/futures/receipt.py,sha256=CGk0HKSJLeWSahkXmep8LVceAbN3wooTjMqGlQkegAY,22054
131
130
  akshare/futures/requests_fun.py,sha256=s31tnP2qUwEux43RX_t3K1uToJiSQ7xHYYQ_0bp16O0,2832
132
131
  akshare/futures/symbol_var.py,sha256=HnKKQ8waVW6sjlqh4F9vsloKY1NVs2s_-M4DB5hb7cA,5589
@@ -157,7 +156,6 @@ akshare/index/index_cons.py,sha256=3jrDfdxhNr9c4NVsTVOyORZwKBFNUU8giERYoIKkUUY,7
157
156
  akshare/index/index_cx.py,sha256=aAmsIKkswKFNOhAsW0QOhp-q6q1aFOSBtqcDaZhIh6A,16775
158
157
  akshare/index/index_drewry.py,sha256=BM7V6P8K4QUFQArsdaWRu5qJUZaCoyNz97_b8dmLeCw,2937
159
158
  akshare/index/index_eri.py,sha256=7X0KNDBntEkE_qSb2jb6IBv-S8PsevLFdxGT8nKT3W0,2111
160
- akshare/index/index_fear_greed_funddb.py,sha256=7Z6GqYkKPJHNHMEN-uZNu2KnNNLTWvJcVlYpfAShJJc,2378
161
159
  akshare/index/index_hog.py,sha256=kb867BVagt70_ycZMn22ks5Z9jlVbMiuTsvq5ygjeig,1657
162
160
  akshare/index/index_kq_fz.py,sha256=Y-cbxWLpRyGcFcMSDxZZQXdAuD85IuQH5xC2rhtGbRc,3395
163
161
  akshare/index/index_kq_ss.py,sha256=m4hAMNnzHk8JNAnKjkYYVeyG4zUC5zR5i0-u-OxmaGU,3333
@@ -168,7 +166,7 @@ akshare/index/index_spot.py,sha256=HrXt2QC9i1pYEh7wyJPKjtexctzSIUyMjEzk5BQq_K8,1
168
166
  akshare/index/index_stock_hk.py,sha256=nPFzRrjyiUpRK-OSDsdi5AFCKHNKqOVji6WJcQxOvNo,9781
169
167
  akshare/index/index_stock_us_sina.py,sha256=IxOk4G49oasv7EfEQenL9-GLuelyUus6c4JPyRlaOzY,1551
170
168
  akshare/index/index_stock_zh.py,sha256=A-tfbz6KHTLmBJimSzvaINrdmkWJ8V-mUkjcy7ly258,17669
171
- akshare/index/index_stock_zh_csindex.py,sha256=jVF29Byn2guaZ4QsXwwL1C5qtqk_m1ja-dgDnKnfz8s,13267
169
+ akshare/index/index_stock_zh_csindex.py,sha256=fIgPyhjbjd8JuREXNZRXEBbKAi4qQh8NaDPSc4k1k5k,4197
172
170
  akshare/index/index_sugar.py,sha256=B_Nj9Q6JP-Y_d7myZ0C79izTxxrbuZIp1Vv_CilVMOc,5006
173
171
  akshare/index/index_sw.py,sha256=hETMmFszQb7JDY8UHjLK8szfwkr7Ui_6QcseOoEfxaI,10456
174
172
  akshare/index/index_yw.py,sha256=6FF38kooLQulnMTqAd1__TNWip4XC1VA72k3T049xYc,4319
@@ -380,8 +378,8 @@ akshare/utils/token_process.py,sha256=K4rGXjh_tgugbRcyOK2h2x0jP3PT65IIK7nxhUKhOe
380
378
  akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
381
379
  tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
382
380
  tests/test_func.py,sha256=j1MGYbZI2if2j_LY1S4FLsf4qfq4NwVqD5wmRlv5Log,832
383
- akshare-1.15.51.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
384
- akshare-1.15.51.dist-info/METADATA,sha256=AM8ozZOv4s_KJTomr5Tvk7NeLqBqFv6SjmJENJ1JpBI,13423
385
- akshare-1.15.51.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
386
- akshare-1.15.51.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
387
- akshare-1.15.51.dist-info/RECORD,,
381
+ akshare-1.15.53.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
382
+ akshare-1.15.53.dist-info/METADATA,sha256=SjNgBu98A4GV4_4GSZqLTlAX5E0T35kZdQB3pIGWZIc,13423
383
+ akshare-1.15.53.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
384
+ akshare-1.15.53.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
385
+ akshare-1.15.53.dist-info/RECORD,,
@@ -1,100 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding:utf-8 -*-
3
- """
4
- Date: 2021/1/10 13:58
5
- Desc: 得到 99 期货网的原始数据
6
- """
7
- import requests
8
- import pickle
9
- from bs4 import BeautifulSoup
10
- import time
11
-
12
-
13
- url = "http://service.99qh.com/Storage/Storage.aspx?page=99qh"
14
-
15
- sample_headers = {
16
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
17
- "Host": "service.99qh.com",
18
- "Origin": "http://service.99qh.com",
19
- "Referer": "http://www.99qh.com/d/store.aspx",
20
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
21
- }
22
-
23
- res = requests.get(url, headers=sample_headers)
24
-
25
- soup = BeautifulSoup(res.text, "lxml")
26
- view_state = soup.find_all(attrs={"id": "__VIEWSTATE"})[0]["value"]
27
- even_validation = soup.find_all(attrs={"id": "__EVENTVALIDATION"})[0]["value"]
28
-
29
- qh_headers = {
30
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
31
- "Accept-Encoding": "gzip, deflate",
32
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
33
- "Cache-Control": "max-age=0",
34
- "Connection": "keep-alive",
35
- "Content-Length": "4458",
36
- "Content-Type": "application/x-www-form-urlencoded",
37
- "Host": "service.99qh.com",
38
- "Origin": "http://service.99qh.com",
39
- "Referer": "http://service.99qh.com/Storage/Storage.aspx?page=99qh",
40
- "Upgrade-Insecure-Requests": "1",
41
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
42
- }
43
-
44
- code_temp_list = [item["value"] for item in soup.find_all("select")[0].find_all("option")]
45
- name_temp_list = [item.get_text() for item in soup.find_all("select")[0].find_all("option")]
46
- code_exchange_name_dict = dict(zip(code_temp_list, name_temp_list))
47
- exchange_value = soup.find_all("select")[0].find_all(attrs={"selected": "selected"})[0]["value"]
48
- symbol_list = soup.find_all("select")[1].get_text().split("\n")[1:-1]
49
- symbol_value_list = [item["value"] for item in soup.find_all("select")[1].find_all("option")]
50
- code_symbol_code_dict = dict()
51
- code_symbol_code_dict[exchange_value] = symbol_value_list
52
-
53
- exchange_symbol_list = {}
54
- exchange_symbol_value_list = {}
55
- for i in code_temp_list:
56
- # i = 14
57
- print(i)
58
- j = 0
59
- while j < 5:
60
- try:
61
- payload = {
62
- "__EVENTTARGET": "ddlExchName",
63
- "__EVENTARGUMENT": "",
64
- "__LASTFOCUS": "",
65
- "__VIEWSTATE": view_state,
66
- "__VIEWSTATEGENERATOR": "6EAC22FA",
67
- "__EVENTVALIDATION": even_validation,
68
- "ddlExchName": i,
69
- # "ddlGoodsName": 6
70
- }
71
-
72
- res = requests.post(url, data=payload, headers=qh_headers)
73
- soup = BeautifulSoup(res.text, "lxml")
74
- exchange = soup.find_all("select")[0].find_all(attrs={"selected": "selected"})[0].get_text()
75
- print(exchange)
76
- exchange_value = soup.find_all("select")[0].find_all(attrs={"selected": "selected"})[0]["value"]
77
- print(exchange_value)
78
- symbol_list = soup.find_all("select")[1].get_text().split("\n")[1:-1]
79
- exchange_symbol_list.update({exchange_value: symbol_list})
80
- symbol_value_list = [item["value"] for item in soup.find_all("select")[1].find_all("option")]
81
- exchange_symbol_value_list.update({exchange_value: symbol_value_list})
82
- view_state = soup.find_all(attrs={"id": "__VIEWSTATE"})[0]["value"]
83
- even_validation = soup.find_all(attrs={"id": "__EVENTVALIDATION"})[0]["value"]
84
- time.sleep(5)
85
- except:
86
- j += 1
87
- continue
88
-
89
-
90
- with open('./akshare/futures/exchange_symbol_list.pk', 'wb') as f:
91
- pickle.dump(exchange_symbol_list, f)
92
-
93
- with open('./akshare/futures/exchange_symbol_value_list.pk', 'wb') as f:
94
- pickle.dump(exchange_symbol_value_list, f)
95
-
96
- with open('./akshare/futures/code_exchange_name_dict.pk', 'wb') as f:
97
- pickle.dump(code_exchange_name_dict, f)
98
-
99
-
100
-
@@ -1,78 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
- # !/usr/bin/env python
3
- """
4
- Date: 2024/4/21 17:00
5
- Desc: funddb-工具-估值情绪-恐惧贪婪指数
6
- https://funddb.cn/tool/fear
7
- """
8
-
9
- import json
10
-
11
- import pandas as pd
12
- import requests
13
- import py_mini_racer
14
-
15
- from akshare.datasets import get_ths_js
16
-
17
-
18
- def _get_file_content_ths(file: str = "cninfo.js") -> str:
19
- """
20
- 获取 JS 文件的内容
21
- :param file: JS 文件名
22
- :type file: str
23
- :return: 文件内容
24
- :rtype: str
25
- """
26
- setting_file_path = get_ths_js(file)
27
- with open(setting_file_path, encoding="utf8") as f:
28
- file_data = f.read()
29
- return file_data
30
-
31
-
32
- def index_fear_greed_funddb(symbol: str = "上证指数") -> pd.DataFrame:
33
- """
34
- funddb-工具-估值情绪-恐惧贪婪指数
35
- https://funddb.cn/tool/fear
36
- :param symbol: choice of {"上证指数", "沪深300"}
37
- :type symbol: str
38
- :return: 恐惧贪婪指数
39
- :rtype: pandas.DataFrame
40
- """
41
- symbol_map = {
42
- "上证指数": "000001.SH",
43
- "沪深300": "000300.SH",
44
- }
45
- url = "https://api.jiucaishuo.com/v2/kjtl/kjtlconnect"
46
- payload = {
47
- "gu_code": symbol_map[symbol],
48
- "type": "h5",
49
- "version": "2.4.5",
50
- "act_time": 1697623588394,
51
- }
52
- r = requests.post(url, json=payload)
53
- data_json = r.json()
54
- js_code = py_mini_racer.MiniRacer()
55
- js_content = _get_file_content_ths("cninfo.js")
56
- js_code.eval(js_content)
57
- mcode = js_code.call("new_my_decode", data_json)
58
- data_json = json.loads(mcode)
59
- date_list = data_json["data"]["xAxis"]["categories"]
60
- tl_list = data_json["data"]["series"][0]["data"]
61
- sz_list = data_json["data"]["series"][1]["data"]
62
- temp_df = pd.DataFrame([date_list, tl_list, sz_list]).T
63
- temp_df.columns = ["date", "fear", "index"]
64
- temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.date
65
- temp_df["fear"] = pd.to_numeric(temp_df["fear"], errors="coerce")
66
- temp_df["index"] = pd.to_numeric(temp_df["index"], errors="coerce")
67
-
68
- temp_df["fear"] = temp_df["fear"].round(2)
69
- temp_df["index"] = temp_df["index"].round(2)
70
- return temp_df
71
-
72
-
73
- if __name__ == "__main__":
74
- index_fear_greed_funddb_df = index_fear_greed_funddb(symbol="上证指数")
75
- print(index_fear_greed_funddb_df)
76
-
77
- index_fear_greed_funddb_df = index_fear_greed_funddb(symbol="沪深300")
78
- print(index_fear_greed_funddb_df)