Skip to content

Commit 2004a83

Browse files
authored
Merge pull request #214 from mucwj/fixbug-eastmoney-recorder
The Eastmoney API has changed, and a new API has been matched
2 parents c5276c9 + 9d55aed commit 2004a83

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

src/zvt/recorders/eastmoney/meta/eastmoney_stock_meta_recorder.py

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,40 +52,59 @@ def run(self):
5252
fc = "{}02".format(security_item.code)
5353

5454
# 基本资料
55-
param = {"color": "w", "fc": fc, "SecurityCode": "SZ300059"}
56-
resp = requests.post("https://emh5.eastmoney.com/api/GongSiGaiKuang/GetJiBenZiLiao", json=param)
55+
# param = {"color": "w", "fc": fc, "SecurityCode": "SZ300059"}
56+
57+
securities_code = f"{security_item.code}.{security_item.exchange.upper()}"
58+
param = {
59+
"type": "RPT_F10_ORG_BASICINFO",
60+
"sty": "ORG_PROFIE,MAIN_BUSINESS,FOUND_DATE,EM2016,BLGAINIAN,REGIONBK",
61+
"filter": f"(SECUCODE=\"{securities_code}\")",
62+
"client": "app",
63+
"source": "SECURITIES",
64+
"pageNumber": 1,
65+
"pageSize": 1
66+
}
67+
resp = requests.get("https://datacenter.eastmoney.com/securities/api/data/get", params=param)
5768
resp.encoding = "utf8"
5869

59-
resp_json = resp.json()["Result"]["JiBenZiLiao"]
70+
resp_json = resp.json()["result"]["data"][0]
6071

61-
security_item.profile = resp_json["CompRofile"]
62-
security_item.main_business = resp_json["MainBusiness"]
63-
security_item.date_of_establishment = to_pd_timestamp(resp_json["FoundDate"])
72+
security_item.profile = resp_json["ORG_PROFIE"]
73+
security_item.main_business = resp_json["MAIN_BUSINESS"]
74+
security_item.date_of_establishment = to_pd_timestamp(resp_json["FOUND_DATE"])
6475

6576
# 关联行业
66-
industries = ",".join(resp_json["Industry"].split("-"))
77+
industries = ",".join(resp_json["EM2016"].split("-"))
6778
security_item.industries = industries
6879

6980
# 关联概念
70-
security_item.concept_indices = resp_json["Block"]
81+
security_item.concept_indices = resp_json["BLGAINIAN"]
7182

7283
# 关联地区
73-
security_item.area_indices = resp_json["Provice"]
84+
security_item.area_indices = resp_json["REGIONBK"]
7485

7586
self.sleep()
7687

7788
# 发行相关
78-
param = {"color": "w", "fc": fc}
79-
resp = requests.post("https://emh5.eastmoney.com/api/GongSiGaiKuang/GetFaXingXiangGuan", json=param)
89+
param = {
90+
"reportName": "RPT_F10_ORG_ISSUEINFO",
91+
"columns": "AFTER_ISSUE_PE,ISSUE_PRICE,TOTAL_ISSUE_NUM,NET_RAISE_FUNDS,ONLINE_ISSUE_LWR",
92+
"filter": f"(SECUCODE=\"{securities_code}\")(TYPENEW=\"4\")",
93+
"client": "app",
94+
"source": "SECURITIES",
95+
"pageNumber": 1,
96+
"pageSize": 1
97+
}
98+
resp = requests.get("https://datacenter.eastmoney.com/securities/api/data/v1/get", params=param)
8099
resp.encoding = "utf8"
81100

82-
resp_json = resp.json()["Result"]["FaXingXiangGuan"]
101+
resp_json = resp.json()["result"]["data"][0]
83102

84-
security_item.issue_pe = to_float(resp_json["PEIssued"])
85-
security_item.price = to_float(resp_json["IssuePrice"])
86-
security_item.issues = to_float(resp_json["ShareIssued"])
87-
security_item.raising_fund = to_float((resp_json["NetCollection"]))
88-
security_item.net_winning_rate = pct_to_float(resp_json["LotRateOn"])
103+
security_item.issue_pe = resp_json["AFTER_ISSUE_PE"]
104+
security_item.price = resp_json["ISSUE_PRICE"]
105+
security_item.issues = resp_json["TOTAL_ISSUE_NUM"]
106+
security_item.raising_fund = resp_json.get("NET_RAISE_FUNDS")
107+
security_item.net_winning_rate = resp_json["ONLINE_ISSUE_LWR"]
89108

90109
self.session.commit()
91110

0 commit comments

Comments
 (0)