zelos-alpha / demeter

Better backtest toolkit for Uniswap v3 and Aave.
https://medium.com/zelos-research
MIT License
39 stars 9 forks source link

Problem with buying some of the Deribit options #13

Closed youbrain closed 5 months ago

youbrain commented 5 months ago

Hello there. Currently, I'm working on a script that finds and buys call & put, daily options for specific price range. For example, when the date is 2024.02.15 08:00 I want to buy the nearest daily put option for price 2910. Nearest is ETH-16FEB24-2900-P.

row about this option

Code: market.buy('ETH-16FEB24-2900-P', 1)

Exception: demeter._typing.DemeterError: insufficient order to buy, required amount is 1, available amount is 0

I think that "bids" column in .csv's that you send via dropbox is not full. Otherwise, how I can buy daily put&call options for specific price range.

Thank you for your response, On the edge of a breakdown Love, Alex

32ethers commented 5 months ago

Check this picture,

image

Ask means someone are selling, bids means someone are buying

So if you want to buy option, you have to find available orders from asks.

the row you provided is

asks bids
[] [[0.0005, 10]]

So indeed there are nothing to buy.

32ethers commented 5 months ago

By the way, I check the asks and bids of ETH-16FEB24-2900-P at every hour, and find some ask price are ridiculous.

If you purchase without checking the price, The backtesting results will exhibit significant deviations.

I will consider adding some auxiliary functions to avoid this situation.

time asks bids
2024-02-15 01:00:00 [] "[[0.012, 3]]"
2024-02-15 02:00:00 [] "[[0.0255, 3]]"
2024-02-15 03:00:00 [] "[[0.023, 3]]"
2024-02-15 04:00:00 [] "[[0.018, 3]]"
2024-02-15 05:00:00 [] "[[0.021, 3]]"
2024-02-15 06:00:00 [] "[[0.0005, 10]]"
2024-02-15 07:00:00 [[15, 14]]" "[[0.0265, 17]]"
2024-02-15 08:00:00 [],"[[0.0005, 10]]"
2024-02-15 09:00:00 "[[15, 13]]" "[[0.0265, 16]]"
2024-02-15 10:00:00 "[[15, 13]]" "[[0.023, 17]]"
2024-02-15 11:00:00 "[[15, 14]]" "[[0.0185, 17]]"
2024-02-15 12:00:00 "[[15, 14]]" "[[0.0225, 17]]"
2024-02-15 13:00:00 "[[15, 13]]" "[[0.022, 16]]"
2024-02-15 14:00:00 "[[15, 13]]" "[[0.016, 17]]"
2024-02-15 15:00:00 "[[0.069, 70]]" "[[0.0005, 80]]"
2024-02-15 16:00:00 "[[0.094, 85]]" "[[0.013, 84]]"
2024-02-15 17:00:00 "[[0.092, 85]]" "[[0.0135, 85]]"
2024-02-15 18:00:00 "[[15, 14]]" "[[0.0135, 17]]"
2024-02-15 19:00:00 "[[15, 14]]" "[[0.0105, 17]]"
2024-02-15 20:00:00 "[[15, 14]]" "[[0.005, 17]]"
2024-02-15 21:00:00 "[[15, 14]]" "[[0.009, 17]]"
2024-02-15 22:00:00 "[[15, 13]]" "[[0.0215, 16]]"
2024-02-15 23:00:00 "[[15, 13]]" "[[0.0145, 16]]"
youbrain commented 5 months ago

Fine. Let's say I need to buy a pair now, call and put options. i go to Deribit, And I can buy any option on the order book. But based on the data you sent me, only 20% of that order book will be available to me when I will backtest.

Another example is how I can test buying the option “ETH-16FEB24-2900-P” when the current time and date is 2024.02.15 08:00. If I was there in real time, I could go to debit and easily buy this option, while during backtesting this option is not available to me at that time I hope you understand what I'm trying to say

32ethers commented 5 months ago

Alright, I think it's quite normal for there to be no orders placed at a certain moment in the options market.

After all, compared to token trading, the liquidity in option market is much lower.

For example, you can observe that the bid-ask spread (the difference between the buy 1 and sell 1 prices) is usually quite large, and there is also a significant difference between these prices and the mark price in the middle.

Of course, we cannot rule out the possibility that there might be an issue with my data. However, I trust my data because it is regularly collected from Deribit's API.

Because Deribit does not provide an API for historical order books, this issue is difficult to verify. If you have other data sources (such as Tardis), please share them with me for verification. If any issues are found, I will correct them promptly.

youbrain commented 5 months ago

Thank you, i will share with you tardis deribit data when download it