Closed avhz closed 4 months ago
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.
@avhz I also found a chapter in implementing quantlib. I'm reading, we will see soon.
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.
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!
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.
@yfnaji yeah you can take it for sure!
@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
@avhz thanks for bringing this to my attention - I am currently investigating and will update as soon as I find something
I'd take this one. Do you have some references for the implementation?