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 357 forks source link

Feat: Ability to import snapshots up to orderbook level L #113

Closed ian-wazowski closed 1 month ago

ian-wazowski commented 1 month ago

In #112, I decided to give a little more thought to functions that take snapshots in BTreeMarketDepth, FusedHashMapMarketDepth, and HashMapMarketDepth because the cost of copying the Vec is too high.

However, since ROIVectorMarketDepth is internally managed by depth: Vec<f64>, it can be cost-effectively fetched via slice.

Therefore, why not guide users who use the ability to take snapshots down to order book level L to use the performance-optimised ROIVectorMarketDepth?

Why not have an expensive implementation inside BTreeMarketDepth, FusedHashMapMarketDepth, and HashMapMarketDepth?

Translated with www.DeepL.com/Translator (free version)

nkaz001 commented 1 month ago

As the name suggests, ROIVectorMarketDepth focuses on a specific range of the market depth. Therefore, you need to set your Range of Interest, which is usually around the mid-price. On the other hand, HashMapMarketDepth maintains the full market depth information. Please see the Working with Market Depth and Trades. The following tutorials also use ROIVectorMarketDepth.

bohblue2 commented 1 month ago

As the name suggests, ROIVectorMarketDepth focuses on a specific range of the market depth. Therefore, you need to set your Range of Interest, which is usually around the mid-price. On the other hand, HashMapMarketDepth maintains the full market depth information. Please see the Working with Market Depth and Trades. The following tutorials also use ROIVectorMarketDepth.

Great! I guess I was misunderstanding the whole structure, I will refer to the example above for the part about creating partial snapshots, and focus on the other parts of the framework.

Thanks for your kind reply.