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.

Metadata

Release files for blackscholes 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blackscholes 0.2.2
File Size Uploaded
blackscholes-0.2.2.tar.gz 17.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for blackscholes 0.2.2
File Interpreter ABI Platform
blackscholes-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.4 kB

Release files / blackscholes-0.2.2.tar.gz

Download URL blackscholes-0.2.2.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7ccde4df6ea76ad3e3bb7ea9183b4d75569124c77f31c679b2bce7d0190385f2
BLAKE2b-256 checksum
How to use checksums
89a808d27b8253ce68f54551b16c6d2fc87e1b9caf365eac4cbd160a0984536d
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / blackscholes-0.2.2-py3-none-any.whl

Download URL blackscholes-0.2.2-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6143c25b4e8838127b904e4079650442899b2b2836c31ed2a7b429bcff30ed5
BLAKE2b-256 checksum
How to use checksums
8158f303b25670eac80bf6098acb363b8f278c63b22174d713cb7243f43b71a5
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page