diff --git a/akshare/__init__.py b/akshare/__init__.py index 69243f4c3b7..b6e9ae35574 100644 --- a/akshare/__init__.py +++ b/akshare/__init__.py @@ -2954,9 +2954,10 @@ 1.15.42 fix: fix get_roll_yield_bar interface 1.15.43 fix: fix macro_china_urban_unemployment interface 1.15.44 fix: fix index_detail_hist_adjust_cni interface +1.15.45 fix: fix stock_jgdy_detail_em interface """ -__version__ = "1.15.44" +__version__ = "1.15.45" __author__ = "AKFamily" import sys diff --git a/akshare/futures/futures_basis.py b/akshare/futures/futures_basis.py index 004efea7ce0..9c062ace59d 100644 --- a/akshare/futures/futures_basis.py +++ b/akshare/futures/futures_basis.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- """ -Date: 2024/11/28 22:00 +Date: 2024/12/12 17:00 Desc: 生意社网站采集大宗商品现货价格及相应基差数据, 数据时间段从 20110104-至今 备注:现期差 = 现货价格 - 期货价格(这里的期货价格为结算价) 黄金为 元/克, 白银为 元/千克, 玻璃现货为 元/平方米, 鸡蛋现货为 元/公斤, 鸡蛋期货为 元/500千克, 其余为 元/吨. @@ -124,9 +124,9 @@ def futures_spot_price( return temp_df else: time.sleep(3) - except: # noqa: E722 + except Exception as e: # noqa: E722 print( - f"{date.strftime('%Y-%m-%d')}日生意社数据连接失败,第{str(i)}次尝试,最多5次" + f"{date.strftime('%Y-%m-%d')}日生意社数据连接失败[错误信息:{e}],第{str(i)}次尝试,最多5次" ) i += 1 if i > 5: @@ -187,6 +187,8 @@ def _check_information(df_data, date): "郑州商品交易所", "大连商品交易所", "广州期货交易所", + # 某些天网站没有数据,比如 20180912,此时返回"暂无数据",但并不是网站被墙了 + "暂无数据", ]: symbol = chinese_to_english(news) record = pd.DataFrame(df_data[df_data["symbol"] == string]) @@ -206,6 +208,16 @@ def _check_information(df_data, date): record.loc[:, "spot_price"] = float(record["spot_price"].iloc[0]) * 1000 records = pd.concat([records, record]) + # 20241129:如果某日没有数据,直接返回返回空表 + if records.empty: + records = df_data.iloc[0:0] + records["near_basis"] = pd.Series(dtype="float") + records["dom_basis"] = pd.Series(dtype="float") + records["near_basis_rate"] = pd.Series(dtype="float") + records["dom_basis_rate"] = pd.Series(dtype="float") + records["date"] = pd.Series(dtype="object") + return records + records.loc[:, ["near_contract_price", "dominant_contract_price", "spot_price"]] = ( records.loc[ :, ["near_contract_price", "dominant_contract_price", "spot_price"] @@ -259,6 +271,7 @@ def _check_information(df_data, date): records["dom_basis_rate"] = ( records["dominant_contract_price"] / records["spot_price"] - 1 ) + # records.loc[:, "date"] = date.strftime("%Y%m%d") records.insert(0, "date", date.strftime("%Y%m%d")) return records @@ -300,8 +313,15 @@ def futures_spot_price_previous(date: str = "20240430") -> pd.DataFrame: values = main[main[4].str.endswith("%")] values.columns = header # Basis - basis = pd.concat(content[2:-1]) + # 对于没有数据的天,xml文件中没有数据,所以content[2:-1]可能为空 + if len(content[2:-1]) > 0: + basis = pd.concat(content[2:-1]) + else: + basis = pd.DataFrame(columns=["主力合约基差", "主力合约基差(%)"]) + basis.columns = ["主力合约基差", "主力合约基差(%)"] + # 20241125(jasonudu):因为部分日期,存在多个品种的现货价格,比如20151125的白糖、豆粕、豆油等,如果用商品名来merge,会出现重复列名,所以改用index来merge + # basis["商品"] = values["商品"].tolist() basis.index = values.index basis = pd.merge( values[["商品", "现货价格", "主力合约代码", "主力合约价格"]], @@ -338,12 +358,12 @@ def futures_spot_price_previous(date: str = "20240430") -> pd.DataFrame: if __name__ == "__main__": futures_spot_price_daily_df = futures_spot_price_daily( - start_day="20241028", end_day="20241128", vars_list=["CU", "RB"] + start_day="20240415", end_day="20240418", vars_list=["CU", "RB"] ) print(futures_spot_price_daily_df) - futures_spot_price_df = futures_spot_price(date="20241128") + futures_spot_price_df = futures_spot_price(date="20240430") print(futures_spot_price_df) - futures_spot_price_previous_df = futures_spot_price_previous(date="20241128") + futures_spot_price_previous_df = futures_spot_price_previous(date="20240430") print(futures_spot_price_previous_df) diff --git a/akshare/stock_feature/stock_gdfx_em.py b/akshare/stock_feature/stock_gdfx_em.py index a22da91e320..9171de59311 100644 --- a/akshare/stock_feature/stock_gdfx_em.py +++ b/akshare/stock_feature/stock_gdfx_em.py @@ -5,13 +5,14 @@ Desc: 东方财富网-数据中心-股东分析 https://data.eastmoney.com/gdfx/ """ + import pandas as pd import requests from tqdm import tqdm def stock_gdfx_free_holding_statistics_em( - date: str = "20210630", + date: str = "20210630", ) -> pd.DataFrame: """ 东方财富网-数据中心-股东分析-股东持股统计-十大流通股东 @@ -83,15 +84,33 @@ def stock_gdfx_free_holding_statistics_em( ] ] big_df["统计次数"] = pd.to_numeric(big_df["统计次数"]) - big_df["公告日后涨幅统计-10个交易日-平均涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-10个交易日-平均涨幅"]) - big_df["公告日后涨幅统计-10个交易日-最大涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-10个交易日-最大涨幅"]) - big_df["公告日后涨幅统计-10个交易日-最小涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-10个交易日-最小涨幅"]) - big_df["公告日后涨幅统计-30个交易日-平均涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-30个交易日-平均涨幅"]) - big_df["公告日后涨幅统计-30个交易日-最大涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-30个交易日-最大涨幅"]) - big_df["公告日后涨幅统计-30个交易日-最小涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-30个交易日-最小涨幅"]) - big_df["公告日后涨幅统计-60个交易日-平均涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-60个交易日-平均涨幅"]) - big_df["公告日后涨幅统计-60个交易日-最大涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-60个交易日-最大涨幅"]) - big_df["公告日后涨幅统计-60个交易日-最小涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-60个交易日-最小涨幅"]) + big_df["公告日后涨幅统计-10个交易日-平均涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-10个交易日-平均涨幅"] + ) + big_df["公告日后涨幅统计-10个交易日-最大涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-10个交易日-最大涨幅"] + ) + big_df["公告日后涨幅统计-10个交易日-最小涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-10个交易日-最小涨幅"] + ) + big_df["公告日后涨幅统计-30个交易日-平均涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-30个交易日-平均涨幅"] + ) + big_df["公告日后涨幅统计-30个交易日-最大涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-30个交易日-最大涨幅"] + ) + big_df["公告日后涨幅统计-30个交易日-最小涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-30个交易日-最小涨幅"] + ) + big_df["公告日后涨幅统计-60个交易日-平均涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-60个交易日-平均涨幅"] + ) + big_df["公告日后涨幅统计-60个交易日-最大涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-60个交易日-最大涨幅"] + ) + big_df["公告日后涨幅统计-60个交易日-最小涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-60个交易日-最小涨幅"] + ) return big_df @@ -167,15 +186,33 @@ def stock_gdfx_holding_statistics_em(date: str = "20210930") -> pd.DataFrame: ] ] big_df["统计次数"] = pd.to_numeric(big_df["统计次数"]) - big_df["公告日后涨幅统计-10个交易日-平均涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-10个交易日-平均涨幅"]) - big_df["公告日后涨幅统计-10个交易日-最大涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-10个交易日-最大涨幅"]) - big_df["公告日后涨幅统计-10个交易日-最小涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-10个交易日-最小涨幅"]) - big_df["公告日后涨幅统计-30个交易日-平均涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-30个交易日-平均涨幅"]) - big_df["公告日后涨幅统计-30个交易日-最大涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-30个交易日-最大涨幅"]) - big_df["公告日后涨幅统计-30个交易日-最小涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-30个交易日-最小涨幅"]) - big_df["公告日后涨幅统计-60个交易日-平均涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-60个交易日-平均涨幅"]) - big_df["公告日后涨幅统计-60个交易日-最大涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-60个交易日-最大涨幅"]) - big_df["公告日后涨幅统计-60个交易日-最小涨幅"] = pd.to_numeric(big_df["公告日后涨幅统计-60个交易日-最小涨幅"]) + big_df["公告日后涨幅统计-10个交易日-平均涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-10个交易日-平均涨幅"] + ) + big_df["公告日后涨幅统计-10个交易日-最大涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-10个交易日-最大涨幅"] + ) + big_df["公告日后涨幅统计-10个交易日-最小涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-10个交易日-最小涨幅"] + ) + big_df["公告日后涨幅统计-30个交易日-平均涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-30个交易日-平均涨幅"] + ) + big_df["公告日后涨幅统计-30个交易日-最大涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-30个交易日-最大涨幅"] + ) + big_df["公告日后涨幅统计-30个交易日-最小涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-30个交易日-最小涨幅"] + ) + big_df["公告日后涨幅统计-60个交易日-平均涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-60个交易日-平均涨幅"] + ) + big_df["公告日后涨幅统计-60个交易日-最大涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-60个交易日-最大涨幅"] + ) + big_df["公告日后涨幅统计-60个交易日-最小涨幅"] = pd.to_numeric( + big_df["公告日后涨幅统计-60个交易日-最小涨幅"] + ) return big_df @@ -334,7 +371,7 @@ def stock_gdfx_holding_change_em(date: str = "20210930") -> pd.DataFrame: def stock_gdfx_free_top_10_em( - symbol: str = "sh688686", date: str = "20210630" + symbol: str = "sh688686", date: str = "20240930" ) -> pd.DataFrame: """ 东方财富网-个股-十大流通股东 @@ -384,14 +421,16 @@ def stock_gdfx_free_top_10_em( "变动比率", ] ] - temp_df["持股数"] = pd.to_numeric(temp_df["持股数"]) - temp_df["占总流通股本持股比例"] = pd.to_numeric(temp_df["占总流通股本持股比例"]) - temp_df["变动比率"] = pd.to_numeric(temp_df["变动比率"]) + temp_df["持股数"] = pd.to_numeric(temp_df["持股数"], errors="coerce") + temp_df["占总流通股本持股比例"] = pd.to_numeric( + temp_df["占总流通股本持股比例"], errors="coerce" + ) + temp_df["变动比率"] = pd.to_numeric(temp_df["变动比率"], errors="coerce") return temp_df def stock_gdfx_top_10_em( - symbol: str = "sh688686", date: str = "20210630" + symbol: str = "sh688686", date: str = "20210630" ) -> pd.DataFrame: """ 东方财富网-个股-十大股东 @@ -477,24 +516,27 @@ def stock_gdfx_free_holding_detail_em(date: str = "20210930") -> pd.DataFrame: big_df.reset_index(inplace=True) big_df["index"] = big_df.index + 1 - big_df.rename(columns={ - "index": "序号", - "HOLDER_NAME": "股东名称", - "HOLDER_TYPE": "股东类型", - "SHARES_TYPE": "股份类型", - "HOLDER_RANK": "股东排名", - "SECURITY_CODE": "股票代码", - "SECURITY_NAME_ABBR": "股票简称", - "HOLD_NUM": "期末持股-数量", - "FREE_HOLDNUM_RATIO": "期末持股-持股占流通股比", - "XZCHANGE": "期末持股-数量变化", - "CHANGE_RATIO": "期末持股-数量变化比例", - "HOLDNUM_CHANGE_NAME": "期末持股-持股变动", - "HOLDER_MARKET_CAP": "期末持股-流通市值", - "END_DATE": "报告期", - "UPDATE_DATE": "公告日", - "REPORT_DATE_NAME": "报告名称", - }, inplace=True) + big_df.rename( + columns={ + "index": "序号", + "HOLDER_NAME": "股东名称", + "HOLDER_TYPE": "股东类型", + "SHARES_TYPE": "股份类型", + "HOLDER_RANK": "股东排名", + "SECURITY_CODE": "股票代码", + "SECURITY_NAME_ABBR": "股票简称", + "HOLD_NUM": "期末持股-数量", + "FREE_HOLDNUM_RATIO": "期末持股-持股占流通股比", + "XZCHANGE": "期末持股-数量变化", + "CHANGE_RATIO": "期末持股-数量变化比例", + "HOLDNUM_CHANGE_NAME": "期末持股-持股变动", + "HOLDER_MARKET_CAP": "期末持股-流通市值", + "END_DATE": "报告期", + "UPDATE_DATE": "公告日", + "REPORT_DATE_NAME": "报告名称", + }, + inplace=True, + ) big_df = big_df[ [ @@ -515,13 +557,21 @@ def stock_gdfx_free_holding_detail_em(date: str = "20210930") -> pd.DataFrame: big_df["报告期"] = pd.to_datetime(big_df["报告期"], errors="coerce").dt.date big_df["公告日"] = pd.to_datetime(big_df["公告日"], errors="coerce").dt.date big_df["期末持股-数量"] = pd.to_numeric(big_df["期末持股-数量"], errors="coerce") - big_df["期末持股-数量变化"] = pd.to_numeric(big_df["期末持股-数量变化"], errors="coerce") - big_df["期末持股-数量变化比例"] = pd.to_numeric(big_df["期末持股-数量变化比例"], errors="coerce") - big_df["期末持股-流通市值"] = pd.to_numeric(big_df["期末持股-流通市值"], errors="coerce") + big_df["期末持股-数量变化"] = pd.to_numeric( + big_df["期末持股-数量变化"], errors="coerce" + ) + big_df["期末持股-数量变化比例"] = pd.to_numeric( + big_df["期末持股-数量变化比例"], errors="coerce" + ) + big_df["期末持股-流通市值"] = pd.to_numeric( + big_df["期末持股-流通市值"], errors="coerce" + ) return big_df -def stock_gdfx_holding_detail_em(date: str = "20230331", indicator: str = "个人", symbol: str = "新进") -> pd.DataFrame: +def stock_gdfx_holding_detail_em( + date: str = "20230331", indicator: str = "个人", symbol: str = "新进" +) -> pd.DataFrame: """ 东方财富网-数据中心-股东分析-股东持股明细-十大股东 https://data.eastmoney.com/gdfx/HoldingAnalyse.html @@ -559,22 +609,24 @@ def stock_gdfx_holding_detail_em(date: str = "20230331", indicator: str = "个 big_df.reset_index(inplace=True) big_df["index"] = big_df.index + 1 - big_df.rename(columns={ - "index": "序号", - "HOLDER_NAME": "股东名称", - "HOLDER_NEWTYPE": "股东类型", - "RANK": "股东排名", - "SECURITY_CODE": "股票代码", - "SECURITY_NAME_ABBR": "股票简称", - "END_DATE": "报告期", - "HOLD_NUM": "期末持股-数量", - "HOLD_NUM_CHANGE": "期末持股-数量变化", - "HOLD_RATIO_CHANGE": "期末持股-数量变化比例", - "HOLDNUM_CHANGE_NAME": "期末持股-持股变动", - "HOLDER_MARKET_CAP": "期末持股-流通市值", - "NOTICE_DATE": "公告日", - - }, inplace=True) + big_df.rename( + columns={ + "index": "序号", + "HOLDER_NAME": "股东名称", + "HOLDER_NEWTYPE": "股东类型", + "RANK": "股东排名", + "SECURITY_CODE": "股票代码", + "SECURITY_NAME_ABBR": "股票简称", + "END_DATE": "报告期", + "HOLD_NUM": "期末持股-数量", + "HOLD_NUM_CHANGE": "期末持股-数量变化", + "HOLD_RATIO_CHANGE": "期末持股-数量变化比例", + "HOLDNUM_CHANGE_NAME": "期末持股-持股变动", + "HOLDER_MARKET_CAP": "期末持股-流通市值", + "NOTICE_DATE": "公告日", + }, + inplace=True, + ) big_df = big_df[ [ @@ -596,9 +648,15 @@ def stock_gdfx_holding_detail_em(date: str = "20230331", indicator: str = "个 big_df["报告期"] = pd.to_datetime(big_df["报告期"], errors="coerce").dt.date big_df["公告日"] = pd.to_datetime(big_df["公告日"], errors="coerce").dt.date big_df["期末持股-数量"] = pd.to_numeric(big_df["期末持股-数量"], errors="coerce") - big_df["期末持股-数量变化"] = pd.to_numeric(big_df["期末持股-数量变化"], errors="coerce") - big_df["期末持股-数量变化比例"] = pd.to_numeric(big_df["期末持股-数量变化比例"], errors="coerce") - big_df["期末持股-流通市值"] = pd.to_numeric(big_df["期末持股-流通市值"], errors="coerce") + big_df["期末持股-数量变化"] = pd.to_numeric( + big_df["期末持股-数量变化"], errors="coerce" + ) + big_df["期末持股-数量变化比例"] = pd.to_numeric( + big_df["期末持股-数量变化比例"], errors="coerce" + ) + big_df["期末持股-流通市值"] = pd.to_numeric( + big_df["期末持股-流通市值"], errors="coerce" + ) big_df["股东排名"] = pd.to_numeric(big_df["股东排名"], errors="coerce") return big_df @@ -637,23 +695,26 @@ def stock_gdfx_free_holding_analyse_em(date: str = "20230930") -> pd.DataFrame: big_df.reset_index(inplace=True) big_df["index"] = big_df.index + 1 - big_df.rename(columns={ - "index": "序号", - "HOLDER_NAME": "股东名称", - "HOLDER_TYPE": "股东类型", - "SECURITY_CODE": "股票代码", - "SECURITY_NAME_ABBR": "股票简称", - "END_DATE": "报告期", - "HOLD_NUM": "期末持股-数量", - "XZCHANGE": "期末持股-数量变化", - "HOLD_RATIO_CHANGE": "期末持股-数量变化比例", - "HOLDNUM_CHANGE_NAME": "期末持股-持股变动", - "HOLDER_MARKET_CAP": "期末持股-流通市值", - "UPDATE_DATE": "公告日", - "D10_ADJCHRATE": "公告日后涨跌幅-10个交易日", - "D30_ADJCHRATE": "公告日后涨跌幅-30个交易日", - "D60_ADJCHRATE": "公告日后涨跌幅-60个交易日", - }, inplace=True) + big_df.rename( + columns={ + "index": "序号", + "HOLDER_NAME": "股东名称", + "HOLDER_TYPE": "股东类型", + "SECURITY_CODE": "股票代码", + "SECURITY_NAME_ABBR": "股票简称", + "END_DATE": "报告期", + "HOLD_NUM": "期末持股-数量", + "XZCHANGE": "期末持股-数量变化", + "HOLD_RATIO_CHANGE": "期末持股-数量变化比例", + "HOLDNUM_CHANGE_NAME": "期末持股-持股变动", + "HOLDER_MARKET_CAP": "期末持股-流通市值", + "UPDATE_DATE": "公告日", + "D10_ADJCHRATE": "公告日后涨跌幅-10个交易日", + "D30_ADJCHRATE": "公告日后涨跌幅-30个交易日", + "D60_ADJCHRATE": "公告日后涨跌幅-60个交易日", + }, + inplace=True, + ) big_df = big_df[ [ "序号", @@ -676,12 +737,24 @@ def stock_gdfx_free_holding_analyse_em(date: str = "20230930") -> pd.DataFrame: big_df["报告期"] = pd.to_datetime(big_df["报告期"], errors="coerce").dt.date big_df["公告日"] = pd.to_datetime(big_df["公告日"], errors="coerce").dt.date big_df["期末持股-数量"] = pd.to_numeric(big_df["期末持股-数量"], errors="coerce") - big_df["期末持股-数量变化"] = pd.to_numeric(big_df["期末持股-数量变化"], errors="coerce") - big_df["期末持股-数量变化比例"] = pd.to_numeric(big_df["期末持股-数量变化比例"], errors="coerce") - big_df["期末持股-流通市值"] = pd.to_numeric(big_df["期末持股-流通市值"], errors="coerce") - big_df["公告日后涨跌幅-10个交易日"] = pd.to_numeric(big_df["公告日后涨跌幅-10个交易日"], errors="coerce") - big_df["公告日后涨跌幅-30个交易日"] = pd.to_numeric(big_df["公告日后涨跌幅-30个交易日"], errors="coerce") - big_df["公告日后涨跌幅-60个交易日"] = pd.to_numeric(big_df["公告日后涨跌幅-60个交易日"], errors="coerce") + big_df["期末持股-数量变化"] = pd.to_numeric( + big_df["期末持股-数量变化"], errors="coerce" + ) + big_df["期末持股-数量变化比例"] = pd.to_numeric( + big_df["期末持股-数量变化比例"], errors="coerce" + ) + big_df["期末持股-流通市值"] = pd.to_numeric( + big_df["期末持股-流通市值"], errors="coerce" + ) + big_df["公告日后涨跌幅-10个交易日"] = pd.to_numeric( + big_df["公告日后涨跌幅-10个交易日"], errors="coerce" + ) + big_df["公告日后涨跌幅-30个交易日"] = pd.to_numeric( + big_df["公告日后涨跌幅-30个交易日"], errors="coerce" + ) + big_df["公告日后涨跌幅-60个交易日"] = pd.to_numeric( + big_df["公告日后涨跌幅-60个交易日"], errors="coerce" + ) return big_df @@ -718,7 +791,7 @@ def stock_gdfx_holding_analyse_em(date: str = "20230331") -> pd.DataFrame: big_df = pd.concat([big_df, temp_df], ignore_index=True) big_df.reset_index(inplace=True) - big_df['index'] = big_df['index'] + 1 + big_df["index"] = big_df["index"] + 1 big_df.rename( columns={ "index": "序号", @@ -766,12 +839,24 @@ def stock_gdfx_holding_analyse_em(date: str = "20230331") -> pd.DataFrame: big_df["公告日"] = pd.to_datetime(big_df["公告日"]).dt.date big_df["报告期"] = pd.to_datetime(big_df["报告期"]).dt.date big_df["期末持股-数量"] = pd.to_numeric(big_df["期末持股-数量"], errors="coerce") - big_df["期末持股-数量变化"] = pd.to_numeric(big_df["期末持股-数量变化"], errors="coerce") - big_df["期末持股-数量变化比例"] = pd.to_numeric(big_df["期末持股-数量变化比例"], errors="coerce") - big_df["期末持股-流通市值"] = pd.to_numeric(big_df["期末持股-流通市值"], errors="coerce") - big_df["公告日后涨跌幅-10个交易日"] = pd.to_numeric(big_df["公告日后涨跌幅-10个交易日"], errors="coerce") - big_df["公告日后涨跌幅-30个交易日"] = pd.to_numeric(big_df["公告日后涨跌幅-30个交易日"], errors="coerce") - big_df["公告日后涨跌幅-60个交易日"] = pd.to_numeric(big_df["公告日后涨跌幅-60个交易日"], errors="coerce") + big_df["期末持股-数量变化"] = pd.to_numeric( + big_df["期末持股-数量变化"], errors="coerce" + ) + big_df["期末持股-数量变化比例"] = pd.to_numeric( + big_df["期末持股-数量变化比例"], errors="coerce" + ) + big_df["期末持股-流通市值"] = pd.to_numeric( + big_df["期末持股-流通市值"], errors="coerce" + ) + big_df["公告日后涨跌幅-10个交易日"] = pd.to_numeric( + big_df["公告日后涨跌幅-10个交易日"], errors="coerce" + ) + big_df["公告日后涨跌幅-30个交易日"] = pd.to_numeric( + big_df["公告日后涨跌幅-30个交易日"], errors="coerce" + ) + big_df["公告日后涨跌幅-60个交易日"] = pd.to_numeric( + big_df["公告日后涨跌幅-60个交易日"], errors="coerce" + ) return big_df diff --git a/akshare/stock_feature/stock_jgdy_em.py b/akshare/stock_feature/stock_jgdy_em.py index 0ab63707b69..00c2a981819 100644 --- a/akshare/stock_feature/stock_jgdy_em.py +++ b/akshare/stock_feature/stock_jgdy_em.py @@ -7,6 +7,7 @@ 东方财富网-数据中心-特色数据-机构调研-机构调研统计: http://data.eastmoney.com/jgdy/tj.html 东方财富网-数据中心-特色数据-机构调研-机构调研详细: http://data.eastmoney.com/jgdy/xx.html """ + import pandas as pd import requests from tqdm import tqdm @@ -23,26 +24,26 @@ def stock_jgdy_tj_em(date: str = "20220101") -> pd.DataFrame: """ url = "http://datacenter-web.eastmoney.com/api/data/v1/get" params = { - 'sortColumns': 'NOTICE_DATE,SUM,RECEIVE_START_DATE,SECURITY_CODE', - 'sortTypes': '-1,-1,-1,1', - 'pageSize': '500', - 'pageNumber': '1', - 'reportName': 'RPT_ORG_SURVEYNEW', - 'columns': 'ALL', - 'quoteColumns': 'f2~01~SECURITY_CODE~CLOSE_PRICE,f3~01~SECURITY_CODE~CHANGE_RATE', - 'source': 'WEB', - 'client': 'WEB', - 'filter': f"""(NUMBERNEW="1")(IS_SOURCE="1")(RECEIVE_START_DATE>'{'-'.join([date[:4], date[4:6], date[6:]])}')""" + "sortColumns": "NOTICE_DATE,SUM,RECEIVE_START_DATE,SECURITY_CODE", + "sortTypes": "-1,-1,-1,1", + "pageSize": "500", + "pageNumber": "1", + "reportName": "RPT_ORG_SURVEYNEW", + "columns": "ALL", + "quoteColumns": "f2~01~SECURITY_CODE~CLOSE_PRICE,f3~01~SECURITY_CODE~CHANGE_RATE", + "source": "WEB", + "client": "WEB", + "filter": f"""(NUMBERNEW="1")(IS_SOURCE="1")(RECEIVE_START_DATE>'{'-'.join([date[:4], date[4:6], date[6:]])}')""", } r = requests.get(url, params=params) data_json = r.json() - total_page = data_json['result']['pages'] + total_page = data_json["result"]["pages"] big_df = pd.DataFrame() - for page in tqdm(range(1, total_page+1), leave=False): + for page in tqdm(range(1, total_page + 1), leave=False): params.update({"pageNumber": page}) r = requests.get(url, params=params) data_json = r.json() - temp_df = pd.DataFrame(data_json['result']['data']) + temp_df = pd.DataFrame(data_json["result"]["data"]) big_df = pd.concat([big_df, temp_df]) big_df.reset_index(inplace=True) big_df["index"] = list(range(1, len(big_df) + 1)) @@ -96,45 +97,47 @@ def stock_jgdy_tj_em(date: str = "20220101") -> pd.DataFrame: "公告日期", ] ] - big_df['最新价'] = pd.to_numeric(big_df['最新价'], errors="coerce") - big_df['涨跌幅'] = pd.to_numeric(big_df['涨跌幅'], errors="coerce") - big_df['接待机构数量'] = pd.to_numeric(big_df['接待机构数量'], errors="coerce") - big_df['接待日期'] = pd.to_datetime(big_df['接待日期']).dt.date - big_df['公告日期'] = pd.to_datetime(big_df['公告日期']).dt.date + big_df["最新价"] = pd.to_numeric(big_df["最新价"], errors="coerce") + big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"], errors="coerce") + big_df["接待机构数量"] = pd.to_numeric(big_df["接待机构数量"], errors="coerce") + big_df["接待日期"] = pd.to_datetime(big_df["接待日期"]).dt.date + big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date return big_df -def stock_jgdy_detail_em(date: str = "20220101") -> pd.DataFrame: +def stock_jgdy_detail_em(date: str = "20241211") -> pd.DataFrame: """ 东方财富网-数据中心-特色数据-机构调研-机构调研详细 - http://data.eastmoney.com/jgdy/xx.html + https://data.eastmoney.com/jgdy/xx.html :param date: 开始时间 :type date: str :return: 机构调研详细 :rtype: pandas.DataFrame """ - url = "http://datacenter-web.eastmoney.com/api/data/v1/get" + url = "https://datacenter-web.eastmoney.com/api/data/v1/get" params = { - 'sortColumns': 'NOTICE_DATE,RECEIVE_START_DATE,SECURITY_CODE,NUMBERNEW', - 'sortTypes': '-1,-1,1,-1', - 'pageSize': '50000', - 'pageNumber': '1', - 'reportName': 'RPT_ORG_SURVEY', - 'columns': 'SECUCODE,SECURITY_CODE,SECURITY_NAME_ABBR,NOTICE_DATE,RECEIVE_START_DATE,RECEIVE_OBJECT,RECEIVE_PLACE,RECEIVE_WAY_EXPLAIN,INVESTIGATORS,RECEPTIONIST,ORG_TYPE', - 'quoteColumns': 'f2~01~SECURITY_CODE~CLOSE_PRICE,f3~01~SECURITY_CODE~CHANGE_RATE', - 'source': 'WEB', - 'client': 'WEB', - 'filter': f"""(IS_SOURCE="1")(RECEIVE_START_DATE>'{'-'.join([date[:4], date[4:6], date[6:]])}')""" + "sortColumns": "NOTICE_DATE,RECEIVE_START_DATE,SECURITY_CODE,NUMBERNEW", + "sortTypes": "-1,-1,1,-1", + "pageSize": "50", + "pageNumber": "1", + "reportName": "RPT_ORG_SURVEY", + "columns": "SECUCODE,SECURITY_CODE,SECURITY_NAME_ABBR,NOTICE_DATE,RECEIVE_START_DATE," + "RECEIVE_OBJECT,RECEIVE_PLACE,RECEIVE_WAY_EXPLAIN,INVESTIGATORS,RECEPTIONIST,ORG_TYPE", + "quoteColumns": "f2~01~SECURITY_CODE~CLOSE_PRICE,f3~01~SECURITY_CODE~CHANGE_RATE", + "quoteType": "0", + "source": "WEB", + "client": "WEB", + "filter": f"""(IS_SOURCE="1")(RECEIVE_START_DATE>'{'-'.join([date[:4], date[4:6], date[6:]])}')""", } r = requests.get(url, params=params) data_json = r.json() - total_page = data_json['result']['pages'] + total_page = data_json["result"]["pages"] big_df = pd.DataFrame() - for page in tqdm(range(1, total_page+1), leave=False): + for page in tqdm(range(1, total_page + 1), leave=False): params.update({"pageNumber": page}) r = requests.get(url, params=params) data_json = r.json() - temp_df = pd.DataFrame(data_json['result']['data']) + temp_df = pd.DataFrame(data_json["result"]["data"]) big_df = pd.concat([big_df, temp_df]) big_df.reset_index(inplace=True) big_df["index"] = list(range(1, len(big_df) + 1)) @@ -171,10 +174,10 @@ def stock_jgdy_detail_em(date: str = "20220101") -> pd.DataFrame: "公告日期", ] ] - big_df['最新价'] = pd.to_numeric(big_df['最新价'], errors="coerce") - big_df['涨跌幅'] = pd.to_numeric(big_df['涨跌幅'], errors="coerce") - big_df['调研日期'] = pd.to_datetime(big_df['调研日期']).dt.date - big_df['公告日期'] = pd.to_datetime(big_df['公告日期']).dt.date + big_df["最新价"] = pd.to_numeric(big_df["最新价"], errors="coerce") + big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"], errors="coerce") + big_df["调研日期"] = pd.to_datetime(big_df["调研日期"], errors="coerce").dt.date + big_df["公告日期"] = pd.to_datetime(big_df["公告日期"], errors="coerce").dt.date return big_df diff --git a/docs/changelog.md b/docs/changelog.md index 1f53c31d038..de7b8856756 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -80,6 +80,11 @@ ## 更新说明详情 +1.15.45 fix: fix stock_jgdy_detail_em interface + + 1. 修复 stock_jgdy_detail_em 接口 + 2. 修复 stock_gdfx_free_top_10_em 接口 + 1.15.44 fix: fix index_detail_hist_adjust_cni interface 1. 修复 index_detail_hist_adjust_cni 接口 @@ -4843,6 +4848,8 @@ ## 版本更新说明 +1.15.45 fix: fix stock_jgdy_detail_em interface + 1.15.44 fix: fix index_detail_hist_adjust_cni interface 1.15.43 fix: fix macro_china_urban_unemployment interface diff --git a/docs/data/stock/stock.md b/docs/data/stock/stock.md index 5e817cd6392..57edc37df67 100644 --- a/docs/data/stock/stock.md +++ b/docs/data/stock/stock.md @@ -4500,7 +4500,7 @@ print(stock_jgdy_tj_em_df) | 名称 | 类型 | 描述 | |------|-----|--------------------------| -| date | str | date="20180928"; 开始查询的时间 | +| date | str | date="20241211"; 开始查询的时间 | 输出参数 @@ -4525,25 +4525,23 @@ print(stock_jgdy_tj_em_df) ```python import akshare as ak -stock_jgdy_detail_em_df = ak.stock_jgdy_detail_em(date="20210915") +stock_jgdy_detail_em_df = ak.stock_jgdy_detail_em(date="20241211") print(stock_jgdy_detail_em_df) ``` 数据示例 ``` - 序号 代码 名称 ... 接待地点 调研日期 公告日期 -0 1 000615 奥园美谷 ... 公司会议室 2021-09-16 2021-09-17 -1 2 000615 奥园美谷 ... 公司会议室 2021-09-16 2021-09-17 -2 3 000615 奥园美谷 ... 公司会议室 2021-09-16 2021-09-17 -3 4 000615 奥园美谷 ... 公司会议室 2021-09-16 2021-09-17 -4 5 000615 奥园美谷 ... 公司会议室 2021-09-16 2021-09-17 -.. ... ... ... ... ... ... ... -619 620 300677 英科医疗 ... 江西省九江市彭泽县彭湖湾工业园垅太路东侧江西英科医疗有限公司 2021-09-16 2021-09-16 -620 621 300718 长盛轴承 ... 浙江长盛滑动轴承股份有限公司 2021-09-16 2021-09-16 -621 622 300718 长盛轴承 ... 浙江长盛滑动轴承股份有限公司 2021-09-16 2021-09-16 -622 623 300718 长盛轴承 ... 浙江长盛滑动轴承股份有限公司 2021-09-16 2021-09-16 -623 624 300718 长盛轴承 ... 浙江长盛滑动轴承股份有限公司 2021-09-16 2021-09-16 + 序号 代码 名称 ... 接待地点 调研日期 公告日期 +0 1 002024 ST易购 ... 武汉中南店 2024-12-12 2024-12-12 +1 2 002024 ST易购 ... 武汉中南店 2024-12-12 2024-12-12 +2 3 002521 齐峰新材 ... 公司接待室 2024-12-12 2024-12-12 +3 4 002521 齐峰新材 ... 公司接待室 2024-12-12 2024-12-12 +4 5 301390 经纬股份 ... 公司 2024-12-12 2024-12-12 +5 6 600030 中信证券 ... 北京中信证券大厦 2024-12-12 2024-12-12 +6 7 600030 中信证券 ... 北京中信证券大厦 2024-12-12 2024-12-12 +7 8 688528 秦川物联 ... 上证路演中心 2024-12-12 2024-12-12 +[8 rows x 13 columns] ``` ### 主营介绍-同花顺 @@ -11795,7 +11793,7 @@ print(stock_history_dividend_df) | 名称 | 类型 | 描述 | |--------|-----|-------------------------------| | symbol | str | symbol="sh688686"; 带市场标识的股票代码 | -| date | str | date="20210630"; 财报发布季度最后日 | +| date | str | date="20240930"; 财报发布季度最后日 | 输出参数 @@ -11815,24 +11813,25 @@ print(stock_history_dividend_df) ```python import akshare as ak -stock_gdfx_free_top_10_em_df = ak.stock_gdfx_free_top_10_em(symbol="sh688686", date="20210630") +stock_gdfx_free_top_10_em_df = ak.stock_gdfx_free_top_10_em(symbol="sh688686", date="20240930") print(stock_gdfx_free_top_10_em_df) ``` 数据示例 ``` - 名次 股东名称 ... 增减 变动比率 -0 1 高华-汇丰-GOLDMAN,SACHS&CO.LLC ... 946997 54.311934 -1 2 铭基国际投资公司-MATTHEWS ASIA FUNDS(US) ... -358837 -15.460528 -2 3 MORGAN STANLEY & CO. INTERNATIONAL PLC. ... 70003 4.082755 -3 4 FMR 有限公司-富达新兴市场基金(交易所) ... 80100 9.086784 -4 5 摩根资产管理(新加坡)有限公司-摩根中国A股市场机会基金 ... 新进 NaN -5 6 UBS AG ... -400254 -45.037994 -6 7 中国工商银行股份有限公司-万家自主创新混合型证券投资基金 ... 新进 NaN -7 8 铭基国际投资公司-Matthews Asia Funds(SICAV) ... 6123 2.132424 -8 9 中信证券股份有限公司 ... 新进 NaN -9 10 泰康人寿保险有限责任公司-投连-多策略优选 ... 新进 NaN + 名次 股东名称 ... 增减 变动比率 +0 1 卢治临 ... 不变 NaN +1 2 卢盛林 ... 不变 NaN +2 3 许学亮 ... 不变 NaN +3 4 宁波千智创业投资合伙企业(有限合伙) ... 不变 NaN +4 5 香港中央结算有限公司 ... -1132820 -25.435429 +5 6 国信证券-招商银行-国信证券鼎信10号科创板战略配售集合资产管理计划 ... 不变 NaN +6 7 摩根资产管理(新加坡)有限公司-摩根中国A股市场机会基金 ... 不变 NaN +7 8 李茂波 ... 不变 NaN +8 9 招商银行股份有限公司-惠升惠泽灵活配置混合型发起式证券投资基金 ... 不变 NaN +9 10 MERRILL LYNCH INTERNATIONAL ... 新进 NaN +[10 rows x 8 columns] ``` #### 十大股东(个股) diff --git a/docs/introduction.md b/docs/introduction.md index 85e2a7ba594..8c0db62ced2 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -6,7 +6,7 @@ **风险提示**:[AKShare](https://github.com/akfamily/akshare) 开源财经数据接口库所采集的数据皆来自公开的数据源,不涉及任何个人隐私数据和非公开数据。 同时本项目提供的数据接口及相关数据仅用于学术研究,任何个人、机构及团体使用本项目的数据接口及相关数据请注意商业风险。 -1. 本文档更新时间:**2024-12-09**; +1. 本文档更新时间:**2024-12-12**; 2. 如有 [AKShare](https://github.com/akfamily/akshare) 库、文档及数据的相关问题,请在 [AKShare Issues](https://github.com/akfamily/akshare/issues) 中提 Issues; 3. 欢迎关注 **数据科学实战** 微信公众号;
4. **知识星球【数据科学实战】** 2024 全新改版,聚焦于量化投资内容,欢迎加入 **知识星球【数据科学实战】** 高质量社区,里面有丰富的视频课程、问答、文章、书籍及代码等内容: