# 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')
# 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')
# 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')
# 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()