说明 / 示例
用法: ContextInfo.get_sector(sector, realtime)
释义: 获取板块成份股,只支持取指数成份股
参数:
string:必须是 ‘stock.market’ 形式,如 ‘000300.SH’ ,可取如沪深300(000300.SH)、中证500(000905.SH)、上证50(000016.SH)等指数的历史成份股
realtime:毫秒级时间戳,如不填则默认取目前最新成份股
返回: list:内含成份股代码,里面股票代码为 ‘000002.SZ’ 形式
示例:
```py
def handlebar(ContextInfo):
index = ContextInfo.barpos
realtime = ContextInfo.get_bar_timetag(index)
print(ContextInfo.get_sector('000300.SH', realtime))
```