Repository navigation
Value American options with the Leisen-Reimer tree - #463
Merged
domokane merged 1 commit intoNov 20, 2026
Merged
Conversation
BlackScholesAlgorithmTypes.LEISEN_REIMER works for European options, but the American dispatch in american_value calls _value_leisen_reimer_tree, which does not exist. EquityAmericanOption.value(..., algo_type=LEISEN_REIMER) therefore raises NameError for American calls and puts, the case the tree's early-exercise branch is written for. Call the existing _value_leisen_reimer helper, as the European dispatch already does. Add unit tests that value an American call and put with the Leisen-Reimer tree. Signed-off-by: Tianlang (Jackie) Chen <305351710+jackiectl2@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
BlackScholesAlgorithmTypes.LEISEN_REIMERcan be selected for European options, but the American branch ofamerican_valuecalls_value_leisen_reimer_tree, which is not defined anywhere. Any American call or put valued with the Leisen-Reimer tree fails before pricing:The tree itself (
leisen_reimer_tree) already handles early exercise, so this is the case it is written for.Fix
Call the existing
_value_leisen_reimerhelper, which the European branch already uses. With the parameters above, the American put is now 7.2539 (CRR tree 7.2553, finite difference 7.2536) and the American call is 8.0562 (CRR 8.0562, finite difference 8.0563).Testing
test_american_leisen_reimerfor an American call and put intests/unit/test_equity_american_option.py. Both cases fail with theNameErrorwithout the fix and pass with it.pytestrun (Python 3.12,requirements.txtversions): 1882 passed.regression_test_equity_american_option.pyandregression_test_model_black_scholes.pyagainst the golden logs: 0 errors (only calculation-time warnings).pylint --rcfile=.pylintrcon the two changed files: no new messages. The undefined-variable error goes away, and the test module's previously unusedBlackScholesAlgorithmTypesimport is now used.I did not run the full regression script suite.