验证代码如下:
initialize_xtquant()
xtdata.download_sector_data()
possible_sectors = ["沪深ETF", "沪深基金"]
populations = set()
for sector in possible_sectors:
this_sector_population = xtdata.get_stock_list_in_sector(sector)
populations.update(this_sector_population)
print(len(populations), "589070.SH" in populations)
print(xtdata.get_instrument_detail("589070.SH"))
得到的输出:
Using server pool: ['115.231.218.73:55310', '115.231.218.79:55310', '42.228.16.211:55300', '42.228.16.210:55300', '36.99.48.20:55300', '36.99.48.21:55300']
***** xtdata连接成功 2026-09-07 14:30:51 *****
服务信息: {'tag': 'xtquant', 'version': '1.0'}
服务地址: 127.0.0.1:58609
数据路径: D:\Documents\GitHub\PythonScripts\scripts\data\datadir
设置xtdata.enable_hello = False可隐藏此消息
2189 False
{'ExchangeID': 'SH', 'InstrumentID': '589070', 'InstrumentName': '科创芯片设计ETF天弘', 'ProductID': '', 'ProductName': '', 'ProductType': -1, 'ExchangeCode': '589070', 'UniCode': '589070', 'CreateDate': '0', 'OpenDate': '20260123', 'ExpireDate': '99999999', 'TradingDay': '20260907', 'PreClose': 1.027, 'SettlementPrice': 1.027, 'UpStopPrice': 1.232, 'DownStopPrice': 0.822, 'FloatVolume': 2021293000.0, 'TotalVolume': 2021293000.0, 'LongMarginRatio': 1.7976931348623157e+308, 'ShortMarginRatio': 1.7976931348623157e+308, 'PriceTick': 0.001, 'VolumeMultiple': 1, 'MainContract': 2147483647, 'LastVolume': 2147483647, 'InstrumentStatus': 0, 'IsTrading': False, 'IsRecent': False, 'ProductTradeQuota': 0, 'ContractTradeQuota': 0, 'ProductOpenInterestQuota': 0, 'ContractOpenInterestQuota': 0}
可以看出,589070.SH不包括在用get_stock_list_in_sector获取"沪深ETF", "沪深基金"里面,但它应该算沪深的ETF。