Skip to content

Finite difference method - #167

Merged
domokane merged 32 commits into
domokane:masterfrom
idorrington92:finite_difference
Mar 13, 2023
Merged

domokane merged 32 commits into
domokane:masterfrom
idorrington92:finite_difference

Conversation

@idorrington92

Copy link
Copy Markdown
Contributor

This PR adds a finite difference method for option pricing.

  • It is mostly based on the kBlack::fd_runner method here https://github.com/domokane/CompFin/blob/main/Week%204/xladdin/Utility/kBlack.cpp
    Main differences are that I've tried to decouple some of the methods (in particular, updating the finite difference matrix and rolling backwards/forwards are now handled separately) and I didn't make my code object oriented
  • Tests compare the output of this model to those in the C++ code linked above, as well as to other models in FinancePy. I've left in the comparisons between different models, but it might be better to just compare to a value if we trust the finite difference model now (the models only agree to 1dp, not sure how similar we expect them to be)
  • I think I've put things in logical places in the code, but happy to move things around
  • I used numba where it sped up the code, but don't have too much experience with it so it could maybe have been done better
  • I'm new to finance, so sorry if any comments/function names/variable names have used the wrong terminology!

… one test for it. Methods don't differ much from CompFin code at the moment
… one test for it. Methods don't differ much from CompFin code at the moment
@domokane

Copy link
Copy Markdown
Owner

Hi Iain
Good work ! I will look over it in the next few days.
Best
D

@domokane
domokane merged commit 5169e24 into domokane:master Mar 13, 2023
@domokane

Copy link
Copy Markdown
Owner

Hi Iain
Great start. It now needs to be wired into the equity vanilla option product as a new Black Scholes model implementation. This is especially useful for valuing an Equity American Call and Put option - it is a useful test but not so interesting for the European option as this has a closed form solution. It would be good to compare the finite difference approach to the CIR tree.
Best
D

@luciferbenz826

Copy link
Copy Markdown

Great work on adding the finite difference method for option pricing! Decoupling methods and handling matrix updates separately is a smart approach. The comparisons with C++ code and other models in Singapore GST provide a solid validation. Your efforts are appreciated, and the logical organization of the code is a plus. Looking forward to more contributions.

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.

3 participants