Example trade
I have the following trade:
ev : T
sym : O:META250117C00320000
x : 313
p : 65.78
s : 26193
c : {235}
t : 1689617168699
q : 1743228604
value : 172297554.00
which was received via the trades channel:
Bid ask spread
As you can see, the bid and ask are not part of this record.
I'd like to find the bid ask spread at the time of that trade.
If I use the trades endpoint:
https://polygon.io/docs/options/get_v3_trades__optionsticker
I can query for quotes that are within 40 seconds of the trade:
quote time > trade time - 20 seconds
quote time < trade time + 20 seconds
Here's the call for this example:
So the time range being used here is:
Monday, July 17, 2023 11:05:48 AM time-a
Monday, July 17, 2023 11:06:08 AM time of trade
Monday, July 17, 2023 11:06:28 AM time-b
Here's the quotes I get back from the query:
The highlighted one seems to be the one closest in time to the trade.
Note however that the trade price 65.78 isn't within the range of the bid ask of that quote:
bid: 65.95
ask: 66.60
Question
So, given a trade, what's the best way to find the bid ask spread at the time of the trade?
Rationale
The goal here is to infer if it was a "bullish" or "bearish" trade.
call at ask: bullish
call at bid: bearish
put at ask: bearish
put at bid: bullish
Other approaches
Another approach to the above would be to use the quotes channel:
The issue there is that I'm only allowed to subscribe to 1000 contracts.
With the approach I described initially, I can just subscribe to all trades, and then retrieve the bid/ask for the interesting ones.
