Quantdb Data Structure logo

Quantdb Data Structure

CommunityPopular
qusong0627
quantdb-data-structure

QuantDB 服务器数据结构与读取口径 — 数据目录组织(1_kline_data~6_ml_datasets)、Hive 分区规律(dt=YYYYMMDD 整数)、单文件 {symbol}.parquet、parquet 后缀式代码 600519.SH 与 PG 前缀式 SH600519 的转换口径、quantdb_hub.py 单一读取入口与 DuckDB 视图清单、服务器路径映射(/opt/quantmind/data/quantdb → 容器 /data/quantdb)。凡需要读写/探查/补数/验证 QuantDB 本地 parquet 数据、查目录结构、写 DuckDB 查询、排查查不到数据问题时使用。触发词:quantdb 结构、数据目录、dt 分区、hive 分区、parquet 路径、数据在哪里、600519.SH、代码格式、qdb_ 视图、quantdb_hub、增量同步、数据缺失排查

Overview

Publisherqusong0627
RepositoryQuantMind
Skill namequantdb-data-structure
Stars
1.7K
Forks
387
Bundled files
Instructions only
LicenseAGPL-3.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by qusong0627 on GitHub. Read the source before you install it.

Installation

Install the Quantdb Data Structure AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/qusong0627/QuantMind/tree/master/skills/quantdb-data-structure
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/qusong0627/QuantMind.git /tmp/QuantMind
mkdir -p .claude/skills
cp -r /tmp/QuantMind/skills/quantdb-data-structure .claude/skills/quantdb-data-structure
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Quantdb Data Structure in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Quantdb Data Structure on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Quantdb Data Structure is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

⚙️ 本技能遵循公共运行环境契约(最高优先级,先于本文其余内容执行): 详见 _shared/env-contract.md,执行前先读它。

quantdb-data-structure — QuantDB 数据结构与读取口径

写任何触碰 QuantDB 本地数据的代码/查询前必读。字段单位与口径陷阱另见 skills/quantdb-fields/SKILL.md(本技能管「数据在哪、怎么组织、怎么读」)。

一、路径映射(先定位数据)

位置路径
生产服务器宿主机/opt/quantmind/data/quantdb
容器内(./data:/data bind mount)/data/quantdb
本地仓库<项目根>/data/quantdb
用户自定义数据集(产出区)/data/quantcustom(宿主机 /opt/quantmind/data/quantcustom)

⚠️ quantdb/ 是官方只读数据;quantcustom/ 是用户/挖掘产出(因子挖掘、因子工厂的落盘区,QM_QUANTCUSTOM_DATA_DIR)。两者结构同为 6 大类,但写入一律进 quantcustom,不要污染 quantdb。

数据目录解析优先级(quantdb_hub.py._resolve_data_dir): 环境变量 QM_QUANTDB_DATA_DIR → /data/quantdb → /app/data/quantdb → D:/quant_data → 项目根 data/quantdb。

二、顶层数据集目录

目录内容组织方式
1_kline_data/日K(daily_forward/backward/unadjusted 三种复权)、index_daily、min1_kline、min5_kline、tick日K/指数=分区;分钟线=单文件
2_base_sector/instrument_detail、sector_concept、trading_calendar、index_weights、margin_trading、hsgt_north混合
3_financial_data/balance/income/cashflow/股本/分红因子等财务报表单文件为主
4_bond_etf/债券 / ETF单文件
5_technical_derived/valuation(估值)、technical_indicators、market_sentiment分区
6_ml_datasets/features_daily、l1_factors、l2_factors、l1_l2_factors、alpha_library(Alpha101+GTJA191+Alpha158 三库因子)分区

辅助文件:releases/(数据包版本)、.sync_state / quantdb_sync.sqlite(增量同步状态)、.qlib_cache、_meta。

用户自定义数据集 quantcustom/6_ml_datasets/

挖掘产物统一落 data/quantcustom/6_ml_datasets/<数据集>/(结构与 quantdb 一致,按 dt=YYYYMMDD/ 分区):

数据集来源附加文件
l1_factors① RD-Agent 因子 export ② 因子工厂(backend/scripts/factor_factory.py)MANIFEST.csv(factor_name/expression/ic/icir/coverage/kept)、PROPOSALS.json
  • 读取入口:QuantDBFactorReader(mode="CUSTOM")(QM_QUANTCUSTOM_DATA_DIR,默认 /data/quantcustom)。
  • 只读展示:GET /api/v1/alpha-agent/factory-factors(读 l1_factors/MANIFEST.csv,只回显不回测)。
  • 历史补全/落库路径:backend/services/api/routers/admin/alpha_factor_pipeline.py。

