A small python utility to scan Block chain for the block with given timestamp using Bisection Search
Here’s the code, I think it should be rather self explanatory, it uses bisection search to look for the block given a particular cutoff (Timestamp, not Block Number), have a look at the referenced article from http://amsi.org.au/ if you haven’t done it before.

Usage should also be apparent from unit tests:
Please note:
a. search_step_size is “initial” step size. Set this to a bigger number so things converges more quickly. When the search passes the target block for the first time, it’d automatically half the step size to recursively converge more accurately to target block.
b. if precision_sec is too small, your search may not converge.
c. Real life application? https://norman-lm-fung.medium.com/web3-py-fetching-all-transfer-events-on-single-tokens-from-a-given-timestamp-90bd6ec08e33
You can gather OI from website such as https://www.coinoptionstrack.com/options/BTC/open-interest
You can also fetch this progammatically using Deribit’s API “get_book_summary_by_instrument”.
Why would you want to do that? For starter, you can use this data and discover, if options OI from Deribit is a decent predictor of BTC/USDT price trend on next-day-basis.
“summeries” looks like this:

Notice the API will return data with expiry starting “Today”. If you need back-test and calculate correlation between Deribit OI vs BTC/USDT, you’d need accumulate this data for some duration of time.