qdpmc.structures.barrier_options.UpOut

class qdpmc.structures.barrier_options.UpOut(spot, barrier, rebate, ob_days, payoff)[source]

Bases: qdpmc.structures.barrier_options.SingleBarrierOption

An up-and-out option.

An up-and-out option is knocked out if, during its life, the price of the underlying asset exceeds the barrier level on any observation day. When the option is knocked out, a rebate is immediately paid to the option holder.

Parameters
  • spot (scalar) – Spot (ie.e, on the valuation day) price of the underlying asset.

  • barrier (scalar or array_like) – The barrier of the option. If a constant is passed, then it will be treated as the time-invariant barrier level of the option. If an array is passed, then it must match the length of ob_days.

  • rebate (scalar or array_like) – The rebate of the option. If a constant is passed, then it will be treated as the time-invariant rebate paid to the option holder. If an array is passed, then it must match the length of ob_days.

  • ob_days (array_like) – A 1-D array of integers specifying observation days. Each of its elements represents the number of days that an observation day is from the valuation day.

  • payoff (qdpmc.tools.payoffs.Payoff) – A Payoff instance that controls the payoff

Examples

In [1]: option = qm.UpOut(
   ...:     spot=100,
   ...:     barrier=120,
   ...:     rebate=0,
   ...:     ob_days=np.linspace(1, 252, 252),
   ...:     payoff=qm.Payoff(
   ...:         qm.plain_vanilla,
   ...:         strike=100,
   ...:         option_type="call"
   ...:     )
   ...: )
   ...: 

In [2]: mc = qm.MonteCarlo(125, 800)

In [3]: bs = qm.BlackScholes(0.03, 0, 0.25, 252)

In [4]: option.calc_value(mc, bs, request_greeks=True)
Out[4]: 
{'PV': 0.8116480696843561,
 'Delta': -0.018588749411592873,
 'Gamma': -0.007570251592653193,
 'Rho': -5.895169116789613,
 'Vega': -7.186127579755813,
 'Theta': 2.6924624579656833e-06}

For time-varying barrier and rebate, pass in an array to barrier:

In [5]: option_tvb = qm.UpOut(
   ...:     spot=100,
   ...:     barrier=np.linspace(110, 120, 252),
   ...:     rebate=np.linspace(0, 3, 252),
   ...:     ob_days=np.linspace(1, 252, 252),
   ...:     payoff=qm.Payoff(
   ...:         qm.plain_vanilla,
   ...:         strike=100,
   ...:         option_type="call"
   ...:     )
   ...: )
   ...: 

In [6]: option_tvb.calc_value(mc, bs)
Out[6]: 0.9622002719561104

Methods

__init__(spot, barrier, rebate, ob_days, payoff)

calc_value(engine, process, *args, **kwargs)

Calculates the present value and Greeks of the option.

pv_log_paths(log_paths, df)

Calculate the present value given a set of paths and an array of discount factor.

Attributes

sim_t_array

The array of days that the price of the underlying asset must be simulated to calculate the present value of the option.

spot

The spot price of the underlying asset.

calc_value(engine, process, *args, **kwargs)

Calculates the present value and Greeks of the option.

Parameters
pv_log_paths(log_paths, df)[source]

Calculate the present value given a set of paths and an array of discount factor.

Parameters
  • log_paths (array_like) – A 2-D array containing the set of projections of the price of the underlying asset.

  • df (array_like) – A 1-D array specifying the discount factors.

Returns

scalar – The present value of the option.

property sim_t_array

The array of days that the price of the underlying asset must be simulated to calculate the present value of the option.

property spot

The spot price of the underlying asset.