Exemplo n.º 1
0
def option_price(strike, vola, forward, r_counter, tau, is_call) \
        -> Union[float, np.ndarray]:
    """Compute the Black-Scholes option price.

    Vectorized for `strike` and `vola` to return output of the same
    dimension as (strike * vola): e.g. if strike.shape == (1, 4) and
    vola.shape == (2, 1), res.dim == (2, 4)

    Parameters
    ----------
    strike : float or numpy.ndarray
        strikes prices
    vola : float or numpy.ndarray
        volatility, in (frac of 1) p.a.
    forward : float
        forward price of the underlying
    r_counter : float
        risk-free rate in the counter currency (continuously comp), in frac.
        of 1 p.a.
    tau : float
        maturity, in years
    is_call : bool or np.ndarray
        True (False) to return prices of call (put) options

    Returns
    -------
    res : float or numpy.ndarray
        price, in domestic currency
    """
    # +1 for call, -1 for put
    omega = is_call * 2 - 1.0

    res = omega * np.exp(-r_counter * tau) * (
        forward * fast_norm_cdf(omega * d1(forward, strike, vola, tau)) -
        strike * fast_norm_cdf(omega * d2(forward, strike, vola, tau)))

    return res
Exemplo n.º 2
0
def delta_pips_forward(forward, strike, vola, tau, is_call):
    omega = is_call * 2 - 1
    res = omega * fast_norm_cdf(omega * d1(forward, strike, vola, tau))
    return res
Exemplo n.º 3
0
def delta_premiumadj_spot(forward, spot, strike, vola, r_counter, tau,
                          is_call):
    omega = is_call * 2 - 1
    res = omega * np.exp(-r_counter * tau) * strike / spot * \
        fast_norm_cdf(omega * d2(forward, strike, vola, tau))
    return res
Exemplo n.º 4
0
def delta_pips_spot(forward, strike, vola, r_base, tau, is_call):
    omega = is_call * 2 - 1
    res = omega * np.exp(-r_base * tau) * \
        fast_norm_cdf(omega * d1(forward, strike, vola, tau))
    return res
Exemplo n.º 5
0
def delta_premiumadj_forward(forward, strike, vola, tau, is_call):
    omega = is_call * 2 - 1
    res = omega * strike / forward * \
        fast_norm_cdf(omega * d2(forward, strike, vola, tau))
    return res