diff --git a/akshare/__init__.py b/akshare/__init__.py index 6d154e355f8..d575f93fb1a 100644 --- a/akshare/__init__.py +++ b/akshare/__init__.py @@ -1096,7 +1096,7 @@ 0.6.68: add: add macro_china_retail_price_index interface 0.6.69: fix: fix box_office_spot interface 0.6.70: fix: fix bond_investing_global interface -0.6.71: fix: fix futures_nh_return_index interface +0.6.71: fix: fix futures_return_index_nh interface 0.6.72: fix: fix get_receipt interface 0.6.73: add: add news_cctv interface 0.6.74: fix: fix macro and acm interface @@ -1672,7 +1672,7 @@ 1.2.47 fix: fix covid_19_dxy interface 1.2.48 fix: fix covid_19_dxy interface 1.2.49 fix: fix rate_interbank interface -1.2.50 fix: fix futures_nh_price_index interface +1.2.50 fix: fix futures_price_index_nh interface 1.2.51 add: add futures_hq_subscribe_exchange_symbol interface 1.2.52 fix: fix futures_foreign_commodity_realtime interface 1.2.53 add: add get_ine_daily interface @@ -1967,9 +1967,10 @@ 1.5.45 add: add stock_hot_deal_xq interface 1.5.46 fix: fix stock_yzxdr_em interface 1.5.47 fix: fix macro_china_lpr interface +1.5.48 fix: fix futures_return_index_nh interface """ -__version__ = "1.5.47" +__version__ = "1.5.48" __author__ = "AKFamily" import sys @@ -1999,7 +2000,7 @@ 南华期货-品种指数涨跌 南华期货-相关系数矩阵 """ -from akshare.futures_derivative.other_index_nh import ( +from akshare.futures_derivative.futures_other_index_nh import ( futures_correlation_nh, futures_board_index_nh, futures_variety_index_nh, @@ -3531,12 +3532,12 @@ """ 南华期货-南华指数 """ -from akshare.futures_derivative.nh_index_return import futures_nh_return_index -from akshare.futures_derivative.nh_index_price import ( - futures_nh_price_index, - futures_nh_index_symbol_table, +from akshare.futures_derivative.futures_index_return_nh import futures_return_index_nh +from akshare.futures_derivative.futures_index_price_nh import ( + futures_price_index_nh, + futures_index_symbol_table_nh, ) -from akshare.futures_derivative.nh_index_volatility import futures_nh_volatility_index +from akshare.futures_derivative.futures_index_volatility_nh import futures_nh_volatility_index """ 空气-河北 diff --git a/akshare/futures_derivative/nh_index_price.py b/akshare/futures_derivative/futures_index_price_nh.py similarity index 76% rename from akshare/futures_derivative/nh_index_price.py rename to akshare/futures_derivative/futures_index_price_nh.py index f706e3532cb..b5236c064a7 100644 --- a/akshare/futures_derivative/nh_index_price.py +++ b/akshare/futures_derivative/futures_index_price_nh.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- """ -Date: 2021/12/20 14:52 +Date: 2022/4/28 16:25 Desc: 南华期货-商品指数历史走势-价格指数-数值 http://www.nanhua.net/nhzc/varietytrend.html 1000 点开始, 用收益率累计 @@ -13,7 +13,7 @@ import pandas as pd -def futures_nh_index_symbol_table() -> pd.DataFrame: +def futures_index_symbol_table_nh() -> pd.DataFrame: """ 南华期货-南华指数所有品种一览表 http://www.nanhua.net/ianalysis/varietyindex/price/A.json?t=1574932974280 @@ -28,16 +28,16 @@ def futures_nh_index_symbol_table() -> pd.DataFrame: return temp_df -def futures_nh_price_index(symbol: str = "A") -> pd.DataFrame: +def futures_price_index_nh(symbol: str = "A") -> pd.DataFrame: """ 南华期货-南华指数单品种-价格-所有历史数据 http://www.nanhua.net/ianalysis/varietyindex/price/A.json?t=1574932974280 - :param symbol: 通过 ak.futures_nh_index_symbol_table() 获取 + :param symbol: 通过 ak.futures_index_symbol_table_nh() 获取 :type symbol: str :return: 南华期货-南华指数单品种-价格-所有历史数据 :rtype: pandas.Series """ - symbol_df = futures_nh_index_symbol_table() + symbol_df = futures_index_symbol_table_nh() if symbol in symbol_df["code"].tolist(): t = time.time() url = f"http://www.nanhua.net/ianalysis/varietyindex/price/{symbol}.json?t={int(round(t * 1000))}" @@ -50,8 +50,8 @@ def futures_nh_price_index(symbol: str = "A") -> pd.DataFrame: if __name__ == "__main__": - futures_nh_index_symbol_table_df = futures_nh_index_symbol_table() - print(futures_nh_index_symbol_table_df) + futures_index_symbol_table_nh_df = futures_index_symbol_table_nh() + print(futures_index_symbol_table_nh_df) - futures_nh_price_index_df = futures_nh_price_index(symbol="NHAI") - print(futures_nh_price_index_df) + futures_price_index_nh_df = futures_price_index_nh(symbol="NHAI") + print(futures_price_index_nh_df) diff --git a/akshare/futures_derivative/nh_index_return.py b/akshare/futures_derivative/futures_index_return_nh.py similarity index 64% rename from akshare/futures_derivative/nh_index_return.py rename to akshare/futures_derivative/futures_index_return_nh.py index 3bab1455b7e..41e2d97a47c 100644 --- a/akshare/futures_derivative/nh_index_return.py +++ b/akshare/futures_derivative/futures_index_return_nh.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- """ -Date: 2021/12/20 15:19 +Date: 2022/4/28 16:19 Desc: 南华期货-商品指数历史走势-收益率指数-数值-http://www.nanhua.net/nhzc/varietytrend.html 1000 点开始, 用收益率累计 目标地址: http://www.nanhua.net/ianalysis/varietyindex/index/NHCI.json?t=1574932290494 @@ -11,19 +11,20 @@ import requests import pandas as pd -from akshare.futures_derivative.nh_index_price import futures_nh_index_symbol_table +from akshare.futures_derivative.futures_index_price_nh import futures_index_symbol_table_nh -def futures_nh_return_index(symbol: str = "Y") -> pd.DataFrame: +def futures_return_index_nh(symbol: str = "Y") -> pd.DataFrame: """ 南华期货-南华指数单品种-收益率-所有历史数据 - :param symbol: 通过 ak.futures_nh_index_symbol_table() 获取 + :param symbol: 通过 ak.futures_index_symbol_table_nh() 获取 :type symbol: str :return: 南华指数单品种-收益率-所有历史数据 :rtype: pandas.Series """ - symbol_df = futures_nh_index_symbol_table() - if symbol in symbol_df["code"].tolist(): + symbol_df = futures_index_symbol_table_nh() + symbol_list = symbol_df["code"].tolist() + if symbol in symbol_list: t = time.time() url = f"http://www.nanhua.net/ianalysis/varietyindex/index/{symbol}.json?t={int(round(t * 1000))}" r = requests.get(url) @@ -31,9 +32,10 @@ def futures_nh_return_index(symbol: str = "Y") -> pd.DataFrame: temp_df = pd.DataFrame(data_json) temp_df.columns = ["date", "value"] temp_df['date'] = pd.to_datetime(temp_df["date"], unit='ms').dt.date + temp_df['value'] = pd.to_numeric(temp_df['value']) return temp_df if __name__ == "__main__": - futures_nh_return_index_df = futures_nh_return_index(symbol='NHAI') - print(futures_nh_return_index_df) + futures_return_index_nh_df = futures_return_index_nh(symbol='NHAI') + print(futures_return_index_nh_df) diff --git a/akshare/futures_derivative/nh_index_volatility.py b/akshare/futures_derivative/futures_index_volatility_nh.py similarity index 86% rename from akshare/futures_derivative/nh_index_volatility.py rename to akshare/futures_derivative/futures_index_volatility_nh.py index 26a9cd8d5d0..5b13d4c53dc 100644 --- a/akshare/futures_derivative/nh_index_volatility.py +++ b/akshare/futures_derivative/futures_index_volatility_nh.py @@ -12,21 +12,21 @@ import requests import pandas as pd -from akshare.futures_derivative.nh_index_price import futures_nh_index_symbol_table +from akshare.futures_derivative.futures_index_price_nh import futures_index_symbol_table_nh def futures_nh_volatility_index(symbol: str = "NHCI", period: str = '20') -> pd.DataFrame: """ 南华期货-南华指数单品种-波动率-所有历史数据 http://www.nanhua.net/nhzc/varietytrend.html - :param symbol: 通过 ak.futures_nh_index_symbol_table() 获取 + :param symbol: 通过 ak.futures_index_symbol_table_nh() 获取 :type symbol: str :param period: 波动周期 choice of {'5', '20', '60', '120'} :type period: str :return: 波动率-所有历史数据 :rtype: pandas.DataFrame """ - symbol_df = futures_nh_index_symbol_table() + symbol_df = futures_index_symbol_table_nh() if symbol in symbol_df["code"].tolist(): t = time.time() url = f"http://www.nanhua.net/ianalysis/volatility/{period}/{symbol}.json?t={int(round(t * 1000))}" diff --git a/akshare/futures_derivative/other_index_nh.py b/akshare/futures_derivative/futures_other_index_nh.py similarity index 100% rename from akshare/futures_derivative/other_index_nh.py rename to akshare/futures_derivative/futures_other_index_nh.py diff --git a/docs/changelog.md b/docs/changelog.md index 9574685a0e3..ea63aefe3be 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,9 @@ | AKShare 版本 | 旧接口名称 | 新接口名称 | 修改日期 | |------------|-----------------------------------|-----------------------------------|----------| +| 1.5.48 | futures_nh_price_index | futures_price_index_nh | 20220428 | +| 1.5.48 | futures_nh_index_symbol_table | futures_index_symbol_table_nh | 20220428 | +| 1.5.48 | futures_nh_return_index | futures_return_index_nh | 20220428 | | 1.5.46 | stock_em_yzxdr | stock_yzxdr_em | 20220427 | | 1.5.34 | stock_em_gpzy_industry_data | stock_gpzy_industry_data_em | 20220420 | | 1.5.26 | stock_em_comment | stock_comment_em | 20220415 | @@ -20,6 +23,12 @@ ## 更新说明 +1.5.48 fix: fix futures_return_index_nh interface + + 1. 修复 futures_return_index_nh 接口,重命名接口及规范数据输出格式 + 2. 修复 futures_index_symbol_table_nh 接口,重名接口 + 3. 修复 futures_price_index_nh 接口,重名接口 + 1.5.47 fix: fix macro_china_lpr interface 1. 修复 macro_china_lpr 接口,规范数据的输出格式 @@ -454,6 +463,8 @@ ## 版本更新说明 +1.5.48 fix: fix futures_return_index_nh interface + 1.5.47 fix: fix macro_china_lpr interface 1.5.46 fix: fix stock_yzxdr_em interface diff --git a/docs/data/futures/futures.md b/docs/data/futures/futures.md index 9d87fa67a35..84e743beafd 100644 --- a/docs/data/futures/futures.md +++ b/docs/data/futures/futures.md @@ -2854,7 +2854,7 @@ print(futures_contract_detail_df) #### 收益率指数 -接口: futures_nh_return_index +接口: futures_return_index_nh 目标地址: http://www.nanhua.net/nhzc/varietytrend.html @@ -2866,7 +2866,7 @@ print(futures_contract_detail_df) | 名称 | 类型 | 描述 | |--------|-----|----------------------------------------------------------------------| -| symbol | str | symbol="Y", 请参考南华指数品种一览表, 可以通过 ak.futures_nh_index_symbol_table() 获取 | +| symbol | str | symbol="Y", 请参考南华指数品种一览表, 可以通过 ak.futures_index_symbol_table_nh() 获取 | 南华指数品种一览表 @@ -2957,8 +2957,8 @@ print(futures_contract_detail_df) ```python import akshare as ak -futures_nh_return_index_df = ak.futures_nh_return_index() -print(futures_nh_return_index_df) +futures_return_index_nh_df = ak.futures_return_index_nh() +print(futures_return_index_nh_df) ``` 数据示例 @@ -2980,7 +2980,7 @@ print(futures_nh_return_index_df) #### 价格指数 -接口: futures_nh_price_index +接口: futures_price_index_nh 目标地址: http://www.nanhua.net/nhzc/varietytrend.html @@ -2992,7 +2992,7 @@ print(futures_nh_return_index_df) | 名称 | 类型 | 描述 | |--------|-----|----------------------------------------------------------------------| -| symbol | str | symbol="Y", 请参考南华指数品种一览表, 可以通过 ak.futures_nh_index_symbol_table() 获取 | +| symbol | str | symbol="Y", 请参考南华指数品种一览表, 可以通过 ak.futures_index_symbol_table_nh() 获取 | 南华指数品种一览表 @@ -3076,8 +3076,8 @@ print(futures_nh_return_index_df) ```python import akshare as ak -futures_nh_price_index_df = ak.futures_nh_price_index(symbol="Y") -print(futures_nh_price_index_df) +futures_price_index_nh_df = ak.futures_price_index_nh(symbol="Y") +print(futures_price_index_nh_df) ``` 数据示例 @@ -3111,7 +3111,7 @@ print(futures_nh_price_index_df) | 名称 | 类型 | 描述 | |--------|-----|--------------------------------------------------------------------------------------------| -| symbol | str | symbol="Y"; 注意是具体品种(不包含指数); 请参考南华指数品种一览表, 可以通过调用 **ak.futures_nh_index_symbol_table()** 获取 | +| symbol | str | symbol="Y"; 注意是具体品种(不包含指数); 请参考南华指数品种一览表, 可以通过调用 **ak.futures_index_symbol_table_nh()** 获取 | | period | str | period='20'; 波动周期; choice of {'5', '20', '60', '120'} | 南华指数品种一览表 diff --git a/docs/tutorial.md b/docs/tutorial.md index 7c9867b2679..9ebea135715 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -134,9 +134,9 @@ # 南华期货-南华指数-波动率指数 "futures_nh_volatility_index" # 波动率指数 # 南华期货-南华指数-价格指数 - "futures_nh_price_index" # 价格指数 + "futures_price_index_nh" # 价格指数 # 南华期货-南华指数-收益率指数 - "futures_nh_return_index" # 收益率指数 + "futures_return_index_nh" # 收益率指数 # 经济政策不确定性(EPU)指数 "article_epu_index" # 主要国家和地区的经济政策不确定性(EPU)指数 # 微博指数