print self.otype, ‘\n’
print “PAYOFF FUNCTION”
print self.payoff_func
To define a derivatives position we need to provide the following information, which is
almost the same as for the instantiation of a valuation class:
name
Name of the position as a string object
quantity
Quantity of options/derivatives
underlying
Instance of simulation object as a risk factor
mar_env
Instance of market_environment
otype
string, either “European” or “American”
payoff_func
Payoff as a Python string object
A Use Case
The following interactive session illustrates the use of the class. However, we need to first
define a simulation object — but not in full; only the most important, object-specific
information is needed. Here, we basically stick to the numerical examples from the
previous two chapters:
In [ 1 ]: from dx import *
For the definition of the derivatives position, we do not need a “full” market_environment
object. Missing information is provided later (during the portfolio valuation), when the
simulation object is instantiated:
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(‘currency’, ‘EUR’)
However, for the portfolio valuation, one additional constant is needed — namely, for the
model to be used. This will become clear in the subsequent section:
In [ 4 ]: me_gbm.add_constant(‘model’, ‘gbm’)
With the simulation object available, we can proceed to define a derivatives position as
follows:
In [ 5 ]: from derivatives_position import derivatives_position
In [ 6 ]: me_am_put = market_environment(‘me_am_put’, dt.datetime( 2015 , 1 , 1 ))
In [ 7 ]: me_am_put.add_constant(‘maturity’, dt.datetime( 2015 , 12 , 31 ))
me_am_put.add_constant(‘strike’, 40.)
me_am_put.add_constant(‘currency’, ‘EUR’)
In [ 8 ]: payoff_func = ‘np.maximum(strike - instrument_values, 0)’
In [ 9 ]: am_put_pos = derivatives_position(
name=‘am_put_pos’,