#python #options #option-pricing #python-packages #blackscholes

blackscholes_python

Black-Scholes option pricing model calculator

3 releases

0.10.7 Nov 21, 2022
0.10.6 Nov 21, 2022
0.10.4 Nov 21, 2022

#303 in Finance

38 downloads per month

MIT license

22KB
299 lines

blackscholes_python

This library provides an simple, lightweight, and efficient (though not heavily optimized) implementation of the Black-Scholes-Merton model for pricing European options.

This crate is compilable to a python package using pyo3 and Maturin. It features full doc and type annotations. The rust compiled python package is ~1 second slower in pricing an option to 10M iterations than the pure rust crate on a Ryzen 7600x.

Usage

Simply create an instance of the Inputs struct and call the desired method.

View the Rust docs and Python docs for usage and examples.


lib.rs:

blackscholes_python

This library provides an simple, lightweight, and efficient (though not heavily optimized) implementation of the Black-Scholes-Merton model for pricing European options.

Usage

Simply create an instance of the Inputs struct and call the desired method.

Example:

let inputs: blackscholes::Inputs = blackscholes::Inputs.new(blackscholes::OptionType::Call, 100.0, 100.0, None, 0.05, 0.02, 20.0 / 365.25, Some(0.2));
let price: f64 = inputs.calc_price();

See the Github Repo for full source code. Other implementations such as a npm WASM package and a pure Rust Crate are also available.

Dependencies

~7–13MB
~144K SLoC