#scholes #black #stock

black_scholes

A Black Scholes option pricing library

20 unstable releases (9 breaking)

0.10.1 Nov 30, 2022
0.9.0 Oct 28, 2022
0.7.1 Jan 13, 2022
0.6.0 Apr 4, 2021
0.1.2 Dec 2, 2017

#2 in #charm

Download history 867/week @ 2023-11-03 566/week @ 2023-11-10 523/week @ 2023-11-17 598/week @ 2023-11-24 579/week @ 2023-12-01 673/week @ 2023-12-08 504/week @ 2023-12-15 128/week @ 2023-12-22 148/week @ 2023-12-29 458/week @ 2024-01-05 544/week @ 2024-01-12 427/week @ 2024-01-19 506/week @ 2024-01-26 464/week @ 2024-02-02 649/week @ 2024-02-09 847/week @ 2024-02-16

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

MIT license

34KB
638 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.8"

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.3–2MB
~43K SLoC