vp.finance.bs_price
The Black-Scholes price of a European option on a stock with continuous dividend yield q. An in-the-money option is priced as the out-of-the-money one plus the discounted forward intrinsic value (put-call parity).
Part of the distribution vipyr; it runs from a checkout of the
repository. Planned on PyPI as pip install vipyr.
Signature
vp.finance.bs_price(S, K, T, r, q, sigma, is_call) Parameters
- S : float, required
- K : float, required
- T : float, required
- r : float, required
- q : float, required
- sigma : float, required
- is_call : bool, required
Returns
A frozen BsPriceResult. Iterating it gives the fields below in order; it also has
params, tests, log and check().
- price : float
- The option's value, in the currency of S and K.
Raises
- TypeError
- An argument of the wrong type, or an unknown keyword.
- vipyr.VivBuildError
- An ImportError: no C compiler, or the program's C does not build.
Examples
import vipyr as vp
r = vp.finance.bs_price(S=42.0, K=40.0, T=0.5, r=0.1, q=0.0, sigma=0.2, is_call=True)
print(r.price) # Hull's example: 4.76
assert r.check() 4.759422392871536Each example ran as written when these pages were generated, and the output shown is what it printed.
Checked against
- Reference
- The SciPy closed form on 2000 random quotes: worst relative error 1.0 × 10−13, tolerance 10−12 (examples/options/test_options.py).
Source
- Viv: examples/options/bs.viv
- The defs it reaches and the calls between them: map of the code