qdpmc.structures.barrier_options.UpIn¶
- class qdpmc.structures.barrier_options.UpIn(spot, barrier, rebate, ob_days, payoff)[source]¶
Bases:
qdpmc.structures.barrier_options.SingleBarrierOption
An up-and-in option.
An up-and-in option begins to function as a normal option once the price of the underlying asset is above the barrier level on any observation day. If during its life the barrier is not hit, a rebate will be paid to the option holder at maturity.
- 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) – The rebate of the option. Must be a constant for knock-in options
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.UpIn( ...: 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': 10.657713190736326, 'Delta': 0.6158884257736955, 'Gamma': 0.018296635217812093, 'Rho': 43.565352342942205, 'Vega': 46.44929686790452, 'Theta': -0.0001343387767049241}
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.