lobkit 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lobkit
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Limit order book reconstruction, order-flow analytics and market-making simulation
5
5
  Author: Yousuf Hossain Shafeen
6
6
  License-Expression: MIT
@@ -170,35 +170,40 @@ simulated and live tables shows which effects are mechanical consequences of the
170
170
  and which require informed traders. Record at least 15 minutes; the script warns when there is
171
171
  too little data to say anything.
172
172
 
173
- Results for one session: BTCUSDT, 40 minutes on 2026-11-01 from 03:18 local time (76,296 quote
174
- updates, 5,813 trades). It was a quiet market: the price stayed within a 181 USDT range and the
175
- mid changed 688 times, about once every 3.5 seconds. That session is one sample, not a study, and
176
- the recording is not in the repository (market data is never committed), so treat these numbers
177
- as an illustration of the pipeline.
178
-
179
- | Result | Live, 1 s buckets | Simulated |
180
- |---|---|---|
181
- | Δmid on OFI | β = 0.221 USDT per unit, **R² = 0.56**, t = 55 | R² = 0.42 at 1 s (Study 5), 0.66 at 10 s |
182
- | Impact coefficient vs 1/depth | R² = 0.85 across depth quintiles | R² = 0.93 (10 s) |
183
- | P(next move up), imbalance < 0.1 → > 0.9 | 0.38 → 0.97, not monotone in between | monotone |
184
- | Next 1 s move from queue imbalance | out-of-sample R² 3.3% | 0.7% (next 10 s) |
185
- | Multi-level OFI, best 1 → 10 levels (5 s) | out-of-sample R² 0.50 → 0.40–0.49: no gain | 0.66 → 0.88, 1 → 5 levels (10 s) |
186
- | Micro-price vs mid, next price change | Stoikov −0.34% MSE, naive −0.32%: no real edge | Stoikov −6.6%, naive −1.3% |
173
+ Results for one session, two instruments recorded side by side: BTCUSDT and ETHUSDT, 2 hours each
174
+ on 2026-11-01 from 04:29 local time. BTCUSDT: 187,746 quote updates, 18,463 trades; the price
175
+ stayed within a 162 USDT range and the mid changed 2,176 times, about once every 3.3 seconds.
176
+ ETHUSDT: 127,805 quote updates, 14,136 trades; an 8 USDT range and 2,931 mid changes. Both books
177
+ tick in cents, so a tick is 0.13 basis points of the BTC price but 0.44 of the ETH price, and the
178
+ ETH best queues are deep (31.5 ETH on average against 2.5 BTC). That session is one sample, not a
179
+ study, and the recordings are not in the repository (market data is never committed), so treat
180
+ these numbers as an illustration of the pipeline.
181
+
182
+ | Result | BTCUSDT, 1 s buckets | ETHUSDT, 1 s buckets | Simulated |
183
+ |---|---|---|---|
184
+ | Δmid on OFI | β = 0.203 USDT per BTC, **R² = 0.59**, t = 102 | β = 0.0008 USDT per ETH, **R² = 0.70**, t = 129 | R² = 0.42 at 1 s (Study 5), 0.66 at 10 s |
185
+ | Impact coefficient vs 1/depth | R² = 0.91 across depth quintiles | R² = 0.87 | R² = 0.93 (10 s) |
186
+ | P(next move up), imbalance < 0.1 → > 0.9 | 0.09 → 0.93, monotone | 0.09 → 0.84, dips at 0.5–0.6 | monotone |
187
+ | Next 1 s move from queue imbalance | out-of-sample R² 2.0% | 4.6% | 0.7% (next 10 s) |
188
+ | Multi-level OFI, best 1 → 10 levels (5 s) | out-of-sample R² 0.33 → 0.38 | 0.45 → 0.47 | 0.66 → 0.88, 1 → 5 levels (10 s) |
189
+ | Micro-price vs mid, next price change | Stoikov −0.6% MSE, naive −0.03% | **Stoikov −10.8%**, naive −4.2% | Stoikov −6.6%, naive −1.3% |
187
190
 
