Skip to content

Fix off-by-one in the Bachelier implied-volatility denominator polynomial - #315

Open
Abhayindia wants to merge 1 commit into
avhz:mainfrom
Abhayindia:fix/bachelier-iv-denominator-312
Open

Abhayindia wants to merge 1 commit into
avhz:mainfrom
Abhayindia:fix/bachelier-iv-denominator-312

Conversation

@Abhayindia

Copy link
Copy Markdown

put_iv panicked with index out of bounds: the len is 9 but the index is 9 because the denominator loop ran 1..=B.len(). The clippy pass in c9ae943 rewrote that to .skip(1), which stopped the panic but left the two inverters summing different polynomials - and both were wrong anyway. The Choi-Kim-Kwak denominator is 1 + sum_{k=1..9} b_k eta^k, so B[i] carries power i+1, not i. It's invisible at the money (eta is small, the denominator barely matters) and gets bad fast on the wings.

Round-tripping price -> iv through the model's own pricer, f=100, t=1. Before:

       k      sigma        call_iv         put_iv     call_err      put_err
    90.0       5.00     1.81823845     1.94645854      6.36e-1      6.11e-1
    90.0      10.00     6.68362009     6.72652954      3.32e-1      3.27e-1
    95.0      10.00     8.85693656     8.87351931      1.14e-1      1.13e-1
    99.0      20.00    19.97385861    19.99557600      1.31e-3      2.21e-4

After:

       k      sigma        call_iv         put_iv     call_err      put_err
    90.0       5.00     5.00000000     5.00000000     6.29e-12     6.29e-12
    90.0      10.00    10.00000000    10.00000000     3.02e-13     3.02e-13
    95.0      10.00    10.00000000    10.00000000     1.24e-15     1.24e-15
    99.0      20.00    20.00000000    20.00000000     8.88e-16     1.07e-15

Added a round-trip test over strikes and vols - it fails on master and passes with this change. The 25 pre-existing failures in finite_difference_pricer / longstaff_schwartz / sabr (#272) are untouched: 62 passed / 25 failed both before and after.

Closes #312.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Index out of bounds in Bachelier put_iv

1 participant