py_vollib.helpers

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.
========================================================================================

Submodules

Package Contents

Functions

test_binary_flag()

forward_price(S, t, r)

Calculate the forward price of an underlying asset.

Attributes

ONE_OVER_SQRT_TWO_PI

CALL

PUT

binary_flag

pdf

the probability density function

ONE_OVER_SQRT_TWO_PI = 0.3989422804014327
CALL = 'c'
PUT = 'p'
binary_flag
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 py_vollib this is replaced with 'c' and 'p'.
========================================================
>>> binary_flag['c']
1
>>> binary_flag['p']
-1
pdf

the probability density function

Parameters:

x – a continuous random variable

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