diff --git a/akshare/__init__.py b/akshare/__init__.py index ccf46bac84c..1ebf0a17b5b 100644 --- a/akshare/__init__.py +++ b/akshare/__init__.py @@ -2571,9 +2571,10 @@ 1.11.55 fix: fix fund_portfolio_bond_hold_em interface 1.11.56 fix: fix stock_balance_sheet_by_report_delisted_em interface 1.11.57 fix: fix stock_zt_pool_em interface +1.11.58 fix: fix bond_china_close_return interface """ -__version__ = "1.11.57" +__version__ = "1.11.58" __author__ = "AKFamily" import sys diff --git a/akshare/bond/bond_china_money.py b/akshare/bond/bond_china_money.py index 567bc1f9916..c8b9785e793 100644 --- a/akshare/bond/bond_china_money.py +++ b/akshare/bond/bond_china_money.py @@ -1,13 +1,14 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- """ -Date: 2022/12/6 15:43 +Date: 2023/11/2 10:43 Desc: 收盘收益率曲线历史数据 https://www.chinamoney.com.cn/chinese/bkcurvclosedyhis/?bondType=CYCC000&reference=1 """ +from functools import lru_cache + import pandas as pd import requests -from functools import lru_cache @lru_cache() @@ -46,10 +47,10 @@ def bond_china_close_return_map() -> pd.DataFrame: def bond_china_close_return( - symbol: str = "国债", - period: str = "1", - start_date: str = "20221111", - end_date: str = "20221211", + symbol: str = "国债", + period: str = "1", + start_date: str = "20231101", + end_date: str = "20231101", ) -> pd.DataFrame: """ 收盘收益率曲线历史数据 @@ -102,8 +103,8 @@ def bond_china_close_return( "远期收益率", ] ] - temp_df['日期'] = pd.to_datetime(temp_df['日期']).dt.date - temp_df['期限'] = pd.to_numeric(temp_df['期限']) + temp_df['日期'] = pd.to_datetime(temp_df['日期'], errors='coerce').dt.date + 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') temp_df['远期收益率'] = pd.to_numeric(temp_df['远期收益率'], errors='coerce') @@ -112,9 +113,6 @@ def bond_china_close_return( if __name__ == "__main__": bond_china_close_return_df = bond_china_close_return( - symbol="国债", period="1", start_date="20221111", end_date="20221211" + symbol="国债", period="1", start_date="20231101", end_date="20231101" ) print(bond_china_close_return_df) - - bond_china_close_return_df = bond_china_close_return(symbol="政策性金融债(进出口行)", period="1", start_date="20221111", end_date="20221211") - print(bond_china_close_return_df) diff --git a/akshare/stock/stock_zh_a_sina.py b/akshare/stock/stock_zh_a_sina.py index eeb22bd2010..6b1559feb3f 100644 --- a/akshare/stock/stock_zh_a_sina.py +++ b/akshare/stock/stock_zh_a_sina.py @@ -188,6 +188,11 @@ def _fq_factor(method: str) -> pd.DataFrame: del data_df["prevclose"] except: pass + try: + del data_df["postVol"] + del data_df["postAmt"] + except: + pass data_df = data_df.astype("float") r = requests.get(zh_sina_a_stock_amount_url.format(symbol, symbol)) amount_data_json = demjson.decode( @@ -521,7 +526,7 @@ def stock_zh_a_minute( ) print(stock_zh_a_daily_hfq_factor_df) - stock_zh_a_daily_df = stock_zh_a_daily(symbol="sh601939") + stock_zh_a_daily_df = stock_zh_a_daily(symbol="sz300798", start_date="20200601", end_date="20231101", adjust="hfq") print(stock_zh_a_daily_df) stock_zh_a_cdr_daily_df = stock_zh_a_cdr_daily( diff --git a/docs/changelog.md b/docs/changelog.md index 8ecb55927e7..0a4483ff0e3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -68,6 +68,11 @@ ## 更新说明详情 +1.11.58 fix: fix bond_china_close_return interface + + 1. 修复 bond_china_close_return 接口 + 2. 修复 stock_zh_a_daily 接口 + 1.11.57 fix: fix stock_zt_pool_em interface 1. 修复 stock_zt_pool_em 接口 @@ -3070,6 +3075,8 @@ ## 版本更新说明 +1.11.58 fix: fix bond_china_close_return interface + 1.11.57 fix: fix stock_zt_pool_em interface 1.11.56 fix: fix stock_balance_sheet_by_report_delisted_em interface diff --git a/docs/data/bond/bond.md b/docs/data/bond/bond.md index 2c851970a80..d44dc8d60b5 100644 --- a/docs/data/bond/bond.md +++ b/docs/data/bond/bond.md @@ -1787,8 +1787,8 @@ print(bond_futures_deliverable_coupons_df) |------------|-----|--------------------------------------------------------------------------| | symbol | str | symbol="政策性金融债(进出口行)"; 通过网页查询或调用 **ak.bond_china_close_return_map()** 获取 | | period | str | period: str = "1"; 期限间隔, choice of {'0.1', '0.5', '1'} | -| start_date | str | start_date="20200830"; 结束日期, 结束日期和开始日期不要超过 1 个月 | -| end_date | str | end_date="20200930"; 结束日期, 结束日期和开始日期不要超过 1 个月 | +| start_date | str | start_date="20231101"; 结束日期, 结束日期和开始日期不要超过 1 个月 | +| end_date | str | end_date="20231101"; 结束日期, 结束日期和开始日期不要超过 1 个月 | 输出参数 @@ -1805,29 +1805,29 @@ print(bond_futures_deliverable_coupons_df) ```python import akshare as ak -bond_china_close_return_df = ak.bond_china_close_return(symbol="政策性金融债(进出口行)", period="1", start_date="20220104", end_date="20220104") +bond_china_close_return_df = ak.bond_china_close_return(symbol="国债", period="1", start_date="20231101", end_date="20231101") print(bond_china_close_return_df) ``` 数据示例 ``` - 日期 期限 到期收益率 即期收益率 远期收益率 -0 2022-01-04 0.083 2.1613 2.1613 NaN -1 2022-01-04 0.250 2.1026 2.1026 NaN -2 2022-01-04 0.500 2.3043 2.3043 NaN -3 2022-01-04 0.750 2.2995 2.2995 NaN -4 2022-01-04 1.000 2.3522 2.3522 2.6613 -5 2022-01-04 2.000 2.5047 2.5066 2.8486 -6 2022-01-04 3.000 2.6162 2.6205 3.0910 -7 2022-01-04 4.000 2.7298 2.7379 3.3340 -8 2022-01-04 5.000 2.8434 2.8569 3.5295 -9 2022-01-04 6.000 2.9489 2.9687 3.7663 -10 2022-01-04 7.000 3.0543 3.0822 3.3544 -11 2022-01-04 8.000 3.0876 3.1162 3.4313 -12 2022-01-04 9.000 3.1209 3.1512 3.5100 -13 2022-01-04 10.000 3.1542 3.1870 3.7787 -14 2022-01-04 11.000 3.2018 3.2407 3.8982 + 日期 期限 到期收益率 即期收益率 远期收益率 +0 2023-11-01 0.083 1.7031 1.7031 NaN +1 2023-11-01 0.250 2.3102 2.3102 NaN +2 2023-11-01 0.500 2.3825 2.3825 NaN +3 2023-11-01 0.750 2.2547 2.2547 NaN +4 2023-11-01 1.000 2.2452 2.2452 2.5188 +5 2023-11-01 2.000 2.3803 2.3819 2.5649 +6 2023-11-01 3.000 2.4403 2.4429 2.6295 +7 2023-11-01 4.000 2.4858 2.4895 2.7256 +8 2023-11-01 5.000 2.5313 2.5367 3.0216 +9 2023-11-01 6.000 2.6076 2.6174 3.1898 +10 2023-11-01 7.000 2.6838 2.6989 2.6956 +11 2023-11-01 8.000 2.6851 2.6985 2.6986 +12 2023-11-01 9.000 2.6865 2.6985 2.7016 +13 2023-11-01 10.000 2.6878 2.6988 2.9891 +14 2023-11-01 11.000 2.7115 2.7252 3.0458 ``` ### 中美国债收益率 diff --git a/docs/introduction.md b/docs/introduction.md index 4fc7f7cd629..52635b5fdf2 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -6,7 +6,7 @@ **风险提示:[AKShare](https://github.com/akfamily/akshare) 开源财经数据接口库所采集的数据皆来自公开的数据源,不涉及任何个人隐私数据和非公开数据。 同时本项目提供的数据接口及相关数据仅用于学术研究,任何个人、机构及团体使用本项目的数据接口及相关数据请注意商业风险。** -1. 本文档更新时间:**2023-10-31**; +1. 本文档更新时间:**2023-11-02**; 2. 如有 [AKShare](https://github.com/akfamily/akshare) 库、文档及数据的相关问题,请在 [AKShare Issues](https://github.com/akfamily/akshare/issues) 中提 Issues; 3. 欢迎关注 **数据科学实战** 微信公众号:
; 4. 如果您的问题未能在文档中找到答案,您也可以加入 **AKShare-VIP QQ 群**: 为了提高问答质量,此群为收费群(一杯咖啡钱即可入群,赠送[《AKShare-初阶-使用教学》](https://zmj.xet.tech/s/wck86)视频课),可以添加 **AKShare-小助手** QQ:1254836886,由小助手邀请入群! ![](https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/akshare/readme/qrcode/qr_code_1254836886.jpg)