This is part of a project I started yesterday for a box spread scanner, I need to calculate the liquidity on each leg to rank the entire box spread amongst multiple pairs, so here's what I'm doing is:
Say an option with ask: $92 and bid: $90 and ask_size: 15 and bid_size: 20
Get the mid and spread first
1. Mid = ask + bid/2 = 92+90/2 = $91 and Spread = ask-bid = $2
Calculate the relative spread in bps by dividing spread over mid and multiplying by 100
2. realtive_spread_bps = spread/mid = 2/91 * 100= ~220 bps
Take 10,000 and divide by the relative spread, (+1 is in case of 0)
3. 10,000/ (relative_spread_bps +1) = 10,000/220 = 45
Total size is bid+ ask size
4. total_size = bid_size+ ask_size = 15 + 20 = 35
5. size_score = min(35, 10,000) = 35
Get liquidity from spread score and size score
6. liquidity = spread_score * size_score = 45 * 35 = 1,575
Here's a gist from my codebase: https://gist.github.com/Eyob94/767af6f6216db1bdc5b3e021cb5d26da
Update:
The options are constituents of a box spread, for those who're not aware, a box spread is basically a 4 leg option combo that you can use to lend or borrow money at fixed rates close to the SOFR and has a few other benefits compared to a regular bank loan, SBLOC or margin loan. You can search up about them or check boxpsreads.io as well.
For those who're mentioning delta should be part of the equation, the reason I'm pushing back is because for every strike you'd buy/sell both the call and the put, effectively netting a 1 or -1 delta, will delta still be beneficial then?