From 9ce8b2be2f49be31c363c88746f21929beb2654b Mon Sep 17 00:00:00 2001 From: ak_quant Date: Tue, 29 Mar 2022 17:21:38 +0800 Subject: [PATCH] feat(macro_china_mobile_number): add macro_china_mobile_number interface add macro_china_mobile_number interface --- akshare/__init__.py | 4 ++- akshare/economic/macro_china.py | 46 +++++++++++++++++++++++++++ docs/changelog.md | 6 ++++ docs/data/macro/macro.md | 55 +++++++++++++++++++++++++++++++++ docs/tutorial.md | 3 ++ 5 files changed, 113 insertions(+), 1 deletion(-) diff --git a/akshare/__init__.py b/akshare/__init__.py index 462dfed8286..220a5a60b38 100644 --- a/akshare/__init__.py +++ b/akshare/__init__.py @@ -1914,9 +1914,10 @@ 1.4.91 fix: fix macro_china_new_financial_credit interface 1.4.92 add: add stock_lhb_hyyyb_em interface 1.4.93 add: add macro_china_insurance_income interface +1.4.94 add: add macro_china_mobile_number interface """ -__version__ = "1.4.93" +__version__ = "1.4.94" __author__ = "AKFamily" import sys @@ -3653,6 +3654,7 @@ from akshare.economic.macro_china import ( macro_china_bank_financing, macro_china_insurance_income, + macro_china_mobile_number, macro_china_cpi_monthly, macro_china_cpi_yearly, macro_china_m2_yearly, diff --git a/akshare/economic/macro_china.py b/akshare/economic/macro_china.py index 30081a866c3..d1281299e8c 100644 --- a/akshare/economic/macro_china.py +++ b/akshare/economic/macro_china.py @@ -1701,6 +1701,52 @@ def macro_china_insurance_income() -> pd.DataFrame: return temp_df +def macro_china_mobile_number() -> pd.DataFrame: + """ + 手机出货量 + https://data.eastmoney.com/cjsj/hyzs_list_EMI00225823.html + :return: 手机出货量 + :rtype: pandas.DataFrame + """ + url = "https://datacenter-web.eastmoney.com/api/data/v1/get" + params = { + 'sortColumns': 'REPORT_DATE', + 'sortTypes': '-1', + 'pageSize': '1000', + 'pageNumber': '1', + 'reportName': 'RPT_INDUSTRY_INDEX', + 'columns': 'REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y', + 'filter': '(INDICATOR_ID="EMI00225823")', + 'source': 'WEB', + 'client': 'WEB', + } + r = requests.get(url, params=params) + data_json = r.json() + temp_df = pd.DataFrame(data_json['result']["data"]) + temp_df.drop_duplicates(inplace=True) + temp_df.columns = [ + "日期", + "最新值", + "涨跌幅", + '近3月涨跌幅', + '近6月涨跌幅', + '近1年涨跌幅', + '近2年涨跌幅', + '近3年涨跌幅', + ] + temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date + temp_df["最新值"] = pd.to_numeric(temp_df["最新值"]) + temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"]) + temp_df["近3月涨跌幅"] = pd.to_numeric(temp_df["近3月涨跌幅"]) + temp_df["近6月涨跌幅"] = pd.to_numeric(temp_df["近6月涨跌幅"]) + temp_df["近1年涨跌幅"] = pd.to_numeric(temp_df["近1年涨跌幅"]) + temp_df["近2年涨跌幅"] = pd.to_numeric(temp_df["近2年涨跌幅"]) + temp_df["近3年涨跌幅"] = pd.to_numeric(temp_df["近3年涨跌幅"]) + temp_df.sort_values(['日期'], inplace=True) + temp_df.reset_index(inplace=True, drop=True) + return temp_df + + def macro_china_new_financial_credit() -> pd.DataFrame: """ 中国-新增信贷数据 diff --git a/docs/changelog.md b/docs/changelog.md index e01fbb587f9..7a7bf719f39 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -11,6 +11,10 @@ ## 更新说明 +1.4.94 add: add macro_china_mobile_number interface + + 1. 新增 macro_china_mobile_number 接口,获取手机出货量数据 + 1.4.93 add: add macro_china_insurance_income interface 1. 新增 macro_china_insurance_income 接口,获取原保险保费收入数据 @@ -229,6 +233,8 @@ ## 版本更新说明 +1.4.94 add: add macro_china_mobile_number interface + 1.4.93 add: add macro_china_insurance_income interface 1.4.92 add: add stock_lhb_hyyyb_em interface diff --git a/docs/data/macro/macro.md b/docs/data/macro/macro.md index 8f6c44ecb9b..aedf4457001 100644 --- a/docs/data/macro/macro.md +++ b/docs/data/macro/macro.md @@ -1419,6 +1419,61 @@ print(macro_china_insurance_income_df) 209 2022-01-01 7.049640e+07 -70.092958 ... -5.768089 5.429366 12.398597 ``` +##### 手机出货量 + +接口: macro_china_mobile_number + +目标地址: https://data.eastmoney.com/cjsj/hyzs_list_EMI00225823.html + +描述: 手机出货量, 数据区间从 201201-至今 + +限量: 单次返回所有历史数据 + +输入参数 + +| 名称 | 类型 | 描述 | +|-----|-----|-----| +| - | - | - | + +输出参数 + +| 名称 | 类型 | 描述 | +|--------|---------|---------| +| 日期 | object | - | +| 最新值 | int64 | - | +| 涨跌幅 | float64 | 注意单位: % | +| 近3月涨跌幅 | float64 | 注意单位: % | +| 近6月涨跌幅 | float64 | 注意单位: % | +| 近1年涨跌幅 | float64 | 注意单位: % | +| 近2年涨跌幅 | float64 | 注意单位: % | +| 近3年涨跌幅 | float64 | 注意单位: % | + +接口示例 + +```python +import akshare as ak + +macro_china_mobile_number_df = ak.macro_china_mobile_number() +print(macro_china_mobile_number_df) +``` + +数据示例 + +``` + 日期 最新值 涨跌幅 ... 近1年涨跌幅 近2年涨跌幅 近3年涨跌幅 +0 2012-01-01 2400.6 NaN ... NaN NaN NaN +1 2012-02-01 2998.9 24.922936 ... NaN NaN NaN +2 2012-03-01 3958.6 32.001734 ... NaN NaN NaN +3 2012-04-01 3528.7 -10.859900 ... NaN NaN NaN +4 2012-05-01 3586.8 1.646499 ... NaN NaN NaN +.. ... ... ... ... ... ... ... +117 2021-10-01 3357.5 56.599813 ... 28.379153 -6.655731 -12.866893 +118 2021-11-01 3525.2 4.994788 ... 19.159005 1.176741 -0.333616 +119 2021-12-01 3340.1 -5.250766 ... 25.591277 9.712916 -6.371587 +120 2022-01-01 3302.2 -1.134697 ... -17.691924 58.660453 -3.013393 +121 2022-02-01 1486.4 -54.987584 ... -31.688037 132.832080 2.432637 +``` + ##### 新增信贷数据 接口: macro_china_new_financial_credit diff --git a/docs/tutorial.md b/docs/tutorial.md index ae540ca4ee4..19b15ab97d3 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -1033,6 +1033,9 @@ # 投资组合-重大变动 "fund_portfolio_change_em" # 天天基金网-基金档案-投资组合-重大变动 "fund_portfolio_industry_allocation_em" # 天天基金网-基金档案-投资组合-行业配置 + # 中国宏观 + "macro_china_insurance_income" # 原保险保费收入 + "macro_china_mobile_number" # 手机出货量 ``` ## 案例演示