188
191
  ![Binance OFI impact](https://raw.githubusercontent.com/hossainyousuf751/microstructure-lab/main/docs/binance_btcusdt_ofi_impact.png)
189
192
 
190
- **What survives contact with a real book.** The contemporaneous OFI relation is at least as
191
- strong live as in the simulator at 1-second buckets, and impact is still larger when the book is
192
- thin. Queue imbalance predicts the next move at the extremes, and on the live book it even has a
193
- little out-of-sample power over the next second.
194
-
195
- **What doesn't.** Deeper levels add nothing out of sample, while they explained a lot in the
196
- simulator. On BTCUSDT the levels behind the best quote are a cent apart and mostly small resting
197
- orders, so their flow carries little information. Neither micro-price beats the mid by more than
198
- a third of a percent. Most rows sit at a one-tick spread with the price unchanged. The 688 price
199
- changes include 323 updates where one side of the book thinned out for an instant and the spread
200
- jumped past 1 USDT (up to 10.8), and a squared-error comparison over so few moves is decided by
201
- those points. A busier session, or a robust loss, is the next step.
193
+ **What survives contact with a real book.** The contemporaneous OFI relation is stronger live
194
+ than in the simulator at 1-second buckets on both instruments, and impact is larger when the book
195
+ is thin. Queue imbalance predicts the direction of the next move at the extremes, and has a little
196
+ out-of-sample power over the next second.
197
+
198
+ **What depends on the book.** On ETHUSDT the Stoikov micro-price forecasts the next price change
199
+ with 10.8% less squared error than the mid, more than in the simulator, and the edge fades with
200
+ the horizon (4.3% after 5 moves, 0.9% after 20). On BTCUSDT it does not: −0.6%. The BTC book
201
+ often thins out for an instant: the spread was above 1 USDT (100 ticks) in 1,131 updates over 305
202
+ episodes, up to 17.4 USDT, while the ETH spread never exceeded 0.45 USDT. Those blowouts dominate
203
+ a squared-error comparison and wreck the naive micro-price (its gap to the mid has an
204
+ out-of-sample R² of −0.77 for the next second on BTC). Deeper levels add only a few points of R²
205
+ on either book, much less than in the simulator: the levels behind the best quote are a cent apart
206
+ and mostly small resting orders.
202
207
 
203
208
  ## Study 4: the market maker inside the order book
204
209
 
@@ -252,24 +257,30 @@ other venue's order flow explain, and whether either venue's flow or return pred
252
257
  known: a simulated venue B that copies venue A 300 ms late. They find the delay exactly
253
258
  (correlation 1.00 at +300 ms) and the direction: only B's next move is predictable from A.
254
259
 
255
- Same session as Study 3 (40 minutes; 76,296 Binance and 24,969 Bybit quote updates):
260
+ Same session as Study 3 (2 hours each; 187,746 Binance and 76,632 Bybit quote updates for
261
+ BTCUSDT, 127,805 and 21,344 for ETHUSDT):
256
262
 
257
263
  | Target venue | R² own OFI | R² other venue's OFI | R² both | Next 1 s from other's OFI (OOS) | Next 1 s from other's return (OOS) |
258
264
  |---|---|---|---|---|---|
259
- | Binance | 0.56 | 0.16 | 0.56 | 0.014 | 0.009 |
260
- | Bybit | 0.58 | 0.28 | 0.60 | 0.004 | 0.004 |
265
+ | Binance BTCUSDT | 0.59 | 0.23 | 0.59 | 0.059 | 0.064 |
266
+ | Bybit BTCUSDT | 0.54 | 0.33 | 0.58 | 0.002 | 0.001 |
267
+ | Binance ETHUSDT | 0.70 | 0.15 | 0.70 | 0.036 | 0.094 |
268
+ | Bybit ETHUSDT | 0.31 | 0.43 | 0.51 | 0.001 | 0.003 |
261
269
 
262
270
  ![Lead-lag](https://raw.githubusercontent.com/hossainyousuf751/microstructure-lab/main/docs/cross_venue_lead_lag.png)
263
271
 
264
- **No exploitable lead at this resolution.** Returns are most correlated at 0 ms (0.09): the
265
- venues move within the same 50 ms. Each venue's own order flow explains its price far better than
266
- the other's. Neither venue's flow or return predicts the other's next second by more than about
267
- 1% out of sample. There is more correlation at negative lags (Bybit first, summed 0.62 against
268
- 0.20 for Binance first), and it persisted after the recorder's timestamp bug was fixed (see
269
- CHANGELOG), but Bybit's price changed only 218 times, so this is a hypothesis for a longer
270
- recording, not a finding. One limitation is built in: timestamps are local receive times, so each
271
- venue's network latency to the recording machine is part of the measured lag. A lead shorter than
272
- the difference in latencies can't be seen from one machine.
272
+ **Bybit tends to move first, by tens of milliseconds.** Returns are most correlated at 0 ms (0.25
273
+ for BTCUSDT, 0.18 for ETHUSDT): most moves land on both venues within the same 50 ms. What is left
274
+ is lopsided in the same way on both instruments. The correlation at negative lags (Bybit first)
275
+ sums to 1.00 for BTCUSDT and 1.13 for ETHUSDT, against 0.26 at positive lags; the strongest
276
+ off-zero lag is Bybit 150 ms ahead on both. The regressions agree: Bybit's flow and return predict
277
+ Binance's next second (out-of-sample R² 3.6–9.4%), Binance's predict Bybit's by 0.3% or less. On
278
+ ETHUSDT, Binance's flow explains more of Bybit's price than Bybit's own flow does (0.43 against
279
+ 0.31). The earlier 40-minute session pointed the same way; two instruments over two hours make it
280
+ a consistent pattern, but still one session. One limitation is built in: timestamps are local
281
+ receive times, so each venue's network latency to the recording machine is part of the measured
282
+ lag. A lead shorter than the difference in latencies can't be told apart from a faster connection
283
+ to Bybit, and a recording from a second location is the way to check.
273
284
 
