vanillaOption#

swordfish.function.vanillaOption()#

Calculate vanilla option prices using specified methods.

Parameters:
  • settlement (Constant) – A DATE scalar or vector indicating the settlement date.

  • maturity (Constant) – A DATE scalar or vector indicating the maturity date.

  • evalDate (Constant) – A DATE scalar or vector indicating the evaluation date.

  • spot (Constant) – A numeric scalar or vector indicating the spot price.

  • strike (Constant) – A numeric scalar or vector indicating the strike price.

  • riskFree (Constant) – A numeric scalar or vector indicating the risk-free interest rate.

  • divYield (Constant) – A numeric scalar or vector indicating the dividend yield.

  • volatility (Constant) – A numeric scalar or vector indicating the volatility.

  • isCall (Constant) –

    A Boolean scalar or vector.

    • true: buy (call option)

    • false: sell (put option)

  • style (Constant) – A STRING scalar or vector indicating the option exercise style. It can be ‘european’ or ‘american’.

  • basis (Constant) –

    An integer or STRING scalar or vector specifying the day count basis type. The optional values are:

    Basis

    Day Count Basis

    0 / “Thirty360US”

    US (NASD) 30/360

    1 / “ActualActual” (default)

    actual/actual

    2 / “Actual360”

    actual/360

    3 / “Actual365”

    actual/365

    4 / “Thirty360EU”

    European 30/360

  • calendar (Constant) – A STRING scalar or vector indicating the trading calendar(s). See Trading Calendar for more information.

  • method (Constant, optional) –

    A STRING scalar indicating the pricing method, by default DFLT.

    • ’BS’ (default): Black-Scholes model (for European options only).

    • ’FDBS’: Finite Difference method + Black-Scholes model.

    • ’heston’: Heston model (for European options only).

    • ’FDHeston’: Finite Difference method + Heston model.

    • ’PTDHeston’: Piecewise Time Dependent Heston model (for European options only).

  • kwargs (Constant, optional) –

    A dictionary specifying other required parameters. Leave it unspecified when method=’BS’, by default DFLT. The key-values pairs should be:

    • When method=’FDBS’:

      • ’xGrid’: A scalar or vector with integers greater than 1, indicating the number of spatial grids used for discretization in the finite difference method.

      • ’tGrid’: A scalar or vector with positive integers, indicating the number of time grids used for discretization in the finite difference method. tGrid must be greater than 0.

      • ’dampingSteps’: A scalar or vector with non-negative integers, representing the number of damping steps applied in the finite difference solution process.

    • When method=’heston’:

      • ’theta’: A numeric scalar or vector representing the long-term mean of the variance.

      • ’kappa’: A numeric scalar or vector indicating the speed of mean reversion for the variance.

      • ’rho’: A numeric scalar or vector representing the correlation coefficient between the asset price and volatility.

      • ’sigma’: A numeric scalar or vector representing the volatility of volatility.

    • When method=’FDHeston’:

      • ’theta’: A numeric scalar or vector representing the long-term mean of the variance.

      • ’kappa’: A numeric scalar or vector indicating the speed of mean reversion for the variance.

      • ’rho’: A numeric scalar or vector representing the correlation coefficient between the asset price and volatility.

      • ’sigma’: A numeric scalar or vector representing the volatility of volatility.

      • ’xGrid’: An scalar or vector with integers greater than 1, indicating the number of spatial grids used for discretization in the finite difference method.

      • ’vGrid’: An scalar or vector with integers greater than 1, indicating the number of volatility grids used for discretization in the finite difference method.

      • ’tGrid’: An scalar or vector with positive integers, indicating the number of time grids used for discretization in the finite difference method. tGrid must be greater than 0.

      • ’dampingSteps’: An scalar or vector with non-negative integers, representing the number of damping steps applied in the finite difference solution process.

    • When method=’PTDHeston’:

      • ’times’: A numeric vector or array indicating the time points when conditions change.

      • ’theta’: A numeric scalar or vector representing the long-term mean of the variance.

      • ’kappa’: A numeric scalar or vector indicating the speed of mean reversion for the variance.

      • ’rho’: A numeric scalar or vector representing the correlation coefficient between the asset price and volatility.

      • ’sigma’: A numeric scalar or vector representing the volatility of volatility.

  • mode (Constant, optional) –

    An integeralscalar or vector indicating the output mode, by default DFLT. It can be:

    • 0: NPV (net present value) only.

    • 1: NPV and Greeks (delta, gamma, theta, vega and rho) in a nested tuple.

    • 2: NPV and Greeks (delta, gamma, theta, vega and rho) in an ordered dictionary.

Returns:

  • When mode=0, return a FLOATING scalar or vector indicating the NPV.

  • When mode=1, return a tuple with two tuple elements, NPV and Greeks (delta, gamma, theta, vega and rho).

  • When mode=2, return an ordered dictionary with keys ‘npv’, ‘delta’, ‘gamma’, ‘theta’, ‘vega’, and ‘rho’.

Return type:

Constant