#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ETF universe + 前复权日线探针(P0 Task2.1)。 VPS 跑: C:\\Python310\\python.exe -X utf8 probe_etf.py """ import sys from xtquant import xtdata as xd def main(): etf = xd.get_stock_list_in_sector("沪深ETF") or [] fund = xd.get_stock_list_in_sector("沪深基金") or [] a = xd.get_stock_list_in_sector("沪深A股") or [] u = list(set(a + etf + fund)) print(f"A={len(a)} ETF={len(etf)} fund={len(fund)} union={len(u)}") print(f"sample ETF: {etf[:5]}") print(f"sample fund: {fund[:5]}") # 抽样: 510300.SH(沪深300ETF) / 513050.SH(中概互联网ETF) / 159919.SZ(300ETF) samples = ["510300.SH", "513050.SH", "159919.SZ"] r = xd.get_market_data_ex([], samples, period="1d", start_time="20240101", end_time="20260721", dividend_type="front") for sym in samples: df = r.get(sym) if r else None bars = 0 if df is None else len(df) tail_close = None if df is None or not len(df) else float(df["close"].iloc[-1]) head_date = None if df is None or not len(df) else str(df.index[0])[:8] tail_date = None if df is None or not len(df) else str(df.index[-1])[:8] nan_close = None if df is None else bool(df["close"].isnull().any()) print(f"{sym}: bars={bars} date=[{head_date}~{tail_date}] tail_close={tail_close} nan_close={nan_close}") sys.stdout.flush() if __name__ == "__main__": main()