复制链接
克隆策略

通过指数基本信息表 找到中证1000的代码

In [1]:
info = DataSource('basic_info_index_CN_STOCK_A').read()
print(info[info['name'] == '中证1000'])
       instrument    name
14511  000852.HIX  中证1000

通过指数代码获取日线行情和分钟行情

In [3]:
# 获取中证1000指数日线行情
bar1d_df = DataSource('bar1d_index_CN_STOCK_A').read(instruments=['000852.HIX'], start_date='2021-01-01')
bar1d_df.tail()
Out[3]:
turn adjust_factor instrument date open volume low close high amount
371 2.0973 1.0 000852.HIX 2022-07-18 6868.299316 18204798500 6839.131836 6953.932129 6953.932129 2.349531e+11
372 2.0983 1.0 000852.HIX 2022-07-19 6956.863281 18224049200 6932.736328 7009.323730 7033.250000 2.354159e+11
373 2.0898 1.0 000852.HIX 2022-07-20 7028.791992 18153371900 7019.512695 7110.104492 7110.104492 2.415321e+11
374 2.2646 1.0 000852.HIX 2022-07-21 7098.269531 19676974000 7067.147461 7075.294434 7134.217773 2.605839e+11
375 1.9891 1.0 000852.HIX 2022-07-22 7081.562500 17303097300 6969.430664 7034.597656 7124.303711 2.214888e+11
In [4]:
# 获取中证1000指数分钟行情
bar1m_df = DataSource('bar1m_index_CN_STOCK_A').read(['000852.HIX'], start_date='2022-01-01')
bar1m_df.tail()
Out[4]:
instrument date open close low high amount volume
31915 000852.HIX 2022-07-22 14:56:00 7033.491699 7033.597656 7033.135254 7034.121094 1.270759e+09 102298400
31916 000852.HIX 2022-07-22 14:57:00 7033.458496 7033.574219 7032.811035 7033.849609 1.383141e+09 111306600
31917 000852.HIX 2022-07-22 14:58:00 7033.493164 7033.567871 7033.493164 7033.642090 1.066817e+08 8029500
31918 000852.HIX 2022-07-22 14:59:00 7033.567871 7033.567871 7033.567871 7033.567871 0.000000e+00 0
31919 000852.HIX 2022-07-22 15:00:00 7033.463379 7034.597656 7033.463379 7034.753906 2.281157e+09 183299700