MaximumLeverage Goooddy commited on
Commit
873f31e
·
0 Parent(s):

Duplicate from Goooddy/crypto-lob-stream

Browse files

Co-authored-by: Goodness Chibueze Kalu <Goooddy@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.avro filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
7
+ *.ftz filter=lfs diff=lfs merge=lfs -text
8
+ *.gz filter=lfs diff=lfs merge=lfs -text
9
+ *.h5 filter=lfs diff=lfs merge=lfs -text
10
+ *.joblib filter=lfs diff=lfs merge=lfs -text
11
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
13
+ *.mds filter=lfs diff=lfs merge=lfs -text
14
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
+ *.model filter=lfs diff=lfs merge=lfs -text
16
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
17
+ *.npy filter=lfs diff=lfs merge=lfs -text
18
+ *.npz filter=lfs diff=lfs merge=lfs -text
19
+ *.onnx filter=lfs diff=lfs merge=lfs -text
20
+ *.ot filter=lfs diff=lfs merge=lfs -text
21
+ *.parquet filter=lfs diff=lfs merge=lfs -text
22
+ *.pb filter=lfs diff=lfs merge=lfs -text
23
+ *.pickle filter=lfs diff=lfs merge=lfs -text
24
+ *.pkl filter=lfs diff=lfs merge=lfs -text
25
+ *.pt filter=lfs diff=lfs merge=lfs -text
26
+ *.pth filter=lfs diff=lfs merge=lfs -text
27
+ *.rar filter=lfs diff=lfs merge=lfs -text
28
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
29
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
31
+ *.tar filter=lfs diff=lfs merge=lfs -text
32
+ *.tflite filter=lfs diff=lfs merge=lfs -text
33
+ *.tgz filter=lfs diff=lfs merge=lfs -text
34
+ *.wasm filter=lfs diff=lfs merge=lfs -text
35
+ *.xz filter=lfs diff=lfs merge=lfs -text
36
+ *.zip filter=lfs diff=lfs merge=lfs -text
37
+ *.zst filter=lfs diff=lfs merge=lfs -text
38
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
39
+ # Audio files - uncompressed
40
+ *.pcm filter=lfs diff=lfs merge=lfs -text
41
+ *.sam filter=lfs diff=lfs merge=lfs -text
42
+ *.raw filter=lfs diff=lfs merge=lfs -text
43
+ # Audio files - compressed
44
+ *.aac filter=lfs diff=lfs merge=lfs -text
45
+ *.flac filter=lfs diff=lfs merge=lfs -text
46
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
47
+ *.ogg filter=lfs diff=lfs merge=lfs -text
48
+ *.wav filter=lfs diff=lfs merge=lfs -text
49
+ # Image files - uncompressed
50
+ *.bmp filter=lfs diff=lfs merge=lfs -text
51
+ *.gif filter=lfs diff=lfs merge=lfs -text
52
+ *.png filter=lfs diff=lfs merge=lfs -text
53
+ *.tiff filter=lfs diff=lfs merge=lfs -text
54
+ # Image files - compressed
55
+ *.jpg filter=lfs diff=lfs merge=lfs -text
56
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
57
+ *.webp filter=lfs diff=lfs merge=lfs -text
58
+ # Video files - compressed
59
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
60
+ *.webm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ task_categories:
4
+ - time-series-forecasting
5
+ tags:
6
+ - finance
7
+ - cryptocurrency
8
+ - order-book
9
+ - market-microstructure
10
+ - high-frequency
11
+ pretty_name: Binance BTC/ETH/SOL L2 Order Book & Trades
12
+ configs:
13
+ - config_name: depth
14
+ data_files: "depth/binance/*/*.parquet"
15
+ - config_name: trades
16
+ data_files: "trades/binance/*/*.parquet"
17
+ - config_name: snapshots
18
+ data_files: "snapshots/binance/*/*.parquet"
19
+ ---
20
+
21
+ # Binance BTC/ETH/SOL - L2 Order Book, Trades & Snapshots
22
+
23
+ Continuous Level-2 order book (depth diffs), trades, and periodic full-book
24
+ snapshots for BTCUSDT, ETHUSDT, and SOLUSDT, captured from Binance's public
25
+ WebSocket feeds with [`crypto-lob-stream`](https://pypi.org/project/crypto-lob-stream/)
26
+ and published monthly as a contribution to open market-microstructure research.
27
+
28
+ Full depth-of-book data is paywalled or licensed for most asset classes; crypto
29
+ is the exception, where the raw feeds are genuinely public. This dataset exists
30
+ to lower that data barrier for independent researchers and students.
31
+
32
+ ## Layout
33
+
34
+ ```
35
+ depth/binance/{ASSET}/YYYY-MM.parquet # order book diff events
36
+ trades/binance/{ASSET}/YYYY-MM.parquet # executed trades
37
+ snapshots/binance/{ASSET}/*.parquet # full-book anchors for replay
38
+ ```
39
+
40
+ Files are Snappy-compressed Parquet, compacted to one file per month per asset,
41
+ and carry an explicit `exchange` column - i.e. the native schema of the
42
+ `crypto-lob-stream` package, so its reconstruction helper works directly.
43
+
44
+ ## Reconstructing the order book
45
+
46
+ Depth rows are diffs, not a standing book. Replay a snapshot plus every
47
+ subsequent diff, pruning to your intended depth after each update, to rebuild
48
+ the book at any instant.
49
+
50
+ Heads up: a naive replay (only dropping a level when `quantity` hits `0`)
51
+ accumulates "ghost levels" over time: price levels that fell out of scope
52
+ but were never explicitly zeroed out, so they just sit there looking real.
53
+ There's a nasty failure mode worth knowing about: a replay can be
54
+ completely gap-free and still end up wrong.
55
+
56
+ Oliver Zehentleitner ran a 25.10-hour BTCUSDT test on this exact problem
57
+ (gap-free, sequence-validated, no synthetic gaps at all) and found that a
58
+ naive, unpruned cache grew to 20,758 bid levels and 9,116 ask levels. At
59
+ the final audit against REST, only 24.09% of those bid levels and 39.82%
60
+ of the ask levels still matched. A pruned cache, checked the same way,
61
+ held steady at 1,011 bids / 1,078 asks with 87.83% / 91.74% matching REST.
62
+ So don't skip the pruning step, sequence continuity alone doesn't stop
63
+ stale levels from piling up. [Full writeup here.](https://dev.to/oliverzehentleitner/your-binance-l2-order-book-can-be-gap-free-and-still-be-wrong-1kk8)
64
+
65
+ The [`crypto-lob-stream`](https://pypi.org/project/crypto-lob-stream/)
66
+ package (source: [GitHub](https://github.com/Goodie-Goody/crypto_lob_stream_pypi))
67
+ handles this for you and prunes automatically:
68
+
69
+ ```python
70
+ pip install crypto-lob-stream
71
+
72
+ from crypto_lob_stream import reconstruct
73
+
74
+ # point this at the folder containing trades/, depth/, snapshots/
75
+ book = reconstruct("./", exchange="binance", asset="BTCUSDT")
76
+ bids, asks = book.top(n=10) # best 10 levels per side, correctly pruned
77
+ ```
78
+
79
+ By default it prunes Binance books to depth 1000 (that's the depth the
80
+ snapshot REST call requests. Binance itself doesn't cap the live diff
81
+ stream, so without pruning the book can genuinely drift past that over
82
+ time). Pass `max_depth=` to override, but I wouldn't disable it.
83
+
84
+ If you're not using Python, the manual version is: load the nearest
85
+ snapshot before your target window, discard diffs at or before its
86
+ `last_update_id`, apply the rest in ascending `last_update_id` order
87
+ (each diff's `quantity` is the new total, not a delta, `0.0` means
88
+ remove), and prune back to your intended depth after every single update.
89
+ That last step is the one that actually prevents the ghost-level problem
90
+ above.
91
+
92
+ ## Schemas
93
+
94
+ **trades**
95
+
96
+ | Field | Type | Notes |
97
+ |---|---|---|
98
+ | timestamp_ms | int64 | Event time (Unix ms) |
99
+ | exchange | string | `binance` |
100
+ | asset | string | e.g. BTCUSDT |
101
+ | trade_id | int64 | Exchange trade ID |
102
+ | price | float64 | |
103
+ | quantity | float64 | |
104
+ | buyer_maker | bool | True if the buyer was the maker |
105
+
106
+ **depth (diff events)**
107
+
108
+ | Field | Type | Notes |
109
+ |---|---|---|
110
+ | timestamp_ms | int64 | Event/receipt time (Unix ms) |
111
+ | exchange | string | |
112
+ | asset | string | |
113
+ | side | string | bid or ask |
114
+ | price | float64 | |
115
+ | quantity | float64 | `0.0` means the level was removed |
116
+ | first_update_id | int64 | Sequence start |
117
+ | last_update_id | int64 | Sequence number for replay ordering |
118
+
119
+ **snapshots**
120
+
121
+ | Field | Type | Notes |
122
+ |---|---|---|
123
+ | timestamp_ms | int64 | Snapshot time (Unix ms) |
124
+ | exchange | string | |
125
+ | asset | string | |
126
+ | side | string | bid or ask |
127
+ | price | float64 | |
128
+ | quantity | float64 | |
129
+ | last_update_id | int64 | Snapshot anchor for diff replay |
130
+
131
+ ## Coverage & limitations
132
+
133
+ - **Reconstructable from 2026-06-03 onward.** Every depth file here carries
134
+ `first_update_id` / `last_update_id`, so the diff sequence can be replayed
135
+ against the snapshots. Earlier data lacks sequence ids and is not published.
136
+ - Reconstruct each market on its own - never merge books across exchanges.
137
+ - Check the diff sequence for continuity before replaying across a boundary.
138
+
139
+ ## Known gaps
140
+
141
+ - **July 2026:** capture paused ~2026-07-05 20:56 to ~21:39 UTC (~43 min) for
142
+ all three symbols, across depth and trades, due to a host restart. A fresh
143
+ snapshot was written on reconnect, so books before and after the gap
144
+ reconstruct cleanly - treat the gap as a hard reset and do not replay a diff
145
+ sequence across it.
146
+
147
+ ## Where this comes from
148
+
149
+ Collected with [`crypto-lob-stream`](https://pypi.org/project/crypto-lob-stream/)
150
+ ([GitHub](https://github.com/Goodie-Goody/crypto_lob_stream_pypi), MIT licensed,
151
+ same as this dataset), a package I built for streaming L2 order book, trade,
152
+ and funding data off public exchange WebSocket feeds straight to Parquet.
153
+ Binance/BTC/ETH/SOL is what's published here, but the package also supports
154
+ Coinbase, OKX, Kraken, and Bybit (spot and perps) if you want to collect your
155
+ own. Issues and PRs welcome on the repo.
depth/binance/BTCUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6339adc0edfae9b62bc49f2056c8596bb431f58e99c516cba9916063a15470d
3
+ size 385932069
depth/binance/BTCUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a5d581db337201f0a2446ee7d59baaf1e5c54363f9760b52759b7dc6ac1779c
3
+ size 317605448
depth/binance/ETHUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4dac7a72f2d4550c7bc0729d579ddbb354be0269981c326a0de7c688dabc0c69
3
+ size 312208107
depth/binance/ETHUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cdff0ddc44157fa7d14ca04faaa228760b8f67c7057f25bcf4acd420f9cb9a42
3
+ size 282650449
depth/binance/SOLUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff1e76b1613f04c44f7578a85f97680cf038ea29dd962125f07ba3171e7d4dd9
3
+ size 110365893
depth/binance/SOLUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d42dc44d9b7ca2bfdd45dfc152f4ec1ba5d873016e3f717fd0e7ee36900b23c5
3
+ size 82871592
snapshots/binance/BTCUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b4579b4fb8a06fe46c6f11a824c42490fb4b7833ecb8e1beb53b014969e6cdb
3
+ size 299002
snapshots/binance/BTCUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c6e474ff14fba5f53b6f9570c6101fe841ebb75908d9809aa8dbefdeb6b5948
3
+ size 350331
snapshots/binance/ETHUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59abdba23cb34b8dbd2b305ac1a3c46d444da299ad4114daef709d3cef71b901
3
+ size 240589
snapshots/binance/ETHUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:199fb1caac486d85fe6bbaec0fd1a14d733c6b73cd6b1ab2e14aa774e64b20d2
3
+ size 294864
snapshots/binance/SOLUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdef486c0b4a5bbe24d47e042a44c95062fe62c0376da85037f3cd7a1dec9d6e
3
+ size 209068
snapshots/binance/SOLUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b640f1fe021855ed02fccfb6c9f07ea823b28031e06f28a7a9dfecc4e815f84b
3
+ size 265475
trades/binance/BTCUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b7a6cff63c4ae242a792fa42ae4dd32bbf5026de59a33a9bbb9b2f1e95af9339
3
+ size 59876309
trades/binance/BTCUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2bc249b2dc2347c93baadd1610726c57ab7acc15b167523c441859087ba15f6c
3
+ size 48969364
trades/binance/ETHUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f3505f4aef1442d68cf73cd108fe690d742303f04f657765c4745de8c823869
3
+ size 55687560
trades/binance/ETHUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc76da888e1b504f3d34629a1e9971294663f48d1d7729f2518767d058392a3c
3
+ size 39784029
trades/binance/SOLUSDT/2026-06.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3d4b599722f58f491f2f32c803268c760ae8693bd01f3105d7646724972e22aa
3
+ size 15615496
trades/binance/SOLUSDT/2026-07.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34b3041827d95fd9dbc403bc7eb7191adde888668a10f8088a46f9e78f3b1556
3
+ size 10528543