A high-frequency trading and market-making backtesting tool in Python and Rust, which accounts for limit orders, queue positions, and latencies, utilizing full tick data for trades and order books, with real-world crypto market-making examples for Binance Futures
Normally, the local process should receive the order acceptance information first and then the order execution information, as shown below:
exch process 2 0 1 1686067320067000
local process 2 1 0 1686067320081000
filled and del 2 1686067324745000.0
local process 2 3 0 1686067324751000
current_timestamp: 1686067380023000 , order_id: 2 , order_status: FILLED , order_req: NONE , order_price: 26097.2 , exec_price: 26097.2 , order_qty: 0.001 , exec_qty: 0.001 , leave_qty: 0.0
However, due to delays, it is possible to receive the FILLED information before the NEW information. In this case, the local process may mistakenly assume that a new order has been submitted, but the exchange process does not have this order because it has already been executed.
exch process 13 0 1 1686067980057500
filled and del 13 1686067980066000.0
local process 13 3 0 1686067980072000
local process 13 1 0 1686067980092000
current_timestamp: 1686068040023000 , order_id: 13 , order_status: NEW , order_req: NONE , order_price: 26159.800000000003 , exec_price: 0.0 , order_qty: 0.001 , exec_qty: 0.0 , leave_qty: 0.001
My suggestion is that when cleaning up the inactive orders (hbt.clear_inactive_orders()), it is necessary to consider deleting the orders that receive both the NEW and FILLED information for the same ID.
Normally, the local process should receive the order acceptance information first and then the order execution information, as shown below:
However, due to delays, it is possible to receive the FILLED information before the NEW information. In this case, the local process may mistakenly assume that a new order has been submitted, but the exchange process does not have this order because it has already been executed.
My suggestion is that when cleaning up the inactive orders (
hbt.clear_inactive_orders()
), it is necessary to consider deleting the orders that receive both the NEW and FILLED information for the same ID.