def BS_max_gamma(underlying, underlying_change, mtr, strike, vol):
    if underlying_change < 0:
        underlying_list = np.arange(underlying + underlying_change,
                                    underlying + 1, 1)
    else:
        underlying_list = np.arange(underlying,
                                    underlying + underlying_change + 1, 1)
    max_result = 0
    for st in underlying_list:
        b_s = BlackScholes(st, 0, 0, mtr)
        deri = b_s.BS_gamma_deri(strike, vol)
        if abs(deri) > max_result:
            max_result = abs(deri)
    return max_result
Exemplo n.º 2
0
def get_greeks(row, greek):
    b_s = BlackScholes(row['underlying_price'], 0, 0, row['mtr'])
    if greek == 'gamma':
        result = b_s.BS_gamma(row['Strike'], row['m_mid_vol'])
    elif greek == 'theta':
        result = b_s.BS_theta(row['Strike'], row['m_mid_vol'], row['CallPut'])
    elif greek == 'vega':
        result = b_s.BS_vega(row['Strike'], row['m_mid_vol'])
    elif greek == 'delta':
        result = b_s.BS_delta(row['Strike'], row['m_mid_vol'], row['CallPut'])
    elif greek == 'vanna':
        result = b_s.BS_vanna(row['Strike'], row['m_mid_vol'])
    elif greek == 'volga':
        result = b_s.BS_volga(row['Strike'], row['m_mid_vol'])
    elif greek == 'gamma_deri':
        result = b_s.BS_gamma_deri(row['Strike'], row['m_mid_vol'])
    return result