Python for Finance: Analyze Big Financial Data

(Elle) #1

Conclusions


This chapter addresses the valuation and risk management of a portfolio of multiple


derivatives positions dependent on multiple, possibly correlated, risk factors. To this end,


a new class called derivatives_position is introduced to model an options/derivatives


position. The main focus, however, lies on the derivatives_portfolio class, which


implements some rather complex tasks. For example, the class takes care of:


Correlations between risk factors (the class generates a single, consistent set of


random numbers for the simulation of all risk factors)


Instantiation of simulation objects given the single market environments and the


general valuation environment, as well as the derivatives positions


Generation of portfolio statistics based on all the assumptions, the risk factors


involved, and the terms of the derivatives positions


The examples presented in this chapter can only show some simple versions of derivatives


portfolios that can be managed and valued with the DX library and the


derivatives_portfolio class. Natural extensions to the DX library would be the addition


of more sophisticated financial models, like a stochastic volatility model, and the addition


of multirisk valuation classes to model and value derivatives dependent on multiple risk


factors, like a European basket option or an American maximum call option, to name just


two. At this stage, the modular modeling and the application of a valuation framework as


general as the Fundamental Theorem of Asset Pricing (or “Global Valuation”) plays out its


strengths: the nonredundant modeling of the risk factors and the accounting for the


correlations between them will then also have a direct influence on the values and Greeks


of multirisk derivatives.


Example 18-3 is a final, brief wrapper module bringing all components of the DX analytics


library together for a single import statement.


Example 18-3. The final wrapper module bringing all DX components together



DX Library Simulation


dx_library.py



from dx_valuation import *
from derivatives_position import derivatives_position
from derivatives_portfolio import derivatives_portfolio


Also, the now-complete init file for the dx directory is in Example 18-4.


Example 18-4. Final Python packaging file



DX Library


packaging file


init.py



import numpy as np
import pandas as pd
import datetime as dt


frame


from get_year_deltas import get_year_deltas
from constant_short_rate import constant_short_rate
from market_environment import market_environment

Free download pdf