Function fang_oost_option::option_pricing::fang_oost_put_gamma[][src]

pub fn fang_oost_put_gamma<'a, 'b: 'a, S>(
    num_u: usize,
    asset: f64,
    strikes: &'a [f64],
    max_strike: f64,
    rate: f64,
    t_maturity: f64,
    cf: S
) -> impl IndexedParallelIterator<Item = GraphElement> + 'a where
    S: Fn(&Complex<f64>) -> Complex<f64> + Sync + Send + 'b, 
Expand description

Returns gamma of a put for the series of strikes

Remarks

The gamma of a put is the same as the gamma of call. This function just wraps the fang_oost_call_gamma function.

Examples

extern crate num_complex;
use num_complex::Complex;
use rayon::prelude::*;
extern crate fang_oost_option;
use fang_oost_option::option_pricing;
let num_u:usize = 256;
let asset = 50.0;
let strikes = vec![75.0, 50.0, 40.0];
let rate = 0.03;
let t_maturity = 0.5;
let volatility:f64 = 0.3;
let max_strike = 5000.0; //needs to be "large enough" to integrate over space
//As an example, cf is standard diffusion
let cf = |u: &Complex<f64>| {
    ((rate-volatility*volatility*0.5)*t_maturity*u+volatility*volatility*t_maturity*u*u*0.5).exp()
};
let deltas: Vec<fang_oost::GraphElement> = option_pricing::fang_oost_put_gamma(
    num_u, asset, &strikes, max_strike,
    rate, t_maturity, &cf
).collect();