ResearchRL commited on
Commit
a0b07cf
·
verified ·
1 Parent(s): 626fad4

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +314 -3
README.md CHANGED
@@ -1,3 +1,314 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ tags:
6
+ - finance
7
+ - trading
8
+ - cryptocurrency
9
+ - bitcoin
10
+ - time-series
11
+ - OHLCV
12
+ - binance
13
+ - futures
14
+ - quantitative-finance
15
+ - differentiable-trading
16
+ pretty_name: BTCUSDT 1-Min Futures — 5-Year Research Dataset (2021–2025)
17
+ size_categories:
18
+ - 1M<n<10M
19
+ task_categories:
20
+ - time-series-forecasting
21
+ ---
22
+
23
+ # BTCUSDT 1-Min Futures — 5-Year Research Dataset (2021–2025)
24
+
25
+ A gap-free 1-minute OHLCV dataset for **BTCUSDT Binance USDⓈ-M Perpetual Futures**
26
+ covering five full calendar years: **2021-01-01 through 2025-12-31 (UTC)**.
27
+
28
+ This repository contains **raw market bars only**. Feature engineering, aggregation,
29
+ sample construction, normalisation, and temporal splitting belong to the downstream
30
+ [DiffQuant](https://github.com/YuriyKolesnikov/diffquant) pipeline, described below
31
+ for reproducibility.
32
+
33
+ ---
34
+
35
+ ## What this dataset is — and is not
36
+
37
+ **Is:**
38
+ - A clean, gap-free 1-minute futures bar dataset (2,629,440 bars)
39
+ - A reproducible research input for intraday quantitative studies
40
+ - The primary data source for the DiffQuant differentiable trading pipeline
41
+
42
+ **Is not:**
43
+ - A trading signal or strategy
44
+ - A labelled prediction dataset
45
+ - An RL environment with rewards or actions
46
+ - Order-book, trades, funding rates, open interest, or liquidation data
47
+
48
+ ---
49
+
50
+ ## Dataset card
51
+
52
+ | | |
53
+ |---|---|
54
+ | **Asset** | BTCUSDT Binance USDⓈ-M Perpetual Futures |
55
+ | **Resolution** | 1-minute bars, close-time convention |
56
+ | **Period** | 2021-01-01 00:00 UTC → 2025-12-31 23:59 UTC |
57
+ | **Total bars** | 2,629,440 |
58
+ | **Coverage** | 100.00% — zero gaps |
59
+ | **File** | `btcusdt_1min_2021_2025.npz` (40.6 MB, NumPy compressed) |
60
+ | **Price range** | $15,502 → $126,087 |
61
+ | **OHLC violations** | 0 ✓ |
62
+ | **Duplicate timestamps** | 0 ✓ |
63
+ | **License** | MIT |
64
+
65
+ ---
66
+
67
+ ## Collection and quality assurance
68
+
69
+ Source: Binance USDⓈ-M Futures public API via internal database.
70
+ All bars use **close-time convention** — each timestamp marks the end of the bar.
71
+
72
+ QA checks applied before release:
73
+
74
+ - Duplicate timestamp detection
75
+ - Full date-range gap scan (minute-level)
76
+ - OHLC consistency: `low ≤ min(open, close)` and `high ≥ max(open, close)`
77
+ - Negative price and volume checks
78
+ - Schema validation across all columns
79
+
80
+ Results for this release:
81
+
82
+ | Check | Result |
83
+ |---|---|
84
+ | Duplicate timestamps | 0 ✓ |
85
+ | Missing minutes | 0 ✓ |
86
+ | OHLC violations | 0 ✓ |
87
+ | Negative prices | 0 ✓ |
88
+ | Zero-volume bars | 213 (retained — valid observations) |
89
+
90
+ ---
91
+
92
+ ## File structure
93
+
94
+ ```python
95
+ import numpy as np
96
+
97
+ data = np.load("btcusdt_1min_2021_2025.npz", allow_pickle=True)
98
+
99
+ bars = data["bars"] # (2_629_440, 6) float32 — raw exchange bars
100
+ timestamps = data["timestamps"] # (2_629_440,) int64 — Unix ms UTC, close-time
101
+ columns = list(data["columns"]) # ['open', 'high', 'low', 'close', 'volume', 'num_trades']
102
+ meta = str(data["meta"][0]) # provenance string
103
+ ```
104
+
105
+ ### Channels (raw values)
106
+
107
+ | Index | Name | Description |
108
+ |---|---|---|
109
+ | 0 | `open` | First trade price in the bar |
110
+ | 1 | `high` | Highest trade price in the bar |
111
+ | 2 | `low` | Lowest trade price in the bar |
112
+ | 3 | `close` | Last trade price in the bar |
113
+ | 4 | `volume` | Total base asset volume (BTC) |
114
+ | 5 | `num_trades` | Number of individual trades |
115
+
116
+ All values are stored as raw floats with no pre-processing applied.
117
+
118
+ ### Summary statistics
119
+
120
+ | Channel | Min | Max | Mean |
121
+ |---|---|---|---|
122
+ | open | 15,502.00 | 126,086.70 | 54,382.59 |
123
+ | high | 15,532.20 | 126,208.50 | 54,406.74 |
124
+ | low | 15,443.20 | 126,030.00 | 54,358.47 |
125
+ | close | 15,502.00 | 126,086.80 | 54,382.60 |
126
+ | volume | 0.00 | 40,256.00 | 241.90 |
127
+ | num_trades | 0.00 | 263,775.00 | 2,551.55 |
128
+
129
+ ### Bars by year
130
+
131
+ ```
132
+ 2021: 525,600 ██████████████████████████████
133
+ 2022: 525,600 ██████████████████████████████
134
+ 2023: 525,600 ██████████████████████████████
135
+ 2024: 527,040 ██████████████████████████████ (leap year)
136
+ 2025: 525,600 ██████████████████████████████
137
+ ```
138
+
139
+ ### Sample bars
140
+
141
+ **First 5 bars (2021-01-01):**
142
+
143
+ | # | Datetime UTC | open | high | low | close | volume | num_trades |
144
+ |---|---|---|---|---|---|---|---|
145
+ | 0 | 2021-01-01 00:00 | 28939.90 | 28981.55 | 28934.65 | 28951.68 | 126.0 | 929 |
146
+ | 1 | 2021-01-01 00:01 | 28948.19 | 28997.16 | 28935.30 | 28991.01 | 143.0 | 1120 |
147
+ | 2 | 2021-01-01 00:02 | 28992.98 | 29045.93 | 28991.01 | 29035.18 | 256.0 | 1967 |
148
+ | 3 | 2021-01-01 00:03 | 29036.41 | 29036.97 | 28993.19 | 29016.23 | 102.0 | 987 |
149
+ | 4 | 2021-01-01 00:04 | 29016.23 | 29023.87 | 28995.50 | 29002.92 | 85.0 | 832 |
150
+
151
+ **Mid-dataset (2023-07-03):**
152
+
153
+ | # | Datetime UTC | open | high | low | close | volume | num_trades |
154
+ |---|---|---|---|---|---|---|---|
155
+ | 1314720 | 2023-07-03 00:00 | 30611.70 | 30615.70 | 30611.70 | 30612.70 | 42.0 | 649 |
156
+ | 1314721 | 2023-07-03 00:01 | 30612.70 | 30624.40 | 30612.70 | 30613.90 | 150.0 | 1846 |
157
+ | 1314722 | 2023-07-03 00:02 | 30613.90 | 30614.00 | 30600.00 | 30600.00 | 241.0 | 1796 |
158
+
159
+ **Last 5 bars (2025-12-31):**
160
+
161
+ | # | Datetime UTC | open | high | low | close | volume | num_trades |
162
+ |---|---|---|---|---|---|---|---|
163
+ | 2629435 | 2025-12-31 23:55 | 87608.40 | 87608.40 | 87608.30 | 87608.30 | 10.0 | 182 |
164
+ | 2629436 | 2025-12-31 23:56 | 87608.40 | 87613.90 | 87608.30 | 87613.90 | 14.0 | 343 |
165
+ | 2629437 | 2025-12-31 23:57 | 87613.90 | 87621.70 | 87613.80 | 87621.70 | 7.0 | 231 |
166
+ | 2629438 | 2025-12-31 23:58 | 87621.60 | 87631.90 | 87603.90 | 87608.10 | 38.0 | 815 |
167
+ | 2629439 | 2025-12-31 23:59 | 87608.10 | 87608.20 | 87608.10 | 87608.20 | 11.0 | 206 |
168
+
169
+ ---
170
+
171
+ ## Quick start
172
+
173
+ ```python
174
+ from huggingface_hub import hf_hub_download
175
+ import numpy as np
176
+ import pandas as pd
177
+
178
+ path = hf_hub_download(
179
+ repo_id = "ResearchRL/diffquant-data",
180
+ filename = "btcusdt_1min_2021_2025.npz",
181
+ repo_type = "dataset",
182
+ )
183
+
184
+ data = np.load(path, allow_pickle=True)
185
+ bars = data["bars"] # (2_629_440, 6) float32
186
+ ts = data["timestamps"] # Unix ms UTC
187
+
188
+ index = pd.to_datetime(ts, unit="ms", utc=True)
189
+ df = pd.DataFrame(bars, columns=list(data["columns"]), index=index)
190
+ print(df.head())
191
+ ```
192
+
193
+ ---
194
+
195
+ ## Reference pipeline: DiffQuant
196
+
197
+ The dataset is designed to be used with the DiffQuant data pipeline.
198
+ Below is a precise description of the transformations applied — included
199
+ here so the dataset can be used reproducibly outside DiffQuant as well.
200
+
201
+ ### Step 1 — Aggregation
202
+
203
+ Resample from 1-min to any target resolution using clock-aligned buckets.
204
+ `origin="epoch"` ensures bars always land on exact boundaries (`:05`, `:10`, …).
205
+ Partial buckets at series edges are dropped.
206
+
207
+ ```python
208
+ from data.aggregator import aggregate
209
+ from configs.base_config import MasterConfig
210
+
211
+ cfg = MasterConfig()
212
+ cfg.data.timeframe_min = 5 # valid: {1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60}
213
+
214
+ bars_5m, ts_5m = aggregate(bars_1m, timestamps, cfg)
215
+ ```
216
+
217
+ ### Step 2 — Feature engineering
218
+
219
+ Applied channel-by-channel after aggregation. The first bar is always dropped
220
+ (no prior close available for log-return computation).
221
+
222
+ | Channel | Transformation |
223
+ |---|---|
224
+ | open, high, low, close | `log(price_t / close_{t-1})` — log-return vs previous bar close |
225
+ | volume | `volume_t / global_mean(volume)` — ratio to mean of the full aggregated series |
226
+ | num_trades | `num_trades_t / global_mean(num_trades)` — same |
227
+ | typical_price (optional) | `log(((H+L+C)/3)_t / close_{t-1})` |
228
+ | time features (optional) | `[sin_hour, cos_hour, sin_dow, cos_dow]` — cyclic UTC encoding |
229
+
230
+ ### Step 3 — Feature presets
231
+
232
+ ```python
233
+ cfg.data.preset = "ohlc" # 4 channels
234
+ cfg.data.preset = "ohlcv" # 5 channels (default)
235
+ cfg.data.preset = "full" # 6 channels
236
+
237
+ cfg.data.add_typical_price = True # +1 channel
238
+ cfg.data.add_time_features = True # +4 channels
239
+
240
+ # Or fully custom:
241
+ cfg.data.preset = "custom"
242
+ cfg.data.feature_columns = ["close", "volume"]
243
+ ```
244
+
245
+ ### Step 4 — Temporal splits (DiffQuant defaults)
246
+
247
+ ```
248
+ Train : 2021-01-01 → 2025-03-31 (~4.25 years)
249
+ Val : 2025-04-01 → 2025-06-30 (3 months)
250
+ Test : 2025-07-01 → 2025-09-30 (3 months)
251
+ Backtest : 2025-10-01 → 2025-12-31 (3 months)
252
+ ```
253
+
254
+ Boundaries are fully configurable via `SplitConfig`.
255
+
256
+ ### Step 5 — Full pipeline one-liner
257
+
258
+ ```python
259
+ from data.pipeline import load_or_build
260
+ from configs.base_config import MasterConfig
261
+
262
+ cfg = MasterConfig()
263
+ splits = load_or_build("btcusdt_1min_2021_2025.npz", cfg, cache_dir="data_cache/")
264
+
265
+ # splits["train"]["full_sequences"] — (N, ctx+hor, F) sliding windows for training
266
+ # splits["val"]["raw_features"] — continuous array for walk-forward evaluation
267
+ ```
268
+
269
+ Results are MD5-hashed and cached on disk. Cache is invalidated automatically
270
+ when the config changes (timeframe, preset, split boundaries, feature flags).
271
+
272
+ ---
273
+
274
+ ## Project context
275
+
276
+ This dataset is the data foundation for **DiffQuant**, a research framework
277
+ studying direct optimisation of trading objectives:
278
+
279
+ > In standard ML trading pipelines, models are trained on proxy objectives —
280
+ > MSE for price prediction, TD-error for RL — evaluated indirectly through
281
+ > downstream trading logic. DiffQuant studies a tighter formulation: position
282
+ > generation, transaction costs, and portfolio path interact directly with the
283
+ > Sharpe ratio as the training objective through a differentiable simulator.
284
+
285
+ **Key references:**
286
+
287
+ - Buehler, H., Gonon, L., Teichmann, J., Wood, B. (2019). *Deep Hedging.*
288
+ Quantitative Finance, 19(8). [`arXiv:1802.03042`](https://arxiv.org/abs/1802.03042)
289
+ — foundational framework for end-to-end differentiable financial objectives.
290
+
291
+ - Moody, J., Saffell, M. (2001). *Learning to Trade via Direct Reinforcement.*
292
+ IEEE Transactions on Neural Networks, 12(4).
293
+ — original formulation of direct PnL optimisation as a training objective.
294
+
295
+ - Khubiev, K., Semenov, M., Podlipnova, I., Khubieva, D. (2026).
296
+ *Finance-Grounded Optimization For Algorithmic Trading.*
297
+ [`arXiv:2509.04541`](https://arxiv.org/abs/2509.04541)
298
+ — closest parallel work on financial loss functions for return prediction.
299
+
300
+ 🔗 **DiffQuant pipeline:** code release planned.
301
+
302
+ ---
303
+
304
+ ## Citation
305
+
306
+ ```bibtex
307
+ @dataset{Kolesnikov2026diffquant_data,
308
+ author = {Kolesnikov, Yuriy},
309
+ title = {{BTCUSDT} 1-Min Futures — 5-Year Research Dataset (2021--2025)},
310
+ year = {2026},
311
+ publisher = {Hugging Face},
312
+ url = {https://huggingface.co/datasets/ResearchRL/diffquant-data},
313
+ }
314
+ ```