Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement finite-difference pricers. #98

Closed
avhz opened this issue Aug 26, 2023 · 9 comments · Fixed by #221
Closed

Implement finite-difference pricers. #98

avhz opened this issue Aug 26, 2023 · 9 comments · Fixed by #221
Assignees
Labels
difficult Hard or lengthy task. enhancement New feature or request help wanted Extra attention is needed

Comments

@avhz
Copy link
Owner

avhz commented Aug 26, 2023

No description provided.

@avhz avhz added enhancement New feature or request help wanted Extra attention is needed difficult Hard or lengthy task. labels Aug 26, 2023
@SimonG85
Copy link
Contributor

I'd take this one. Do you have some references for the implementation?

@avhz
Copy link
Owner Author

avhz commented Sep 18, 2023

You could try Finite Difference Computing with PDEs. It's supposed to be quite good and it's open access here.

Also might be worth having a look at QuantLib.

@SimonG85
Copy link
Contributor

@avhz I also found a chapter in implementing quantlib. I'm reading, we will see soon.

@jrinder42
Copy link

You can take a look here, specifically at the PDE_European.jl and PDE_American.jl files. I worked on this very problem a while ago, albeit, in Julia. Feel free to translate this code to Rust.

@SimonG85
Copy link
Contributor

SimonG85 commented Mar 7, 2024

You can take a look here, specifically at the PDE_European.jl and PDE_American.jl files. I worked on this very problem a while ago, albeit, in Julia. Feel free to translate this code to Rust.

Thanks. I'm a little bit busy at work but I'll take a look!

@yfnaji
Copy link
Contributor

yfnaji commented Apr 2, 2024

Hey @SimonG85

Would it be ok if I take this issue? I was able to make some progress on it. I would very happy for you to look at the PR once it is ready.

@SimonG85
Copy link
Contributor

SimonG85 commented Apr 5, 2024

@yfnaji yeah you can take it for sure!

@avhz
Copy link
Owner Author

avhz commented Apr 25, 2024

@yfnaji

In the latest commit (74a90f0), I tried ATM option tests, and there a number of failures. In particular, the explicit() method seems to have an issue.

---- instruments::options::finite_difference_pricer::tests_finite_difference_pricer::european_call_explicit stdout ----
thread 'instruments::options::finite_difference_pricer::tests_finite_difference_pricer::european_call_explicit' panicked at src/instruments/options/finite_difference_pricer.rs:503:9:

Left:           NaN, 
Right:          2.179260421286685, 
Precision:      0.000000014901161193847656

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- instruments::options::finite_difference_pricer::tests_finite_difference_pricer::american_put_explicit stdout ----
thread 'instruments::options::finite_difference_pricer::tests_finite_difference_pricer::american_put_explicit' panicked at src/instruments/options/finite_difference_pricer.rs:488:9:

Left:           54096898083232840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 
Right:          1.74684769403327, 
Precision:      0.000000014901161193847656


---- instruments::options::finite_difference_pricer::tests_finite_difference_pricer::american_call_explicit stdout ----
thread 'instruments::options::finite_difference_pricer::tests_finite_difference_pricer::american_call_explicit' panicked at src/instruments/options/finite_difference_pricer.rs:473:9:

Left:           inf, 
Right:          2.179260421286685, 
Precision:      0.000000014901161193847656


---- instruments::options::finite_difference_pricer::tests_finite_difference_pricer::european_put_explicit stdout ----
thread 'instruments::options::finite_difference_pricer::tests_finite_difference_pricer::european_put_explicit' panicked at src/instruments/options/finite_difference_pricer.rs:518:9:

Left:           NaN, 
Right:          1.691554666293824, 
Precision:      0.000000014901161193847656


---- instruments::options::finite_difference_pricer::tests_finite_difference_pricer::american_call_implicit stdout ----
thread 'instruments::options::finite_difference_pricer::tests_finite_difference_pricer::american_call_implicit' panicked at src/instruments/options/finite_difference_pricer.rs:478:9:

Left:           2.771814089100344, 
Right:          2.179260421286685, 
Precision:      0.000000014901161193847656


---- instruments::options::finite_difference_pricer::tests_finite_difference_pricer::european_call_implicit stdout ----
thread 'instruments::options::finite_difference_pricer::tests_finite_difference_pricer::european_call_implicit' panicked at src/instruments/options/finite_difference_pricer.rs:508:9:

Left:           2.771814089100344, 
Right:          2.179260421286685, 
Precision:      0.000000014901161193847656

---- instruments::options::finite_difference_pricer::tests_finite_difference_pricer::european_call_crank_nicolson stdout ----
thread 'instruments::options::finite_difference_pricer::tests_finite_difference_pricer::european_call_crank_nicolson' panicked at src/instruments/options/finite_difference_pricer.rs:513:9:

Left:           0.8579231906354501, 
Right:          2.179260421286685, 
Precision:      0.000000014901161193847656

Edit (see e5db8c0):

There also seems to be an issue with OTM Eur Call implicit() method.

explicit() also fails on OTM/ITM.

'instruments::options::finite_difference_pricer::tests_finite_difference_pricer_out_of_the_money::european_call_implicit' panicked at src/instruments/options/finite_difference_pricer.rs:758:9:

Left:           -0.41215437112011133, 
Right:          0.000001014047539618235, 
Precision:      0.000000014901161193847656

@yfnaji
Copy link
Contributor

yfnaji commented Apr 25, 2024

@avhz thanks for bringing this to my attention - I am currently investigating and will update as soon as I find something

@avhz avhz linked a pull request Jun 12, 2024 that will close this issue
@avhz avhz closed this as completed in #221 Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficult Hard or lengthy task. enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants