Crates.io | black_scholes |
lib.rs | black_scholes |
version | 0.10.2 |
source | src |
created_at | 2017-12-02 15:19:25.312952 |
updated_at | 2024-05-26 13:16:42.391774 |
description | A Black Scholes option pricing library. |
homepage | https://github.com/danielhstahl/black_scholes_rust |
repository | https://github.com/danielhstahl/black_scholes_rust |
max_upload_size | |
id | 41345 |
size | 38,437 |
Linux | Coveralls |
---|---|
This is a simple Black Scholes option calculator written in rust. Documentation is on docs.rs.
The move from 0.4 to 0.5 results changed the IV api to return a Result<f64, f64>
rather than an f64
.
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
);