Registry / ai-ml / py-lets-be-rational

py-lets-be-rational

JSON →
library1.0.1pypypi✓ verified 82d ago

Pure Python implementation of Peter Jaeckel's LetsBeRational, providing high-precision computation of implied volatility and option pricing using rational approximations. Current version 1.0.1, released on PyPI with no updates since 2018. Low maintenance but stable.

pip install py-lets-be-rational
INSTALL
IMPORT
SIG · PY-LETS-BE-RATIONA
P
py-lets-be-rational
ai-mlpythonv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

implied_volatility_from_a_transformed_rational_guess
from lets_be_rational import implied_volatility_from_a_transformed_rational_guess
from lets_be_rational import ImpliedVolatility
black
from lets_be_rational import black
normalised_black
from lets_be_rational import normalised_black

Computes implied volatility using Let's Be Rational algorithm.

from lets_be_rational import ImpliedVolatility import math iv = ImpliedVolatility() # Example: forward=1.2, strike=1.0, time to expiry=0.5, option price=0.2, call=True sigma = iv.implied_volatility(1.2, 1.0, 0.5, 0.2, True) print(f"Implied Volatility: {sigma:.6f}")
Debug
Known issues
gotchaImport from `lets_be_rational` not `py_lets_be_rational` or `letsberational`. The package is installed as `py-lets-be-rational` but the module is named `lets_be_rational`.
fix
Use `from lets_be_rational import ImpliedVolatility`.
affects: all
gotchaThe library expects forward price, not spot price. If you pass spot, results will be wrong for nonzero interest/dividends.
fix
Compute forward = spot * exp((r - q) * T) before calling.
affects: all
gotchaOption price must be a positive float. Passing zero or negative price may cause silent errors or zero division.
fix
Ensure option price > 0.
affects: all
Upgrade
Version history
1.0.1latest on PyPI · released Apr 13, 2017
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
py-lets-be-rational — pip install py-lets-be-rational · libregistry