Generic Valuation Class
As with the generic simulation class, we instantiate an object of the valuation class by
providing only a few inputs (in this case, four):
name
A string object as a name for the model simulation object
underlying
An instance of a simulation class representing the underlying
mar_env
An instance of the market_environment class
payoff_func
A Python string containing the payoff function for the option/derivative
The generic class has three methods:
update
This method updates selected valuation parameters (attributes).
delta
This method calculates a numerical value for the Delta of an option/derivative.
vega
This method calculates the Vega of an option/derivative.
Equipped with the background knowledge from the previous chapters about the DX library,
the generic valuation class as presented in Example 17-1 should be almost self-
explanatory; where appropriate, inline comments are also provided. We again present the
class in its entirety first and highlight selected topics immediately afterward and in the
subsequent sections.
Example 17-1. Generic valuation class
DX Library Valuation
valuation_class.py
class valuation_class(object):
”’ Basic class for single-factor valuation.
Attributes
==========
name : string
name of the object
underlying :
instance of simulation class
mar_env : instance of market_environment
market environment data for valuation
payoff_func : string
derivatives payoff in Python syntax
Example: ‘np.maximum(maturity_value - 100, 0)’
where maturity_value is the NumPy vector with
respective values of the underlying
Example: ‘np.maximum(instrument_values - 100, 0)’
where instrument_values is the NumPy matrix with
values of the underlying over the whole time/path grid