nkaz001 / hftbacktest

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
MIT License
1.78k stars 358 forks source link

How to check our trades data? #68

Closed shreyassarda7 closed 6 months ago

shreyassarda7 commented 7 months ago

Hi @nkaz001, I have been playing with this backtesting framework for some time. I wanted to understand how can we check the trades that are executed when we are doing the backtest. What would be a standard process to debug the strategy results? Thank you

nkaz001 commented 7 months ago

You can check if an order is filled by iterating through hbt.orders dict and checking the order's status (either FILLED or PARTIALLY FILLED) before clear_inactive_order.

Please see https://hftbacktest.readthedocs.io/en/latest/tutorials/Getting%20Started.html#Clearing-inactive-orders-(FILLED,-CANCELED,-EXPIRED)

shreyassarda7 commented 7 months ago

This way we can definitely print them but wouldn't it be better to have a way in hbt to get trades? For ex. hbt.trades_executed. Or some way to get a list of trades executed or orders to be appended to some list.

nkaz001 commented 7 months ago

Adding an executed trade list slows down the backtesting process. IMO, since HFT backtest accounts for full TbT data and queue positions, it's already slower compared to candle-based backtesting. It is better to minimize features if they can be easily implemented on a user-side basis according to the user's needs.