qdpmc.structures.barrier_options.DownOut¶
- class qdpmc.structures.barrier_options.DownOut(spot, barrier, rebate, ob_days, payoff)[source]¶
Bases:
qdpmc.structures.barrier_options.SingleBarrierOption
A down-and-out option.
A down-and-out barrier option is knocked out if, during its life, the price of the underlying asset is below 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.DownOut( ...: spot=100, ...: barrier=80, ...: 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': 10.991243209321574, 'Delta': 0.6259638096611091, 'Gamma': 0.010498896669351119, 'Rho': 45.30222411112109, 'Vega': 31.61628139015503, 'Theta': -0.00012905859204242066}
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
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.