Open kasperlmc opened 3 months ago
version is 1.84
Crypto exchanges often experience unstable data feeds, leading to gaps in the feed that cannot always be fully recovered. This can result in incomplete market depth data, where certain price levels may not be properly updated. Consequently, the best bid may cross the best ask in the market depth, or vice versa. Since HftBacktest determines the best bid and ask from the Level 2 market depth, this can cause discrepancy.
To resolve this issue, HftBacktest adjusts by finding the best ask price above the best bid price when the best bid is updated, and finding the best bid price below the best ask price when the best ask is updated. As a result, there may be residual "afterimages" in the market depth, and these are naturally refreshed over time.
When you access the market depth, I recommend bounding the depth to the best bid and the best ask using hbt.best_bid
, hbt.best_bid_tick
, hbt.best_ask
, and hbt.best_ask_tick
. Please see Working with Market Depth and Trades tutorial.
Alright, thank you for the explanation.
I have noticed that the data for hbt.bid_depth and hbt.ask_depth seems inconsistent with hbt.best_bid and hbt.best_ask. During my examination, I found that the minimum price in hbt.ask_depth is lower than hbt.best_ask. What might be causing this discrepancy, and is there any way to resolve it?