774170ec05
采集层(多源各下): - baostock: 日线全字段全量(baostock_daily_fullmarket) + 15min全市场 + 静态(基础/复权/分红/季频/三表) + 成份股 - akshare: 静态(估值/龙虎榜/大宗/融资融券/北向/指数成分/行业/股本/解禁/业绩预告) - xtdata(miniQMT): build_daily_from_xtdata + daily_update_xtdata 数据补全 P0: - ETF全市场: universe 扩展 沪深A股∪ETF∪基金(7414), dividend_type='front' 前复权 - 历史成份股(治幸存者偏差): index_const_hist_download 深证/国证 adjust_cni 4指数 + 中证1000/2000快照 + 新浪交叉校验 - 退市K线: baostock_delisted_download + import_delisted_to_db(实证 Day1 fetch_all_stocks 已含退市) 灌库: - import_baostock_to_db: daily_baostock_full(5537股/1826万行,18字段)+ bs_index_constituent + bs_adjust_factor - INSERT OR REPLACE 幂等, WAL+busy_timeout, dbbardata 不碰 每日增量 #7(用户决策A: VPS直跑): - daily_update_static: login探针防黑名单graceful skip + LOOKBACK7 + query_stock_basic含退市 + INSERT OR REPLACE + QUERY_COUNT守48000/天 设计文档: spec(13节三层融合) + P0 plan + 数据gap设计
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
#!/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()
|