Skip to content

Value American options with the Leisen-Reimer tree - #463

Merged
domokane merged 1 commit into
FinancePy-Org:masterfrom
jackiectl2:fix-leisen-reimer-american
Nov 20, 2026
Merged

domokane merged 1 commit into
FinancePy-Org:masterfrom
jackiectl2:fix-leisen-reimer-american

Conversation

@jackiectl2

Copy link
Copy Markdown
Contributor

Problem

BlackScholesAlgorithmTypes.LEISEN_REIMER can be selected for European options, but the American branch of american_value calls _value_leisen_reimer_tree, which is not defined anywhere. Any American call or put valued with the Leisen-Reimer tree fails before pricing:

from financepy.utils.date import Date
from financepy.utils.global_types import OptionTypes
from financepy.products.equity.equity_american_option import EquityAmericanOption
from financepy.market.curves.flat_discount_curve import FlatDiscountCurve
from financepy.models.black_scholes import BlackScholes
from financepy.models.bs_american_analytic import BlackScholesAlgorithmTypes

value_dt = Date(1, 1, 2016)
option = EquityAmericanOption(Date(1, 1, 2017), 50.0, OptionTypes.AMERICAN_PUT)
option.value(
    value_dt, 50.0,
    FlatDiscountCurve(value_dt, 0.06), FlatDiscountCurve(value_dt, 0.04),
    BlackScholes(0.40),
    algo_type=BlackScholesAlgorithmTypes.LEISEN_REIMER,
)
# NameError: name '_value_leisen_reimer_tree' is not defined

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_reimer helper, 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

  • Added test_american_leisen_reimer for an American call and put in tests/unit/test_equity_american_option.py. Both cases fail with the NameError without the fix and pass with it.
  • Full pytest run (Python 3.12, requirements.txt versions): 1882 passed.
  • Ran regression_test_equity_american_option.py and regression_test_model_black_scholes.py against the golden logs: 0 errors (only calculation-time warnings).
  • pylint --rcfile=.pylintrc on the two changed files: no new messages. The undefined-variable error goes away, and the test module's previously unused BlackScholesAlgorithmTypes import is now used.

I did not run the full regression script suite.

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>
@domokane
domokane merged commit dc67292 into FinancePy-Org:master Nov 20, 2026
2 checks passed
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.

2 participants