Closed brandonros closed 1 year ago
my first guess is the maturity
For example, for an option that expires in 30 days, the Black-Scholes time to expiration input is 30/365 = 0.0822 or 8.22%.
should be more like this
fn days_to_expire_to_maturity(days_to_expire: f64) -> f64 {
return (days_to_expire / 365.5);
}
fn main() {
let option_price = 10.74;
let underlying_price = 380.13; // SPY
let strike = 380.0;
let rate = 0.03938; // 10 year
let maturity = days_to_expire_to_maturity(23.0); // 23 days to expiration (2022-10-27 -> 2022-11-18)
let iv = black_scholes::call_iv(
option_price,
underlying_price,
strike,
rate,
maturity
).unwrap();
println!("{}", iv);
}
$ cargo run
Compiling options-rs v0.1.0 (/Users/brandonros/Desktop/options-rs)
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
Running `target/debug/options-rs`
0.26844376511258566
much better, thanks, sorry for the noise