274
285
  ## Roadmap
275
286
 
@@ -130,35 +130,40 @@ simulated and live tables shows which effects are mechanical consequences of the
130
130
  and which require informed traders. Record at least 15 minutes; the script warns when there is
131
131
  too little data to say anything.
132
132
 
133
- Results for one session: BTCUSDT, 40 minutes on 2026-11-01 from 03:18 local time (76,296 quote
134
- updates, 5,813 trades). It was a quiet market: the price stayed within a 181 USDT range and the
135
- mid changed 688 times, about once every 3.5 seconds. That session is one sample, not a study, and
136
- the recording is not in the repository (market data is never committed), so treat these numbers
137
- as an illustration of the pipeline.
138
-
139
- | Result | Live, 1 s buckets | Simulated |
140
- |---|---|---|
141
- | Δmid on OFI | β = 0.221 USDT per unit, **R² = 0.56**, t = 55 | R² = 0.42 at 1 s (Study 5), 0.66 at 10 s |
142
- | Impact coefficient vs 1/depth | R² = 0.85 across depth quintiles | R² = 0.93 (10 s) |
143
- | P(next move up), imbalance < 0.1 → > 0.9 | 0.38 → 0.97, not monotone in between | monotone |
144
- | Next 1 s move from queue imbalance | out-of-sample R² 3.3% | 0.7% (next 10 s) |
145
- | Multi-level OFI, best 1 → 10 levels (5 s) | out-of-sample R² 0.50 → 0.40–0.49: no gain | 0.66 → 0.88, 1 → 5 levels (10 s) |
146
- | Micro-price vs mid, next price change | Stoikov −0.34% MSE, naive −0.32%: no real edge | Stoikov −6.6%, naive −1.3% |
133
+ Results for one session, two instruments recorded side by side: BTCUSDT and ETHUSDT, 2 hours each
134
+ on 2026-11-01 from 04:29 local time. BTCUSDT: 187,746 quote updates, 18,463 trades; the price
135
+ stayed within a 162 USDT range and the mid changed 2,176 times, about once every 3.3 seconds.
136
+ ETHUSDT: 127,805 quote updates, 14,136 trades; an 8 USDT range and 2,931 mid changes. Both books
137
+ tick in cents, so a tick is 0.13 basis points of the BTC price but 0.44 of the ETH price, and the
138
+ ETH best queues are deep (31.5 ETH on average against 2.5 BTC). That session is one sample, not a
139
+ study, and the recordings are not in the repository (market data is never committed), so treat
140
+ these numbers as an illustration of the pipeline.
141
+
142
+ | Result | BTCUSDT, 1 s buckets | ETHUSDT, 1 s buckets | Simulated |
143
+ |---|---|---|---|
144
+ | Δmid on OFI | β = 0.203 USDT per BTC, **R² = 0.59**, t = 102 | β = 0.0008 USDT per ETH, **R² = 0.70**, t = 129 | R² = 0.42 at 1 s (Study 5), 0.66 at 10 s |
145
+ | Impact coefficient vs 1/depth | R² = 0.91 across depth quintiles | R² = 0.87 | R² = 0.93 (10 s) |
146
+ | P(next move up), imbalance < 0.1 → > 0.9 | 0.09 → 0.93, monotone | 0.09 → 0.84, dips at 0.5–0.6 | monotone |
147
+ | Next 1 s move from queue imbalance | out-of-sample R² 2.0% | 4.6% | 0.7% (next 10 s) |
148
+ | Multi-level OFI, best 1 → 10 levels (5 s) | out-of-sample R² 0.33 → 0.38 | 0.45 → 0.47 | 0.66 → 0.88, 1 → 5 levels (10 s) |
149
+ | Micro-price vs mid, next price change | Stoikov −0.6% MSE, naive −0.03% | **Stoikov −10.8%**, naive −4.2% | Stoikov −6.6%, naive −1.3% |
147
150
 
