21 releases

0.10.2 May 26, 2024
0.10.1 Nov 30, 2022
0.9.0 Oct 28, 2022
0.7.1 Jan 13, 2022
0.1.2 Dec 2, 2017

#26 in Finance

Download history 456/week @ 2024-07-27 636/week @ 2024-08-03 681/week @ 2024-08-10 790/week @ 2024-08-17 635/week @ 2024-08-24 301/week @ 2024-08-31 349/week @ 2024-09-07 134/week @ 2024-09-14 394/week @ 2024-09-21 510/week @ 2024-09-28 711/week @ 2024-10-05 576/week @ 2024-10-12 818/week @ 2024-10-19 741/week @ 2024-10-26 495/week @ 2024-11-02 495/week @ 2024-11-09

2,625 downloads per month
Used in 5 crates (4 directly)

MIT license

34KB
642 lines

[lin-badge]: https://github.com/danielhstahl/black_scholes_rust/workflows/Rust/badge.svg [cov-badge]: https://coveralls.io/repos/github/danielhstahl/black_scholes_rust/badge.svg?branch=master

Linux Coveralls
![lin-badge] ![cov-badge]

black_scholes_rust

This is a simple Black Scholes option calculator written in rust. Documentation is on docs.rs.

breaking changes

The move from 0.4 to 0.5 results changed the IV api to return a Result<f64, f64> rather than an f64.

using black_scholes_rust

Put the following in your Cargo.toml:

[dependencies]
black_scholes = "0.10.1"

Import and use:

extern crate black_scholes;
let stock = 5.0;
let strike = 4.5;
let rate = 0.01;
let discount = 0.99;
let sigma = 0.3;
let maturity = 2.0;
let sqrt_maturity_sigma = sigma*maturity.sqrt();
let price = black_scholes::call_discount(
    stock, strike, discount,
    sqrt_maturity_sigma
);
//or 
let price = black_scholes::call(
    stock, strike, rate,
    sigma, maturity
);

Dependencies

~1.2–1.8MB
~40K SLoC