vollib.helpers package
Submodules
vollib.helpers.constants module
vollib.helpers.constants
A library for option pricing, implied volatility, and greek calculation. vollib is based on lets_be_rational, a Python wrapper for LetsBeRational by Peter Jaeckel as described below.
- copyright:
© 2017 Gammon Capital LLC
- 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.
========================================================================================
vollib.helpers.distributions module
vollib.helpers.distributions
A library for option pricing, implied volatility, and greek calculation. vollib is based on lets_be_rational, a Python wrapper for LetsBeRational by Peter Jaeckel as described below.
- copyright:
© 2017 Gammon Capital LLC
- 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.
========================================================================================
- vollib.helpers.distributions.CBND(x, y, rho)[source]
A function for computing bivariate normal probabilities.
Alan Genz Department of Mathematics Washington State University Pullman, WA 99164-3113 Email : alangenz@wsu.edu
This function is based on the method described by
Drezner, Z and G.O. Wesolowsky, (1990), On the computation of the bivariate normal integral, Journal of Statist. Comput. Simul. 35, pp. 101-107,
with major modifications for double precision, and for
|R|close to 1. This code was originally transelated into VBA by Graeme West
vollib.helpers.doctest_helper module
vollib.helpers.doctest_helper
A library for option pricing, implied volatility, and greek calculation. vollib is based on lets_be_rational, a Python wrapper for LetsBeRational by Peter Jaeckel as described below.
- copyright:
© 2017 Gammon Capital LLC
- 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.
========================================================================================
vollib.helpers.exceptions module
vollib.helpers.exceptions
A library for option pricing, implied volatility, and greek calculation. vollib is based on lets_be_rational, a Python wrapper for LetsBeRational by Peter Jaeckel as described below.
- copyright:
© 2017 Gammon Capital LLC
- 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.
========================================================================================
vollib.helpers.numerical_greeks module
vollib.helpers.numerical_greeks
A library for option pricing, implied volatility, and greek calculation. vollib is based on lets_be_rational, a Python wrapper for LetsBeRational by Peter Jaeckel as described below.
- copyright:
© 2017 Gammon Capital LLC
- 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 | |
+-----------+------------------------------------------------------+
======================================================================================
- vollib.helpers.numerical_greeks.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
- vollib.helpers.numerical_greeks.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
- vollib.helpers.numerical_greeks.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
- vollib.helpers.numerical_greeks.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
- vollib.helpers.numerical_greeks.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
Module contents
vollib.helpers
A library for option pricing, implied volatility, and greek calculation. vollib is based on lets_be_rational, a Python wrapper for LetsBeRational by Peter Jaeckel as described below.
- copyright:
© 2017 Gammon Capital LLC
- 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.
========================================================================================
- vollib.helpers.forward_price(S, t, r)[source]
Calculate the forward price of an underlying asset.
- Parameters:
S (float) – underlying asset price
t (float) – time to expiration in years
r (float) – risk-free interest rate
>>> S = 95 >>> t = .5 >>> r = .02 >>> F = forward_price(S,t,r) >>> pre_calculated = 95.95476587299596 >>> abs(F-pre_calculated)<.000000001 True
- vollib.helpers.pdf(x)
the probability density function
- Parameters:
x – a continuous random variable
- vollib.helpers.test_binary_flag()[source]
======================================================== Note: In "Let's be Rational," Peter Jäckel uses θ as a flag to distinguish between puts and calls. +1 represents a call, -1 represents a put. See page 1, Introduction, first paragraph. Throughout vollib this is replaced with 'c' and 'p'. ========================================================
>>> binary_flag['c'] 1 >>> binary_flag['p'] -1