wilsonwangwang commited on
Commit
b08e45b
·
verified ·
1 Parent(s): 1a945e7

Delete gap_supplement/MERGE_GAP_SKILL.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. gap_supplement/MERGE_GAP_SKILL.md +0 -61
gap_supplement/MERGE_GAP_SKILL.md DELETED
@@ -1,61 +0,0 @@
1
- ---
2
- name: polymarket-gap-merge-parquet
3
- description: 将 gap 补充 parquet 与 poly_data 下 huggingface_data/raw 全量 trades/quant/users 合并(DuckDB 推荐)。
4
- ---
5
-
6
- # Polymarket gap 与基线 parquet 合并
7
-
8
- ## 路径约定
9
-
10
- - **Gap 产物**(本仓库内,用于上传 HF):`Polymarket_data/hf_push/gap_supplement/trades_fix_gap.parquet`(及 quant/users)。
11
- - **基线**(通常在同级 `poly_data`):`$POLY_ROOT/huggingface_data/raw/trades.parquet` 等。未设置 `POLY_ROOT` 时默认 `Polymarket_data` 的上一级目录下的 `poly_data`。
12
- - **Trades 去重键**:`(timestamp, transaction_hash, maker, taker)`。合并前将 `timestamp`/`block_number` 规范为 `BIGINT`,`transaction_hash`/`maker`/`taker` 用 `lower()`。
13
-
14
- ## DuckDB:写出新文件再原子替换(推荐)
15
-
16
- 将下面路径替换为你的 `POLY_ROOT` 绝对路径。
17
-
18
- ```sql
19
- COPY (
20
- SELECT * FROM (
21
- SELECT
22
- CAST(CAST(timestamp AS VARCHAR) AS BIGINT) AS _ts,
23
- lower(CAST(transaction_hash AS VARCHAR)) AS _tx,
24
- lower(CAST(maker AS VARCHAR)) AS _mk,
25
- lower(CAST(taker AS VARCHAR)) AS _tk,
26
- *
27
- FROM read_parquet('/ABS/POLY_ROOT/huggingface_data/raw/trades.parquet')
28
- UNION ALL
29
- SELECT
30
- CAST(CAST(timestamp AS VARCHAR) AS BIGINT),
31
- lower(CAST(transaction_hash AS VARCHAR)),
32
- lower(CAST(maker AS VARCHAR)),
33
- lower(CAST(taker AS VARCHAR)),
34
- *
35
- FROM read_parquet('/ABS/Polymarket_data/hf_push/gap_supplement/trades_fix_gap.parquet')
36
- )
37
- QUALIFY ROW_NUMBER() OVER (PARTITION BY _ts, _tx, _mk, _tk ORDER BY _ts) = 1
38
- ) TO '/ABS/POLY_ROOT/huggingface_data/raw/trades_merged.parquet'
39
- (FORMAT PARQUET, COMPRESSION ZSTD);
40
- ```
41
-
42
- 校验后:`mv trades_merged.parquet trades.parquet`(先在副本上验证行数与键)。
43
-
44
- ## 生成 Gap 侧文件
45
-
46
- 在 `Polymarket_data` 根目录:
47
-
48
- ```bash
49
- export POLY_ROOT=/path/to/poly_data # 含 data/recovered_chunks、markets 等
50
- python3 scripts/gap_recovery/gap_to_trades_quant_users_hf.py
51
- python3 scripts/gap_recovery/prepare_hf_gap_bundle.py
52
- export HF_TOKEN=...
53
- python3 scripts/gap_recovery/hf_sync_gap_dataset.py
54
- ```
55
-
56
- ## 相关源码(均在 `scripts/gap_recovery/`)
57
-
58
- - `gap_to_trades_quant_users_hf.py` — 全量 gap → trades/quant/users
59
- - `run_recent_recovery_parallel.py` — RPC 拉取与自适应批次
60
- - `build_trades_supplement_from_gap_parquets.py` — 仅 trades 补充
61
- - `verify_hf_orderfilled_gaps_2_50_duckdb.py` — HF 相邻块小空洞统计