148
151
  ![Binance OFI impact](https://raw.githubusercontent.com/hossainyousuf751/microstructure-lab/main/docs/binance_btcusdt_ofi_impact.png)
149
152
 
150
- **What survives contact with a real book.** The contemporaneous OFI relation is at least as
151
- strong live as in the simulator at 1-second buckets, and impact is still larger when the book is
152
- thin. Queue imbalance predicts the next move at the extremes, and on the live book it even has a
153
- little out-of-sample power over the next second.
154
-
155
- **What doesn't.** Deeper levels add nothing out of sample, while they explained a lot in the
156
- simulator. On BTCUSDT the levels behind the best quote are a cent apart and mostly small resting
157
- orders, so their flow carries little information. Neither micro-price beats the mid by more than
158
- a third of a percent. Most rows sit at a one-tick spread with the price unchanged. The 688 price
159
- changes include 323 updates where one side of the book thinned out for an instant and the spread
160
- jumped past 1 USDT (up to 10.8), and a squared-error comparison over so few moves is decided by
161
- those points. A busier session, or a robust loss, is the next step.
153
+ **What survives contact with a real book.** The contemporaneous OFI relation is stronger live
154
+ than in the simulator at 1-second buckets on both instruments, and impact is larger when the book
155
+ is thin. Queue imbalance predicts the direction of the next move at the extremes, and has a little
156
+ out-of-sample power over the next second.
157
+
158
+ **What depends on the book.** On ETHUSDT the Stoikov micro-price forecasts the next price change
159
+ with 10.8% less squared error than the mid, more than in the simulator, and the edge fades with
160
+ the horizon (4.3% after 5 moves, 0.9% after 20). On BTCUSDT it does not: −0.6%. The BTC book
161
+ often thins out for an instant: the spread was above 1 USDT (100 ticks) in 1,131 updates over 305
162
+ episodes, up to 17.4 USDT, while the ETH spread never exceeded 0.45 USDT. Those blowouts dominate
163
+ a squared-error comparison and wreck the naive micro-price (its gap to the mid has an
164
+ out-of-sample R² of −0.77 for the next second on BTC). Deeper levels add only a few points of R²
165
+ on either book, much less than in the simulator: the levels behind the best quote are a cent apart
166
+ and mostly small resting orders.
162
167
 
163
168
  ## Study 4: the market maker inside the order book
164
169
 
@@ -212,24 +217,30 @@ other venue's order flow explain, and whether either venue's flow or return pred
212
217
  known: a simulated venue B that copies venue A 300 ms late. They find the delay exactly
213
218
  (correlation 1.00 at +300 ms) and the direction: only B's next move is predictable from A.
214
219
 
215
- Same session as Study 3 (40 minutes; 76,296 Binance and 24,969 Bybit quote updates):
220
+ Same session as Study 3 (2 hours each; 187,746 Binance and 76,632 Bybit quote updates for
221
+ BTCUSDT, 127,805 and 21,344 for ETHUSDT):
216
222
 
217
223
  | Target venue | R² own OFI | R² other venue's OFI | R² both | Next 1 s from other's OFI (OOS) | Next 1 s from other's return (OOS) |
218
224
  |---|---|---|---|---|---|
219
- | Binance | 0.56 | 0.16 | 0.56 | 0.014 | 0.009 |
220
- | Bybit | 0.58 | 0.28 | 0.60 | 0.004 | 0.004 |
225
+ | Binance BTCUSDT | 0.59 | 0.23 | 0.59 | 0.059 | 0.064 |
226
+ | Bybit BTCUSDT | 0.54 | 0.33 | 0.58 | 0.002 | 0.001 |
227
+ | Binance ETHUSDT | 0.70 | 0.15 | 0.70 | 0.036 | 0.094 |
228
+ | Bybit ETHUSDT | 0.31 | 0.43 | 0.51 | 0.001 | 0.003 |
221
229
 
222
230
  ![Lead-lag](https://raw.githubusercontent.com/hossainyousuf751/microstructure-lab/main/docs/cross_venue_lead_lag.png)
223
231
 
224
- **No exploitable lead at this resolution.** Returns are most correlated at 0 ms (0.09): the
225
- venues move within the same 50 ms. Each venue's own order flow explains its price far better than
226
- the other's. Neither venue's flow or return predicts the other's next second by more than about
227
- 1% out of sample. There is more correlation at negative lags (Bybit first, summed 0.62 against
228
- 0.20 for Binance first), and it persisted after the recorder's timestamp bug was fixed (see
229
- CHANGELOG), but Bybit's price changed only 218 times, so this is a hypothesis for a longer
230
- recording, not a finding. One limitation is built in: timestamps are local receive times, so each
231
- venue's network latency to the recording machine is part of the measured lag. A lead shorter than
232
- the difference in latencies can't be seen from one machine.
232
+ **Bybit tends to move first, by tens of milliseconds.** Returns are most correlated at 0 ms (0.25
233
+ for BTCUSDT, 0.18 for ETHUSDT): most moves land on both venues within the same 50 ms. What is left
234
+ is lopsided in the same way on both instruments. The correlation at negative lags (Bybit first)
235
+ sums to 1.00 for BTCUSDT and 1.13 for ETHUSDT, against 0.26 at positive lags; the strongest
236
+ off-zero lag is Bybit 150 ms ahead on both. The regressions agree: Bybit's flow and return predict
237
+ Binance's next second (out-of-sample R² 3.6–9.4%), Binance's predict Bybit's by 0.3% or less. On
238
+ ETHUSDT, Binance's flow explains more of Bybit's price than Bybit's own flow does (0.43 against
239
+ 0.31). The earlier 40-minute session pointed the same way; two instruments over two hours make it
240
+ a consistent pattern, but still one session. One limitation is built in: timestamps are local
241
+ receive times, so each venue's network latency to the recording machine is part of the measured
242
+ lag. A lead shorter than the difference in latencies can't be told apart from a faster connection
243
+ to Bybit, and a recording from a second location is the way to check.
233
244
 
