Python for Finance: Analyze Big Financial Data

(Elle) #1
quantity=100.,
underlying=‘vstoxx_model’,
mar_env=option_environments[option],
otype=‘American’,
payoff_func=payoff_func)

Note that we use 100 as the position quantity throughout, which is the typical contract size


for VSTOXX options.


The Options Portfolio


To compose the portfolio, we need to specify a couple of parameters that together define


our valuation environment — i.e., those parameters shared by all objects in the portfolio:


In  [ 61 ]: val_env =   market_environment(‘val_env’,   pricing_date)
val_env.add_constant(‘starting_date’, pricing_date)
val_env.add_constant(‘final_date’, pricing_date)
# temporary value, is updated during valuation
val_env.add_curve(‘discount_curve’, csr)
val_env.add_constant(‘frequency’, ‘B’)
val_env.add_constant(‘paths’, 25000 )

The market is rather simple; it consists of a single risk factor:


In  [ 62 ]: underlyings =   {‘vstoxx_model’ :   me_vstoxx}

Taking all this together allows us to define a derivatives_portfolio object:


In  [ 63 ]: portfolio   =   derivatives_portfolio(‘portfolio’,  option_positions,
val_env, underlyings)

The valuation takes quite a bit of time, since multiple American options are valued by the


Least-Squares Monte Carlo approach and multiple Greeks also have to be estimated by


revaluations using the same computationally demanding algorithm:


In  [ 64 ]: %time results   =   portfolio.get_statistics(fixed_seed=True)
Out[64]: CPU times: user 38.6 s, sys: 1.96 s, total: 40.6 s
Wall time: 40.6 s

The results DataFrame object is best sorted by the name column to have a better


comparative view of the statistics:


In  [ 65 ]: results.sort(columns=‘name’)
Out[65]: name quant. value curr. pos_value pos_delta pos_vega
8 am_put_17 100 4.575197 EUR 457.5197 -24.85 102.77
1 am_put_18 100 5.203648 EUR 520.3648 -30.62 107.93
0 am_put_19 100 5.872686 EUR 587.2686 -33.31 107.79
2 am_put_20 100 6.578714 EUR 657.8714 -34.82 110.01
6 am_put_21 100 7.320523 EUR 732.0523 -39.46 105.20
7 am_put_22 100 8.081625 EUR 808.1625 -40.61 102.38
3 am_put_23 100 8.871962 EUR 887.1962 -43.26 104.37
4 am_put_24 100 9.664272 EUR 966.4272 -40.14 101.04
5 am_put_25 100 10.475168 EUR 1047.5168 -45.74 102.81

This portfolio is, as expected for a portfolio of long American put options, short (negative)


Delta and long (positive) Vega:


In  [ 66 ]: results[[‘pos_value’,‘pos_delta’,‘pos_vega’]].sum()
Out[66]: pos_value 6664.3795
pos_delta -332.8100
pos_vega 944.3000
dtype: float64
Free download pdf