三、文件组织规律(决定查询写法)

  1. 分区型:<数据集>/dt=YYYYMMDD/data.parquet。dt 是 Hive 分区列,整数(如 20260828),DuckDB 过滤 WHERE dt BETWEEN 20260101 AND 20260828 可走谓词下推,不要写字符串。
  2. 单文件型:<数据集>/{symbol}.parquet(财务报表、分钟K)或整表单文件(instrument_detail.parquet),用 pd.read_parquet 直读。
  3. 混合格式:6_ml_datasets/l1_factors/ 同时存在平铺 l1_factors_YYYYMMDD.parquet 与 dt=YYYYMMDD/ 分区——只读 dt=* 分区目录,避免混入平铺文件。
  4. 北向资金特殊:2_base_sector/hsgt_north/ 日频在 daily_freq/*.parquet(无分区),季度快照用 quarter=YYYYQN Hive 分区(2024-08 起季度披露)。

四、代码格式口径(最高频踩坑点)

存储位置格式示例
QuantDB parquet 的 symbol/wind_code后缀式600519.SH、000001.SZ
PG 表 stock_daily_latest 等内部表前缀式SH600519、SZ000001
  • 查 QuantDB parquet 前必须转换:后端用 backend/shared/stock_utils.py 的 StockCodeUtil.to_suffix(code);前端 normalizeStockCode。
  • 反面教训:把前缀式代码原样传进 parquet 查询会静默返回空、不报错,快路径还会悄悄跌入兜底数据源(复权口径随之失效)。写完新链路必须实测两种复权参数下首/末根数值真正分化,并核对响应的 source_used 字段。

五、读取入口与 DuckDB 视图清单

唯一推荐入口:backend/services/engine/data_platform/quantdb_hub.py(QuantDBDataHub)——懒加载、线程安全、自动做列名映射(time→trade_date、wind_code→symbol、volinstock/vol_in_stock→volume)。不要绕过它自己拼 parquet 路径,除非做数据巡检。

分区数据集挂载的 DuckDB 视图(hive_partitioning=1, union_by_name=true):

视图数据
qdb_daily_forward / qdb_daily_backward / qdb_daily_unadjusted前复权 / 后复权 / 不复权日K
qdb_index_daily指数日K
qdb_valuation估值
qdb_technical_indicators技术指标
qdb_market_sentiment市场情绪
qdb_features_daily每日特征
qdb_margin_trading融资融券
qdb_l2_factors / qdb_l1_l2_factorsL2 / L1+L2 因子
qdb_l1_factorsL1 因子(仅当存在 dt=* 分区时挂载)
qdb_alpha_library三库因子 429 列(训练直读)
qdb_hsgt_north_daily / qdb_hsgt_north北向资金日频 / 季度

临时探查可直接 DuckDB 查文件:

sql
SELECT * FROM read_parquet('/data/quantdb/1_kline_data/daily_forward/dt=20260828/data.parquet')
WHERE symbol = '600519.SH';

六、服务器核查命令速查

bash
# 目录与体量
ls /opt/quantmind/data/quantdb && du -sh /opt/quantmind/data/quantdb/*

# 容器内可见性
docker exec quantmind ls /data/quantdb

# 某交易日数据是否到位(以日K为例)
ls /opt/quantmind/data/quantdb/1_kline_data/daily_forward/dt=20260828/

数据更新后服务未感知时:docker compose restart quantmind celery-worker(数据走 bind mount,无需重建镜像)。增量同步需先在【个人中心】→【数据平台】绑定 QUANTDB_API_KEY 后 docker exec 触发。

七、写代码前的自查清单

  • 用的是 QM_QUANTDB_DATA_DIR/默认目录解析,而不是写死路径?
  • 分区过滤用的是整数 dt,范围合理(不跨年全表扫)?
  • 查 parquet 的代码已转后缀式?查 PG 内部表保持前缀式?
  • 查询结果为空时验证过不是「格式错配静默查空」,而是真的无数据?
  • 涉及字段单位(成交量/成交额/市值/股息率)时已对照 quantdb-fields 技能?

Frequently asked questions

What does the Quantdb Data Structure AI skill do?

QuantDB 服务器数据结构与读取口径 — 数据目录组织(1_kline_data~6_ml_datasets)、Hive 分区规律(dt=YYYYMMDD 整数)、单文件 {symbol}.parquet、parquet 后缀式代码 600519.SH 与 PG 前缀式 SH600519 的转换口径、quantdb_hub.py 单一读取入口与 DuckDB 视图清单、服务器路径映射(/opt/quantmind/data/quantdb → 容器 /data/quantdb)。凡需要读写/探查/补数/验证 QuantDB 本地 parquet 数据、查目录结构、写 DuckDB 查询、排查查不到数据问题时使用。触发词:quantdb 结构、数据目录、dt 分区、hive 分区、parquet 路径、数据在哪里、600519.SH、代码格式、qdb_ 视图、quantdb_hub、增量同步、数据缺失排查

Why use Quantdb Data Structure on TypingMind?

Because you install it once and use it with any model. Quantdb Data Structure is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Quantdb Data Structure in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/qusong0627/QuantMind/tree/master/skills/quantdb-data-structure. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Quantdb Data Structure?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Quantdb Data Structure?

As many as you like. As long as a model supports skills, you can use Quantdb Data Structure with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Quantdb Data Structure AI skill free?

Yes. It is published on GitHub by qusong0627 under the AGPL-3.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