Skip to main content

blackscholes

Python Version PyPI Downloads uv Ruff

A Black-Scholes calculator for Python that includes up to the third-order Greeks.

Supports the Black-Scholes-Merton model, Black-76 model and option structures.

There is also a graphical interface available at: https://carlo.ai/tools/blackscholes

Installation

pip install blackscholes

Examples

Input variables

S = 55.0  # Asset price of 55
K = 50.0  # Strike price of 50
T = 1.0  # 1 Year to maturity
r = 0.0025  # 0.25% Risk-free rate
sigma = 0.15  # 15% Volatility
q = 0.0 # 0% Annual Dividend Yield

Call

from blackscholes import BlackScholesCall
call = BlackScholesCall(S=S, K=K, T=T, r=r, sigma=sigma, q=q)
call.price()  ## 6.339408
call.delta()  ## 0.766407
call.spot_delta() ## 0.7683
call.charm()  ## 0.083267

Put

from blackscholes import BlackScholesPut
put = BlackScholesPut(S=S, K=K, T=T, r=r, sigma=sigma, q=q)
put.price()  ## 1.214564
put.delta()  ## -0.23359
put.spot_delta() ## -0.23417
put.charm()  ## 0.083267

Black-76

The Black-76 model is often used specifically for options and futures and bonds. blackscholes also supports this model. To see all available greeks check out section 4. The Greeks (Black-76).

Call Example

from blackscholes import Black76Call
call = Black76Call(F=55, K=50, T=1, r=0.0025, sigma=0.15)
call.price()  ## 6.2345
call.delta()  ## 0.7594
call.vomma()  ## 45.1347

Put Example

from blackscholes import Black76Put
put = Black76Put(F=55, K=50, T=1, r=0.0025, sigma=0.15)
put.price()  ## 1.2470
put.delta()  ## -0.2381
put.vomma()  ## 45.1347

Structures

blackscholes offers the following six option structures:

  • Straddle
  • Strangle
  • Butterfly
  • Iron Condor
  • Spreads
  • Iron Butterfly

All structures have a long and short version. To learn more check out section 6. Option Structures.

Long Straddle Example

from blackscholes import BlackScholesStraddleLong

straddle = BlackScholesStraddleLong(S=55, K=50, T=1.0,
                                    r=0.0025, sigma=0.15)
straddle.price()  ## 7.5539
straddle.delta()  ## 0.5328

Binary options

Binary options are also called exotic, digital or bet options. blackscholes supports Greeks for binary calls and puts.

Contributing

We very much welcome new contributions! Check out the Github Issues to see what is currently being worked on.

Also check out Contributing in the documentation to learn more about contributing to blackscholes.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blackscholes-0.2.1.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blackscholes-0.2.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file blackscholes-0.2.1.tar.gz.

File metadata

  • Download URL: blackscholes-0.2.1.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for blackscholes-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6760dde561e31fed40fb114d052caed865cc6724cf5ba7b79d4642f95a517b02
MD5 980359a4781cd8ad5aa51ee3734e353d
BLAKE2b-256 e00f350bbe53b31090bc912cc32d5228a96ec53e677d22d10280cd8862279482

See more details on using hashes here.

File details

Details for the file blackscholes-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: blackscholes-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for blackscholes-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0184b8f7fb4ae02f3f2ed2bc67e8f182a245a2c6320e503ed5437bc191657a5
MD5 6ff7a0b2a75d5c4fabf29ef519715dea
BLAKE2b-256 16a6caca465beff8262a91472d5e05bbbb9329d4c6054e7203e114ca1c5c7c32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page