nkaz001 / hftbacktest

A high-frequency trading and market-making backtesting and trading bot 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.96k stars 384 forks source link

How to incorporate underlying coin move to make markets in some derivative? #64

Closed shreyassarda7 closed 9 months ago

shreyassarda7 commented 9 months ago

I came across this amazing project while looking for a HFT-backtesting framework. I can understand this involves a Single Asset Market-Making Model. Is there any way to incorporate some underlying asset order book and give a logic for calculating fair for derivatives?

It would be interesting to see this feature because currently, I'm just creating a time series of underlying assets on which the derivative market depends. Then getting the last timestamp from the stat.timestamp list to get underlying value to determine what jump to apply on the Derivative fair and then put bid-ask prices that are to be backtested for market-making derivative.

I think this feature should be easy to accommodate in this framework. This can make it a pretty interesting proposition backtesting market-making strategies for ETFs, Futures, or Options as well.

nkaz001 commented 9 months ago

Is what you mentioned about the way you deal with the underlying value similar to this?

If so, I think it's currently the best way to deal with it because it's computationally much cheaper if you can compute the values in advance. Running a backtest for mutiple assets in a tick-by-tick manner could be much slower.

In a branch of this repo, you can find an experimental implementation in Rust for multi-asset backtesting, even though it's not thoroughly tested.

shreyassarda7 commented 9 months ago

Hi @nkaz001, thanks for the revert. Yeah, this definitely is better than my method of slicing through pd.Series which didn't make it possible with numba. Thanks