234
245
  ## Roadmap
235
246
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lobkit"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "Limit order book reconstruction, order-flow analytics and market-making simulation"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lobkit
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Limit order book reconstruction, order-flow analytics and market-making simulation
5
5
  Author: Yousuf Hossain Shafeen
6
6
  License-Expression: MIT
@@ -170,35 +170,40 @@ simulated and live tables shows which effects are mechanical consequences of the
170
170
  and which require informed traders. Record at least 15 minutes; the script warns when there is
171
171
  too little data to say anything.
172
172
 
173
- Results for one session: BTCUSDT, 40 minutes on 2026-11-01 from 03:18 local time (76,296 quote
174
- updates, 5,813 trades). It was a quiet market: the price stayed within a 181 USDT range and the
175
- mid changed 688 times, about once every 3.5 seconds. That session is one sample, not a study, and
176
- the recording is not in the repository (market data is never committed), so treat these numbers
177
- as an illustration of the pipeline.
178
-
179
- | Result | Live, 1 s buckets | Simulated |
180
- |---|---|---|
181
- | Δmid on OFI | β = 0.221 USDT per unit, **R² = 0.56**, t = 55 | R² = 0.42 at 1 s (Study 5), 0.66 at 10 s |
182
- | Impact coefficient vs 1/depth | R² = 0.85 across depth quintiles | R² = 0.93 (10 s) |
183
- | P(next move up), imbalance < 0.1 → > 0.9 | 0.38 → 0.97, not monotone in between | monotone |
184
- | Next 1 s move from queue imbalance | out-of-sample R² 3.3% | 0.7% (next 10 s) |
185
- | Multi-level OFI, best 1 → 10 levels (5 s) | out-of-sample R² 0.50 → 0.40–0.49: no gain | 0.66 → 0.88, 1 → 5 levels (10 s) |
186
- | Micro-price vs mid, next price change | Stoikov −0.34% MSE, naive −0.32%: no real edge | Stoikov −6.6%, naive −1.3% |
173
+ Results for one session, two instruments recorded side by side: BTCUSDT and ETHUSDT, 2 hours each
174
+ on 2026-11-01 from 04:29 local time. BTCUSDT: 187,746 quote updates, 18,463 trades; the price
175
+ stayed within a 162 USDT range and the mid changed 2,176 times, about once every 3.3 seconds.
176
+ ETHUSDT: 127,805 quote updates, 14,136 trades; an 8 USDT range and 2,931 mid changes. Both books
177
+ tick in cents, so a tick is 0.13 basis points of the BTC price but 0.44 of the ETH price, and the
178
+ ETH best queues are deep (31.5 ETH on average against 2.5 BTC). That session is one sample, not a
179
+ study, and the recordings are not in the repository (market data is never committed), so treat
180
+ these numbers as an illustration of the pipeline.
181
+
182
+ | Result | BTCUSDT, 1 s buckets | ETHUSDT, 1 s buckets | Simulated |
183
+ |---|---|---|---|
184
+ | Δmid on OFI | β = 0.203 USDT per BTC, **R² = 0.59**, t = 102 | β = 0.0008 USDT per ETH, **R² = 0.70**, t = 129 | R² = 0.42 at 1 s (Study 5), 0.66 at 10 s |
185
+ | Impact coefficient vs 1/depth | R² = 0.91 across depth quintiles | R² = 0.87 | R² = 0.93 (10 s) |
186
+ | P(next move up), imbalance < 0.1 → > 0.9 | 0.09 → 0.93, monotone | 0.09 → 0.84, dips at 0.5–0.6 | monotone |
187
+ | Next 1 s move from queue imbalance | out-of-sample R² 2.0% | 4.6% | 0.7% (next 10 s) |
188
+ | Multi-level OFI, best 1 → 10 levels (5 s) | out-of-sample R² 0.33 → 0.38 | 0.45 → 0.47 | 0.66 → 0.88, 1 → 5 levels (10 s) |
189
+ | Micro-price vs mid, next price change | Stoikov −0.6% MSE, naive −0.03% | **Stoikov −10.8%**, naive −4.2% | Stoikov −6.6%, naive −1.3% |
187
190
 
