Repository navigation
Replies: 1 comment
|
Thanks, good catch, and your fix is right. The pairing step grouped contracts by expiry and strike only, so two series that share both could overwrite each other. I added the root to the key, plus a regression test with SPX and SPXW at the same strike and expiry in mixed order. The test fails on the old code and passes with the fix. One correction on the impact. In the current app SPX and NDX come from Cboe's delayed chain, which takes Cboe's own IV or solves it from each contract's mid, and that path never runs this pairing step. So the third Friday SPX and NDX maps were not affected. The pairing step runs on the Alpaca path (SPY, QQQ and single stocks), where the same collision can happen between a stock's standard series and an adjusted series after a split or merger. The fix covers that case too. It ships in the next release. Thanks for writing it up so clearly. |
Uh oh!
There was an error while loading. Please reload this page.
Found a bug in the step that shares one IV between the call and the put at the same strike. It grouped contracts by expiration and strike only, so it couldn’t tell two different index option roots apart when they expire on the same day.
Under the model’s assumptions, a call and a put at the same strike and expiration should have the same IV. The OTM one usually has the cleaner quote, so the app uses its IV for both sides.
For SPX, two separate option series can expire on the same date:
SPX: the monthly contract, settled at the open (AM) on the third Friday.
SPXW: the weekly or daily contract, settled at the close (PM). There’s also one on the third Friday.
NDX and NDXP work the same way. On the third Friday, the SPX 6700 call and the SPXW 6700 call had the same expiration and strike, so they landed in the same group. Each new contract replaced the earlier one of the same type, which mixed them up:
the call slot could hold the SPX call and the put slot the SPXW put (or the other way round);
the out-of-the-money IV from one series was then copied onto a contract from the other series;
the contract that got bumped from the group never took part in the sharing at all.
The two series have different times to expiration, because one settles at 9:30 and the other at 4:00. Their IVs are not the same thing, so copying one onto the other gives wrong gamma and wrong GEX on monthly expiration days, the very days that carry the most open interest.
The fix
Add the root to the grouping key, so SPX and SPXW are paired separately:
The diff is two lines: the key went from (c.expiry, c.strike) to (c.root, c.expiry, c.strike), and the loop that unpacks it changed to match.
All reactions