#finance #option #pricing #blackscholes #option-pricing

blackscholes

Black-Scholes option pricing model calculator

14 releases (5 breaking)

0.17.3 Jan 17, 2023
0.17.2 Jan 16, 2023
0.16.0 Jan 16, 2023
0.13.1 Jan 9, 2023
0.10.5 Nov 21, 2022

#28 in Finance

Download history 115/week @ 2022-11-16 16/week @ 2022-11-23 10/week @ 2022-11-30 5/week @ 2022-12-14 1/week @ 2022-12-21 43/week @ 2022-12-28 48/week @ 2023-01-04 104/week @ 2023-01-11 42/week @ 2023-01-18 20/week @ 2023-01-25

220 downloads per month

MIT license

30KB
406 lines

blackscholes

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

Includes all first, second, and third order Greeks.

Usage

View the docs for usage and examples.

TODO

  • Finish doc tests
  • Finish unit tests
  • Add all second order greeks
  • Add all third order greeks
  • Add proper error handling rather than panicking
  • Organize traits into seperate files
  • Add Black76 (plan to create another package for this)

Other packages available:
Python: Pypi
WASM: npm


lib.rs:

blackscholes

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

Provides methods for pricing options, calculating implied volatility, and calculating the first, second, and third order Greeks.

Example:

use blackscholes::{Inputs, OptionType, Pricing};
let inputs = Inputs::new(OptionType::Call, 100.0, 100.0, None, 0.05, 0.2, 20.0/365.25, Some(0.2));
let price: f32 = inputs.calc_price().unwrap();

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

Dependencies

~4.5MB
~88K SLoC