qdpmc.structures.barrier_options.DoubleIn

class qdpmc.structures.barrier_options.DoubleIn(spot, barrier_up, barrier_down, ob_days_up, ob_days_down, rebate, payoff)[source]

Bases: qdpmc.structures.barrier_options.DoubleBarrierOption

A double-in option.

A double-in option begins to function as a normal function (i.e., knocks in) if on any observation day the price of the underlying asset is above the upper barrier or the lower barrier. A rebate is paid at the maturity of the option if the option does not knock in during its life.

Parameters
  • spot (scalar) – The spot price of the underlying asset.

  • barrier_up (scalar or array_like) – The upper barrier of the option. This can be either a scalar or an array. If a scalar is passed, it will be treated as the time-invariant level of barrier. If an array is passed, it must match the length of ob_days_up.

  • barrier_down (scalar or array_like) – The lower barrier of the option. This can be either a scalar or an array. If a scalar is passed, it will be treated as the time-invariant level of barrier. If an array is passed, it must match the length of ob_days_down”.

  • ob_days_up (array_like) – The array of observation days for the upper barrier. This must be an array of integers with each element representing the number of days that an observation day is from the valuation day. The last element of the union of ob_days_up and ob_days_down is assumed to be the maturity of the double-barrier option.

  • ob_days_down (array_like) – Similar to ob_days_up.

  • rebate (scalar) – The rebate of the option. Must be a constant for knock-in options

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

Examples

In [1]: option = qm.DoubleIn(
   ...:     spot=100,
   ...:     barrier_up=120,
   ...:     barrier_down=80,
   ...:     ob_days_up=np.linspace(1, 252, 21),
   ...:     ob_days_down=np.linspace(1, 252, 252),
   ...:     rebate=2,
   ...:     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': 10.89256212145423,
 'Delta': 0.5961634218351194,
 'Gamma': 0.01270010422369208,
 'Rho': 48.461276412877595,
 'Vega': 43.06603706029826,
 'Theta': -6.162593837880987e-05}

Methods

__init__(spot, barrier_up, barrier_down, …)

A double-in option.

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.