qdpmc.structures.barrier_options.DoubleOut¶
- class qdpmc.structures.barrier_options.DoubleOut(spot, barrier_up, barrier_down, ob_days_up, ob_days_down, payoff, rebate=None, rebate_up=None, rebate_down=None)[source]¶
Bases:
qdpmc.structures.barrier_options.DoubleBarrierOption
A double-out option.
A double-out option is knocked out if, during its life, the price of the underlying asset is above the upper barrier or below the lower barrier. A rebate is paid to the option holder once the option is knocked out.
- 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 – Similar to ob_days_up.
payoff (
qdpmc.tools.payoffs.Payoff
) – A Payoff instance that controls the payoffrebate (scalar or array_like) – If a scalar or an array is passed, then identical rebates will apply to knock-outs from above and below. If rebate is specified, both rebate_up and rebate_down will be ignored. If an array is passed, it must match the length of the union of ob_days_up and ob_days_down
rebate_up (scalar or array_like) – The rebate paid to the holder if the option is knocked out from above. Can be either a scalar or an array.
rebate_down (scalar or array_like) – The rebate paid to the holder if the option is knocked out from below. Can be either a scalar or an array.
Examples
In [1]: option = qm.DoubleOut( ...: spot=100, ...: barrier_up=120, ...: barrier_down=80, ...: ob_days_up=np.linspace(1, 252, 252), ...: ob_days_down=np.linspace(1, 252, 252), ...: payoff=qm.Payoff( ...: qm.plain_vanilla, ...: strike=100, ...: option_type="call" ...: ), ...: rebate_up=1, ...: rebate_down=2 ...: ) ...: 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': 1.7696415614224594, 'Delta': -0.024164066433892958, 'Gamma': -0.0056162877859114915, 'Rho': -3.2559052179776597, 'Vega': -3.8800941221480834, 'Theta': -2.2692924118667327e-05}
Methods
__init__
(spot, barrier_up, barrier_down, …)A double-out 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
The array of days that the price of the underlying asset must be simulated to calculate the present value of the option.
The spot price of the underlying asset.
- calc_value(engine, process, *args, **kwargs)¶
Calculates the present value and Greeks of the option.
- Parameters
engine (
qdpmc.engine.monte_carlo.MonteCarlo
) – An instance of Engine which determines the number of iterations and the batch size.process (
qdpmc.model.market_process.Heston
orqdpmc.model.market_process.BlackScholes
) – Market process.args – Forwarded to
qdpmc.engine.monte_carlo.MonteCarlo.calc()
kwargs – Forwarded to
qdpmc.engine.monte_carlo.MonteCarlo.calc()
- 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.