188
191
  ![Binance OFI impact](https://raw.githubusercontent.com/hossainyousuf751/microstructure-lab/main/docs/binance_btcusdt_ofi_impact.png)
189
192
 
190
- **What survives contact with a real book.** The contemporaneous OFI relation is at least as
191
- strong live as in the simulator at 1-second buckets, and impact is still larger when the book is
192
- thin. Queue imbalance predicts the next move at the extremes, and on the live book it even has a
193
- little out-of-sample power over the next second.
194
-
195
- **What doesn't.** Deeper levels add nothing out of sample, while they explained a lot in the
196
- simulator. On BTCUSDT the levels behind the best quote are a cent apart and mostly small resting
197
- orders, so their flow carries little information. Neither micro-price beats the mid by more than
198
- a third of a percent. Most rows sit at a one-tick spread with the price unchanged. The 688 price
199
- changes include 323 updates where one side of the book thinned out for an instant and the spread
200
- jumped past 1 USDT (up to 10.8), and a squared-error comparison over so few moves is decided by
201
- those points. A busier session, or a robust loss, is the next step.
193
+ **What survives contact with a real book.** The contemporaneous OFI relation is stronger live
194
+ than in the simulator at 1-second buckets on both instruments, and impact is larger when the book
195
+ is thin. Queue imbalance predicts the direction of the next move at the extremes, and has a little
196
+ out-of-sample power over the next second.
197
+
198
+ **What depends on the book.** On ETHUSDT the Stoikov micro-price forecasts the next price change
199
+ with 10.8% less squared error than the mid, more than in the simulator, and the edge fades with
200
+ the horizon (4.3% after 5 moves, 0.9% after 20). On BTCUSDT it does not: −0.6%. The BTC book
201
+ often thins out for an instant: the spread was above 1 USDT (100 ticks) in 1,131 updates over 305
202
+ episodes, up to 17.4 USDT, while the ETH spread never exceeded 0.45 USDT. Those blowouts dominate
203
+ a squared-error comparison and wreck the naive micro-price (its gap to the mid has an
204
+ out-of-sample R² of −0.77 for the next second on BTC). Deeper levels add only a few points of R²
205
+ on either book, much less than in the simulator: the levels behind the best quote are a cent apart
206
+ and mostly small resting orders.
202
207
 
203
208
  ## Study 4: the market maker inside the order book
204
209
 
@@ -252,24 +257,30 @@ other venue's order flow explain, and whether either venue's flow or return pred
252
257
  known: a simulated venue B that copies venue A 300 ms late. They find the delay exactly
253
258
  (correlation 1.00 at +300 ms) and the direction: only B's next move is predictable from A.
254
259
 
255
- Same session as Study 3 (40 minutes; 76,296 Binance and 24,969 Bybit quote updates):
260
+ Same session as Study 3 (2 hours each; 187,746 Binance and 76,632 Bybit quote updates for
261
+ BTCUSDT, 127,805 and 21,344 for ETHUSDT):
256
262
 
257
263
  | Target venue | R² own OFI | R² other venue's OFI | R² both | Next 1 s from other's OFI (OOS) | Next 1 s from other's return (OOS) |
258
264
  |---|---|---|---|---|---|
259
- | Binance | 0.56 | 0.16 | 0.56 | 0.014 | 0.009 |
260
- | Bybit | 0.58 | 0.28 | 0.60 | 0.004 | 0.004 |
265
+ | Binance BTCUSDT | 0.59 | 0.23 | 0.59 | 0.059 | 0.064 |
266
+ | Bybit BTCUSDT | 0.54 | 0.33 | 0.58 | 0.002 | 0.001 |
267
+ | Binance ETHUSDT | 0.70 | 0.15 | 0.70 | 0.036 | 0.094 |
268
+ | Bybit ETHUSDT | 0.31 | 0.43 | 0.51 | 0.001 | 0.003 |
261
269
 
262
270
  ![Lead-lag](https://raw.githubusercontent.com/hossainyousuf751/microstructure-lab/main/docs/cross_venue_lead_lag.png)
263
271
 
264
- **No exploitable lead at this resolution.** Returns are most correlated at 0 ms (0.09): the
265
- venues move within the same 50 ms. Each venue's own order flow explains its price far better than
266
- the other's. Neither venue's flow or return predicts the other's next second by more than about
267
- 1% out of sample. There is more correlation at negative lags (Bybit first, summed 0.62 against
268
- 0.20 for Binance first), and it persisted after the recorder's timestamp bug was fixed (see
269
- CHANGELOG), but Bybit's price changed only 218 times, so this is a hypothesis for a longer
270
- recording, not a finding. One limitation is built in: timestamps are local receive times, so each
271
- venue's network latency to the recording machine is part of the measured lag. A lead shorter than
272
- the difference in latencies can't be seen from one machine.
272
+ **Bybit tends to move first, by tens of milliseconds.** Returns are most correlated at 0 ms (0.25
273
+ for BTCUSDT, 0.18 for ETHUSDT): most moves land on both venues within the same 50 ms. What is left
274
+ is lopsided in the same way on both instruments. The correlation at negative lags (Bybit first)
275
+ sums to 1.00 for BTCUSDT and 1.13 for ETHUSDT, against 0.26 at positive lags; the strongest
276
+ off-zero lag is Bybit 150 ms ahead on both. The regressions agree: Bybit's flow and return predict
277
+ Binance's next second (out-of-sample R² 3.6–9.4%), Binance's predict Bybit's by 0.3% or less. On
278
+ ETHUSDT, Binance's flow explains more of Bybit's price than Bybit's own flow does (0.43 against
279
+ 0.31). The earlier 40-minute session pointed the same way; two instruments over two hours make it
280
+ a consistent pattern, but still one session. One limitation is built in: timestamps are local
281
+ receive times, so each venue's network latency to the recording machine is part of the measured
282
+ lag. A lead shorter than the difference in latencies can't be told apart from a faster connection
283
+ to Bybit, and a recording from a second location is the way to check.
273
284
 
274
285
  ## Roadmap
275
286
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes