# https://www.joinquant.com/help/api/help?name=macroData
# PMI制造业采购经理指数 MAC_MANUFACTURING_PMI
from jqdata import macro
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.max_columns', None)
start_year = '2017'
end_year = '2019'
q = query(macro.MAC_MANUFACTURING_PMI
).filter(macro.MAC_MANUFACTURING_PMI.stat_month >= start_year,
macro.MAC_MANUFACTURING_PMI.stat_month <= end_year,
).order_by(macro.MAC_MANUFACTURING_PMI.stat_month.asc()
).with_entities(macro.MAC_MANUFACTURING_PMI.stat_month,
macro.MAC_MANUFACTURING_PMI.pmi)
df = macro.run_query(q)
print(df)
plt.figure(figsize=(15,5),dpi=80)
plt.plot(df['stat_month'], df['pmi'], color='black', linestyle="-")
# plt.gca().xaxis.set_major_formatter(DateFormatter('%y-%m'))
plt.xticks(df['stat_month'], rotation=45)
pyplot.title('制造业PMI', loc='right')
stat_month pmi 0 2017-01 51.3 1 2017-02 51.6 2 2017-03 51.8 3 2017-04 51.2 4 2017-05 51.2 5 2017-06 51.7 6 2017-07 51.4 7 2017-08 51.7 8 2017-09 52.4 9 2017-10 51.6 10 2017-11 51.8 11 2017-12 51.6 12 2018-01 51.3 13 2018-02 50.3 14 2018-03 51.5 15 2018-04 51.4 16 2018-05 51.9 17 2018-06 51.5 18 2018-07 51.2 19 2018-08 51.3 20 2018-09 50.8 21 2018-10 50.2 22 2018-11 50.0 23 2018-12 49.4
Text(1.0, 1.0, '制造业PMI')
# GDP分地区国内生产总值表 MAC_AREA_GDP_QUARTER(季度) MAC_AREA_GDP_YEAR(年度) 含有全国各地址123产业GDP
from jqdata import macro
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.max_columns', None)
start_year = '2000'
end_year = '2019'
q = query(macro.MAC_AREA_GDP_YEAR
).filter(macro.MAC_AREA_GDP_YEAR.stat_year >= start_year,
macro.MAC_AREA_GDP_YEAR.stat_year <= end_year,
macro.MAC_AREA_GDP_YEAR.area_code==156
).order_by(macro.MAC_AREA_GDP_YEAR.stat_year.asc()
).with_entities(macro.MAC_AREA_GDP_YEAR.stat_year,
macro.MAC_AREA_GDP_YEAR.gdp)
df = macro.run_query(q)
print(df)
plt.figure(figsize=(15,5),dpi=80)
plt.plot(df['stat_year'], df['gdp'], color='black', linestyle="-")
plt.xticks(df['stat_year'], rotation=45)
pyplot.title('GDP', loc='right')
stat_year gdp 0 2000 100280.1393 1 2001 110863.1230 2 2002 121717.4247 3 2003 137422.0349 4 2004 161840.1609 5 2005 187318.9031 6 2006 219438.5000 7 2007 270232.3000 8 2008 319244.6000 9 2009 348517.7437 10 2010 412119.2558 11 2011 487940.1805 12 2012 538579.9535 13 2013 592963.2295 14 2014 641280.5743 15 2015 685992.9497 16 2016 740060.7967 17 2017 820754.2782 18 2018 900309.4780
Text(1.0, 1.0, 'GDP')
# CPI 分地区居民消费价格指数 MAC_AREA_CPI_MONTH
from jqdata import macro
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.max_columns', None)
start_year = '2018'
end_year = '2019'
# q = query(macro.MAC_AREA_CPI_MONTH
# ).filter(macro.MAC_AREA_CPI_MONTH.stat_month >= start_year,
# macro.MAC_AREA_CPI_MONTH.stat_month <= end_year,
# macro.MAC_AREA_CPI_MONTH.area_code==156
# ).order_by(macro.MAC_AREA_CPI_MONTH.stat_month.asc()
# ).with_entities(macro.MAC_AREA_CPI_MONTH.stat_month,
# # macro.MAC_AREA_CPI_MONTH.area_code,
# # macro.MAC_AREA_CPI_MONTH.area_name,
# macro.MAC_AREA_CPI_MONTH.item_name,
# macro.MAC_AREA_CPI_MONTH.item_value)
# df = macro.run_query(q)
# print(df)
import tushare as ts
df = ts.get_cpi()
df = df.iloc[::-1]
df = df[df.month >= start_year]
# df = df[df.month <= end_year]
plt.figure(figsize=(15,5),dpi=80)
plt.plot(df['month'], df['cpi'], color='black', linestyle="-")
plt.xticks(df['month'], rotation=45)
pyplot.title('CPI', loc='right')
Text(1.0, 1.0, 'CPI')
# PPI 工业品出厂价格指数 http://tushare.org/macro.html
from jqdata import macro
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.max_columns', None)
start_year = '2018'
end_year = '2019'
import tushare as ts
df = ts.get_ppi()
df = df.iloc[::-1]
# print(df)
# month :统计月份
# ppiip :工业品出厂价格指数
# ppi :生产资料价格指数
# qm:采掘工业价格指数
# rmi:原材料工业价格指数
# pi:加工工业价格指数
# cg:生活资料价格指数
# food:食品类价格指数
# clothing:衣着类价格指数
# roeu:一般日用品价格指数
# dcg:耐用消费品价格指数
df = df[df.month >= start_year]
plt.figure(figsize=(15,5),dpi=80)
plt.plot(df['month'], df['ppiip'], color='black', linestyle="-",label='ppiip工业品出厂价格指数')
plt.plot(df['month'], df['ppi'], color='red', linestyle="-",label='ppi生产资料价格指数')
plt.xticks(df['month'], rotation=45)
pyplot.title('工业品出厂价格指数PPI', loc='right')
plt.legend()
<matplotlib.legend.Legend at 0x7f09254fe5c0>
本社区仅针对特定人员开放
查看需注册登录并通过风险意识测评
5秒后跳转登录页面...