‘jd’ : jump_diffusion
‘srd’: square_root_diffusion}
otypes = {‘European’ : valuation_mcs_european,
‘American’ : valuation_mcs_american}
In the interactive use case that follows, we combine selected elements to define two
different derivatives positions that we then combine into a portfolio.
We build on the use case for the derivatives_position class with the gbm and
am_put_pos objects from the previous section. To illustrate the use of the
derivatives_portfolio class, let us define both an additional underlying and an
additional options position. First, a jump_diffusion object:
In [ 11 ]: me_jd = market_environment(‘me_jd’, me_gbm.pricing_date)
In [ 12 ]: # add jump diffusion-specific parameters
me_jd.add_constant(‘lambda’, 0.3)
me_jd.add_constant(‘mu’, -0.75)
me_jd.add_constant(‘delta’, 0.1)
# add other parameters from gbm
me_jd.add_environment(me_gbm)
In [ 13 ]: # needed for portfolio valuation
me_jd.add_constant(‘model’, ‘jd’)
Second, a European call option based on this new simulation object:
In [ 14 ]: me_eur_call = market_environment(‘me_eur_call’, me_jd.pricing_date)
In [ 15 ]: me_eur_call.add_constant(‘maturity’, dt.datetime( 2015 , 6 , 30 ))
me_eur_call.add_constant(‘strike’, 38.)
me_eur_call.add_constant(‘currency’, ‘EUR’)
In [ 16 ]: payoff_func = ‘np.maximum(maturity_value - strike, 0)’
In [ 17 ]: eur_call_pos = derivatives_position(
name=‘eur_call_pos’,
quantity= 5 ,
underlying=‘jd’,
mar_env=me_eur_call,
otype=‘European’,
payoff_func=payoff_func)
From a portfolio perspective, the relevant market now is:
In [ 18 ]: underlyings = {‘gbm’: me_gbm, ‘jd’ : me_jd}
positions = {‘am_put_pos’ : am_put_pos, ‘eur_call_pos’ : eur_call_pos}
For the moment we abstract from correlations between the underlyings. Compiling a
market_environment for the portfolio valuation is the last step before we can instantiate a
derivatives_portfolio class:
In [ 19 ]: # discounting object for the valuation
csr = constant_short_rate(‘csr’, 0.06)
In [ 20 ]: val_env = market_environment(‘general’, me_gbm.pricing_date)
val_env.add_constant(‘frequency’, ‘W’)
# monthly frequency
val_env.add_constant(‘paths’, 25000 )
val_env.add_constant(‘starting_date’, val_env.pricing_date)
val_env.add_constant(‘final_date’, val_env.pricing_date)
# not yet known; take pricing_date temporarily
val_env.add_curve(‘discount_curve’, csr)
# select single discount_curve for whole portfolio
In [ 21 ]: from derivatives_portfolio import derivatives_portfolio
In [ 22 ]: portfolio = derivatives_portfolio(
name=‘portfolio’,
positions=positions,
val_env=val_env,
assets=underlyings,
fixed_seed=True)
Now we can harness the power of the valuation class and get a bunch of different statistics