示例#1
0
def get_china_yearly_pmi():
    """
    获取中国年度PMI数据, 数据区间从20050201-至今
    :return: pandas.Series
    2005-02-01    54.7
    2005-03-01    54.5
    2005-04-01    57.9
    2005-05-01    56.7
    2005-06-01    52.9
                  ...
    2019-06-30    49.4
    2019-07-31    49.7
    2019-08-31    49.5
    2019-09-30    49.5
    2019-10-31       0
    """
    t = time.time()
    res = requests.get(
        JS_CHINA_PMI_YEARLY_URL.format(
            str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
        )
    )
    json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
    date_list = [item["date"] for item in json_data["list"]]
    value_list = [item["datas"]["中国官方制造业PMI报告"] for item in json_data["list"]]
    value_df = pd.DataFrame(value_list)
    value_df.columns = json_data["kinds"]
    value_df.index = pd.to_datetime(date_list)
    temp_df = value_df["今值"]
    temp_df.name = "pmi"
    return temp_df
示例#2
0
def macro_china_pmi_yearly():
    """
    中国年度PMI数据, 数据区间从20050201-至今
    https://datacenter.jin10.com/reportType/dc_chinese_manufacturing_pmi
    https://cdn.jin10.com/dc/reports/dc_chinese_manufacturing_pmi_all.js?v=1578817858
    :return: pandas.Series
    """
    t = time.time()
    res = requests.get(
        JS_CHINA_PMI_YEARLY_URL.format(str(int(round(t * 1000))),
                                       str(int(round(t * 1000)) + 90)))
    json_data = json.loads(res.text[res.text.find("{"):res.text.rfind("}") +
                                    1])
    date_list = [item["date"] for item in json_data["list"]]
    value_list = [item["datas"]["中国官方制造业PMI报告"] for item in json_data["list"]]
    value_df = pd.DataFrame(value_list)
    value_df.columns = json_data["kinds"]
    value_df.index = pd.to_datetime(date_list)
    temp_df = value_df["今值"]
    temp_df.name = "pmi"
    return temp_df