# 上证50指数成分
df = D.history_data(D.instruments(),'2010-01-01','2015-01-01',fields=['in_sse50'])
instruments = list(set(df[df['in_sse50']==1]['instrument']))
print('上证50指数成分股预览10只股票:', instruments[:10])
# 沪深300指数成分
df = D.history_data(D.instruments(),'2010-01-01','2015-01-01',fields=['in_csi300'])
instruments = list(set(df[df['in_csi300']==1]['instrument']))
print('沪深300指数成分股预览10只股票:', instruments[:10])
# 中证500指数成分
df = D.history_data(D.instruments(),'2010-01-01','2015-01-01',fields=['in_csi500'])
instruments = list(set(df[df['in_csi500']==1]['instrument']))
print('中证500指数成分股预览10只股票:', instruments[:10])
# (举例)获取国防军工行业股票列表
df = D.history_data(D.instruments(), '2017-01-01', '2017-05-01', ['industry_sw_level1'])
instruments = list(set(df[df['industry_sw_level1'] == 650000]['instrument']))
D.history_data(instruments, '2017-07-27', '2017-07-27', ['company_name'])