py_vollib.helpers.numerical_greeks
¶
A library for option pricing, implied volatility, and greek calculation. py_vollib is based on lets_be_rational, a Python wrapper for LetsBeRational by Peter Jaeckel as described below.
- copyright:
© 2023 Larry Richards
- license:
MIT, see LICENSE for more details.
About LetsBeRational:¶
The source code of LetsBeRational resides at www.jaeckel.org/LetsBeRational.7z .
========================================================================================
Copyright © 2013-2014 Peter Jäckel.
Permission to use, copy, modify, and distribute this software is freely granted,
provided that this notice is preserved.
WARRANTY DISCLAIMER
The Software is provided "as is" without warranty of any kind, either express or implied,
including without limitation any implied warranties of condition, uninterrupted use,
merchantability, fitness for a particular purpose, or non-infringement.
========================================================================================
Note about the parameter “b”:¶
======================================================================================
from Espen Gaarder Haug's
"The Complete Guide to Option Pricing Formulas," Second Edition,
page 90.
+-----------+------------------------------------------------------+
| b = r | gives the Black and Scholes (1973) stock option |
| | model |
+-----------+------------------------------------------------------+
| b = r -q | gives the Merton (1973) stock option model with |
| | continuous dividend yield q |
+-----------+------------------------------------------------------+
| b = 0 | gives the Black (1976) futures option model |
+-----------+------------------------------------------------------+
| b = 0 and | gives the Asay (1982) margined futures option model |
| r = 0 | |
+-----------+------------------------------------------------------+
======================================================================================
Warning
helpers.numerical_greeks are not meant to be used directly!
Use the functions exposed by black.greeks.numerical
, black_scholes.greeks.numerical
, and
black_scholes_merton.greeks.numerical
instead.
Module Contents¶
Functions¶
|
Calculate option delta using numerical integration. |
|
Calculate option theta using numerical integration. |
|
Calculate option vega using numerical integration. |
|
Calculate option rho using numerical integration. |
|
Calculate option gamma using numerical integration. |
Attributes¶
- dS = 0.01¶
- delta(flag, S, K, t, r, sigma, b, pricing_function)[source]¶
Calculate option delta using numerical integration.
- Parameters:
S (float) – underlying asset price
K (float) – strike price
sigma (float) – annualized standard deviation, or volatility
t (float) – time to expiration in years
r (float) – risk-free interest rate
b (float) – see above
flag (str) – ‘c’ or ‘p’ for call or put.
pricing_function (python function object) – any function returning the price of an option
- theta(flag, S, K, t, r, sigma, b, pricing_function)[source]¶
Calculate option theta using numerical integration.
- Parameters:
S (float) – underlying asset price
K (float) – strike price
sigma (float) – annualized standard deviation, or volatility
t (float) – time to expiration in years
r (float) – risk-free interest rate
b (float) – see above
flag (str) – ‘c’ or ‘p’ for call or put.
pricing_function (python function object) – any function returning the price of an option
- vega(flag, S, K, t, r, sigma, b, pricing_function)[source]¶
Calculate option vega using numerical integration.
- Parameters:
S (float) – underlying asset price
K (float) – strike price
sigma (float) – annualized standard deviation, or volatility
t (float) – time to expiration in years
r (float) – risk-free interest rate
b (float) – see above
flag (str) – ‘c’ or ‘p’ for call or put.
pricing_function (python function object) – any function returning the price of an option
- rho(flag, S, K, t, r, sigma, b, pricing_function)[source]¶
Calculate option rho using numerical integration.
- Parameters:
S (float) – underlying asset price
K (float) – strike price
sigma (float) – annualized standard deviation, or volatility
t (float) – time to expiration in years
r (float) – risk-free interest rate
b (float) – see above
flag (str) – ‘c’ or ‘p’ for call or put.
pricing_function (python function object) – any function returning the price of an option
- gamma(flag, S, K, t, r, sigma, b, pricing_function)[source]¶
Calculate option gamma using numerical integration.
- Parameters:
S (float) – underlying asset price
K (float) – strike price
sigma (float) – annualized standard deviation, or volatility
t (float) – time to expiration in years
r (float) – risk-free interest rate
b (float) – see above
flag (str) – ‘c’ or ‘p’ for call or put.
pricing_function (python function object) – any function returning the price of an option