maturity_value = paths[time_index]
average value over whole path
mean_value = np.mean(paths[:time_index], axis= 1 )
maximum value over whole path
max_value = np.amax(paths[:time_index], axis= 1 )[- 1 ]
minimum value over whole path
min_value   =   np.amin(paths[:time_index], axis= 1 )[- 1 ]
try:
payoff  =   eval(self.payoff_func)
return payoff
except:
print “Error    evaluating  payoff  function.”
def present_value(self, accuracy= 6 ,   fixed_seed=False,   full=False):
”’
Parameters
==========
accuracy    :   int
number  of  decimals    in  returned    result
fixed_seed  :   Boolean
use same/fixed  seed    for valuation
full    :   Boolean
return  also    full    1d  array   of  present values
”’
cash_flow   =   self.generate_payoff(fixed_seed=fixed_seed)
discount_factor =   self.discount_curve.get_discount_factors(
(self.pricing_date, self.maturity))[ 0 ,     1 ]
result  =   discount_factor    np.sum(cash_flow)   /   len(cash_flow)
if full:
return round(result,    accuracy),  discount_factor    cash_flow
else:
return round(result,    accuracy)
The generate_payoff method provides some special objects to be used for the definition
of the payoff of the option:
strike is the strike of the option.
maturity_value represents the 1D ndarray object with the simulated values of the
underlying at maturity of the option.
mean_value is the average of the underlying over a whole path from today until
maturity.
max_value is the maximum value of the underlying over a whole path.
min_value gives the minimum value of the underlying over a whole path.
The last three especially allow for the efficient handling of options with Asian (i.e.,
lookback) features.
A Use Case
The application of the valuation class valuation_mcs_european is best illustrated by a
specific use case. However, before a valuation class can be instantiated, we need a
simulation object — i.e., an underlying for the option to be valued. From Chapter 16, we
use the geometric_brownian_motion class to model the underlying. We also use the
example parameterization of the respective use case there:
In  [ 1 ]:  from dx import  *
In  [ 2 ]:  me_gbm  =   market_environment(‘me_gbm’,    dt.datetime( 2015 ,  1 ,     1 ))
In  [ 3 ]:  me_gbm.add_constant(‘initial_value’,    36.)
me_gbm.add_constant(‘volatility’,   0.2)
me_gbm.add_constant(‘final_date’,   dt.datetime( 2015 ,  12 ,    31 ))
me_gbm.add_constant(‘currency’, ‘EUR’)
me_gbm.add_constant(‘frequency’,    ‘M’)
me_gbm.add_constant(‘paths’,     10000 )