{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"The" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Derivatives Portfolio Risk Statistics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "From a risk management perspective it is important to know **how sensitive derivatives portfolios are** with regard to certain parameter values (market quotes, model assumptions, etc.). This part illustrates how to generate certain **risk reports** for `derivatives_portfolio` objects." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import dx\n", "import datetime as dt\n", "import time\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Risk Factors" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The example is based on **two risk factors**, both modeled as geometric Brownian motions." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# constant short rate\n", "r = dx.constant_short_rate('r', 0.01)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# market environment\n", "me_gbm_1 = dx.market_environment('gbm_1', dt.datetime(2015, 1, 1))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# geometric Brownian motion\n", "me_gbm_1.add_constant('initial_value', 40.)\n", "me_gbm_1.add_constant('volatility', 0.2) \n", "me_gbm_1.add_constant('currency', 'EUR')\n", "me_gbm_1.add_constant('model', 'gbm')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "me_gbm_2 = dx.market_environment('gbm_2', me_gbm_1.pricing_date)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# valuation environment\n", "val_env = dx.market_environment('val_env', dt.datetime(2015, 1, 1))\n", "val_env.add_constant('paths', 25000)\n", " # 25,000 paths\n", "val_env.add_constant('frequency', 'W')\n", " # weekly frequency\n", "val_env.add_curve('discount_curve', r)\n", "val_env.add_constant('starting_date', dt.datetime(2015, 1, 1))\n", "val_env.add_constant('final_date', dt.datetime(2015, 12, 31))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# add valuation environment to market environments\n", "me_gbm_1.add_environment(val_env)\n", "me_gbm_2.add_environment(me_gbm_1)\n", "me_gbm_2.add_constant('initial_value', 40.)\n", "me_gbm_2.add_constant('volatility', 0.5)\n", " # higher volatility" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "risk_factors = {'gbm_1' : me_gbm_1, 'gbm_2' : me_gbm_2}\n", " # market with two risk factors" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Derivatives Positions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are going to model **total of 6 derivatives positions**." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Market Environment" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All derivatives instruments (positions) share the same `market_environment` object." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# market environment for the options\n", "me_option = dx.market_environment('put', dt.datetime(2015, 1, 1))\n", "me_option.add_constant('maturity', dt.datetime(2015, 12, 31))\n", "me_option.add_constant('currency', 'EUR')\n", "me_option.add_environment(val_env)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Derivatives Positions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Two different kinds of derivatives make up the portfolio---an **American put option** and a **European maximum call option**. Both types of derivatives populate three positions, respectively." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "positions = {}\n", "half = 3 # 2 times that many options\n", "for i in range(half):\n", " name = 'am_put_pos_%s' %i # same name for position key and name\n", " positions[name] = dx.derivatives_position(\n", " name=name,\n", " quantity=1,\n", " underlyings=['gbm_1'],\n", " mar_env=me_option,\n", " otype='American single',\n", " payoff_func='np.maximum(instrument_values - 40., 0)')\n", "\n", "multi_payoff = \"np.maximum(np.maximum(maturity_value['gbm_1'], maturity_value['gbm_2']) - 40., 0)\"\n", "for i in range(half, 2 * half):\n", " name = 'multi_pos_%s' %i # same name for position key and name\n", " positions[name] = dx.derivatives_position(\n", " name=name,\n", " quantity=1,\n", " underlyings=['gbm_1', 'gbm_2'],\n", " mar_env=me_option,\n", " otype='European multi',\n", " payoff_func=multi_payoff)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Portfolio Modeling and Valuation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The instantiation of the `derivatives_portfolio` object is as usual." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "portfolio = dx.derivatives_portfolio(\n", " name='portfolio',\n", " positions=positions,\n", " val_env=val_env,\n", " risk_factors=risk_factors,\n", " correlations=None,\n", " parallel=False)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Total\n", " pos_value 40.912\n", "dtype: float64\n", "CPU times: user 879 ms, sys: 60.5 ms, total: 939 ms\n", "Wall time: 915 ms\n" ] } ], "source": [ "%time res = portfolio.get_values(fixed_seed=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, the **value estimates** from the Monte Carlo simulation and valuation." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
positionnamequantityotyperisk_factsvaluecurrencypos_value
0am_put_pos_0am_put_pos_01American single[gbm_1]3.278EUR3.278
1am_put_pos_1am_put_pos_11American single[gbm_1]3.267EUR3.267
2am_put_pos_2am_put_pos_21American single[gbm_1]3.320EUR3.320
3multi_pos_3multi_pos_31European multi[gbm_1, gbm_2]10.349EUR10.349
4multi_pos_4multi_pos_41European multi[gbm_1, gbm_2]10.349EUR10.349
5multi_pos_5multi_pos_51European multi[gbm_1, gbm_2]10.349EUR10.349
\n", "
" ], "text/plain": [ " position name quantity otype risk_facts \\\n", "0 am_put_pos_0 am_put_pos_0 1 American single [gbm_1] \n", "1 am_put_pos_1 am_put_pos_1 1 American single [gbm_1] \n", "2 am_put_pos_2 am_put_pos_2 1 American single [gbm_1] \n", "3 multi_pos_3 multi_pos_3 1 European multi [gbm_1, gbm_2] \n", "4 multi_pos_4 multi_pos_4 1 European multi [gbm_1, gbm_2] \n", "5 multi_pos_5 multi_pos_5 1 European multi [gbm_1, gbm_2] \n", "\n", " value currency pos_value \n", "0 3.278 EUR 3.278 \n", "1 3.267 EUR 3.267 \n", "2 3.320 EUR 3.320 \n", "3 10.349 EUR 10.349 \n", "4 10.349 EUR 10.349 \n", "5 10.349 EUR 10.349 " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Portfolio Risk Reports" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Portfolio risk reports are meant to provide a broad overview of how sensitive the value of a portfolio is with regard to the value of certain input parameters (market data, model parameters). While **Greeks** provide the same information with regard to marginal changes in the input paramters, risk reports provide a **wider range input-output (parameter-portfolio value) combinations**." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### No Correlation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, consider the portfolio from before, i.e. **without correlation**." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[1., 0.],\n", " [0., 1.]])" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "portfolio.val_env.get_list('cholesky_matrix')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calling the method `get_port_risk` and providing a key for the respetive Greek yields sensitivities with regard to all risk factors (here: `gbm_1` and `gbm_2`). " ] }, { "cell_type": "raw", "metadata": {}, "source": [ "portfolio.valuation_objects[3].underlying_objects['gbm_1'].update(initial_value=15)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "gbm_1\n", "0.8\n", "0.9\n", "1.0\n", "1.1\n", "1.2\n", "\n", "gbm_2\n", "0.8\n", "0.9\n", "1.0\n", "1.1\n", "1.2\n", "\n", "\n", "\n", "CPU times: user 5.33 s, sys: 264 ms, total: 5.6 s\n", "Wall time: 5.48 s\n" ] } ], "source": [ "%%time\n", "vegas, benchvalue = portfolio.get_port_risk(Greek='Vega',\n", " fixed_seed=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The return object is a pandas `Panel` object." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gbm_1_Vegagbm_2_Vega
majorminor
0.8factor0.1600.400
value32.30729.448
0.9factor0.1800.450
value33.24631.815
1.0factor0.2000.500
value40.96540.965
1.1factor0.2200.550
value35.10936.519
1.2factor0.2400.600
value35.99438.856
\n", "
" ], "text/plain": [ " gbm_1_Vega gbm_2_Vega\n", "major minor \n", "0.8 factor 0.160 0.400\n", " value 32.307 29.448\n", "0.9 factor 0.180 0.450\n", " value 33.246 31.815\n", "1.0 factor 0.200 0.500\n", " value 40.965 40.965\n", "1.1 factor 0.220 0.550\n", " value 35.109 36.519\n", "1.2 factor 0.240 0.600\n", " value 35.994 38.856" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "vegas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using the helper funtion `risk_report` allows the easy, readable printout of the results, i.e. the **portfolio volatility sensitivities**. In this case you can see that, for example, the increase in the first risk fator's (`gbm_1`) volatility by 10% leads to a portfolio value increase bya bit less than 1 currency unit. Decreasing the same input parameter by 10% reduces the portfolio value by a bit less than 1 currency unit." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "gbm_1_Vega\n", "major minor \n", "0.8 factor 0.16\n", " value 32.31\n", "0.9 factor 0.18\n", " value 33.25\n", "1.0 factor 0.20\n", " value 40.96\n", "1.1 factor 0.22\n", " value 35.11\n", "1.2 factor 0.24\n", " value 35.99\n", "Name: gbm_1_Vega, dtype: float64\n", "\n", "gbm_2_Vega\n", "major minor \n", "0.8 factor 0.40\n", " value 29.45\n", "0.9 factor 0.45\n", " value 31.82\n", "1.0 factor 0.50\n", " value 40.96\n", "1.1 factor 0.55\n", " value 36.52\n", "1.2 factor 0.60\n", " value 38.86\n", "Name: gbm_2_Vega, dtype: float64\n" ] } ], "source": [ "dx.risk_report(vegas)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Of course, you can generate the same risk report for the **portfolio initial value sensitivities**." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "gbm_1\n", "0.8\n", "0.9\n", "1.0\n", "1.1\n", "1.2\n", "\n", "gbm_2\n", "0.8\n", "0.9\n", "1.0\n", "1.1\n", "1.2\n", "\n", "\n", "\n", "CPU times: user 5.33 s, sys: 246 ms, total: 5.58 s\n", "Wall time: 5.46 s\n" ] } ], "source": [ "%time deltas, benchvalue = portfolio.get_port_risk(Greek='Delta', fixed_seed=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, increasing the initial value of the first risk factor (`gbm_1`) by 10% increases the portfolio value by about 11 currency units." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gbm_1_Deltagbm_2_Delta
majorminor
0.8factor32.00032.000
value25.47624.138
0.9factor36.00036.000
value28.44028.311
1.0factor40.00040.000
value40.96540.965
1.1factor44.00044.000
value45.30641.601
1.2factor48.00048.000
value61.35650.091
\n", "
" ], "text/plain": [ " gbm_1_Delta gbm_2_Delta\n", "major minor \n", "0.8 factor 32.000 32.000\n", " value 25.476 24.138\n", "0.9 factor 36.000 36.000\n", " value 28.440 28.311\n", "1.0 factor 40.000 40.000\n", " value 40.965 40.965\n", "1.1 factor 44.000 44.000\n", " value 45.306 41.601\n", "1.2 factor 48.000 48.000\n", " value 61.356 50.091" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "deltas" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gbm_1_Deltagbm_2_Delta
majorminor
0.8value-15.489-16.827
0.9value-12.525-12.654
1.0value0.0000.000
1.1value4.3410.636
1.2value20.3919.126
\n", "
" ], "text/plain": [ " gbm_1_Delta gbm_2_Delta\n", "major minor \n", "0.8 value -15.489 -16.827\n", "0.9 value -12.525 -12.654\n", "1.0 value 0.000 0.000\n", "1.1 value 4.341 0.636\n", "1.2 value 20.391 9.126" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "deltas.loc(axis=0)[:, 'value'] - benchvalue" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### With Correlation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Consider now a **highly negative correlation** case." ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "correlations = [['gbm_1', 'gbm_2', -0.9]]" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "portfolio = dx.derivatives_portfolio(\n", " 'portfolio', positions, val_env,\n", " risk_factors, correlations, parallel=False)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 1. , 0. ],\n", " [-0.9 , 0.43588989]])" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "portfolio.val_env.get_list('cholesky_matrix')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Since the value of the European maximum call option is dependent on the risk factor correlation you see a **significant change in this derivative's value estimate**." ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Total\n", " pos_value 44.112\n", "dtype: float64\n", "CPU times: user 780 ms, sys: 49.3 ms, total: 829 ms\n", "Wall time: 788 ms\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
positionnamequantityotyperisk_factsvaluecurrencypos_value
0am_put_pos_0am_put_pos_01American single[gbm_1]3.293EUR3.293
1am_put_pos_1am_put_pos_11American single[gbm_1]3.293EUR3.293
2am_put_pos_2am_put_pos_21American single[gbm_1]3.293EUR3.293
3multi_pos_3multi_pos_31European multi[gbm_1, gbm_2]11.411EUR11.411
4multi_pos_4multi_pos_41European multi[gbm_1, gbm_2]11.411EUR11.411
5multi_pos_5multi_pos_51European multi[gbm_1, gbm_2]11.411EUR11.411
\n", "
" ], "text/plain": [ " position name quantity otype risk_facts \\\n", "0 am_put_pos_0 am_put_pos_0 1 American single [gbm_1] \n", "1 am_put_pos_1 am_put_pos_1 1 American single [gbm_1] \n", "2 am_put_pos_2 am_put_pos_2 1 American single [gbm_1] \n", "3 multi_pos_3 multi_pos_3 1 European multi [gbm_1, gbm_2] \n", "4 multi_pos_4 multi_pos_4 1 European multi [gbm_1, gbm_2] \n", "5 multi_pos_5 multi_pos_5 1 European multi [gbm_1, gbm_2] \n", "\n", " value currency pos_value \n", "0 3.293 EUR 3.293 \n", "1 3.293 EUR 3.293 \n", "2 3.293 EUR 3.293 \n", "3 11.411 EUR 11.411 \n", "4 11.411 EUR 11.411 \n", "5 11.411 EUR 11.411 " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%time portfolio.get_values(fixed_seed=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Via the `step` parameter, you can influence the **granularity of the risk report**." ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "gbm_1\n", "0.8\n", "0.8500000000000001\n", "0.9000000000000001\n", "0.9500000000000002\n", "1.0000000000000002\n", "1.0500000000000003\n", "1.1000000000000003\n", "1.1500000000000004\n", "1.2000000000000004\n", "\n", "gbm_2\n", "0.8\n", "0.8500000000000001\n", "0.9000000000000001\n", "0.9500000000000002\n", "1.0000000000000002\n", "1.0500000000000003\n", "1.1000000000000003\n", "1.1500000000000004\n", "1.2000000000000004\n", "\n", "\n", "\n", "CPU times: user 8.97 s, sys: 613 ms, total: 9.59 s\n", "Wall time: 9.02 s\n" ] } ], "source": [ "%%time \n", "deltas, benchvalue = portfolio.get_port_risk(Greek='Delta',\n", " fixed_seed=True,\n", " step=0.05)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this case, an increase in the intial value of the first risk factor (`gbm_1`) by 10% leads to a **much higher increase**\n", "in the portfolio value of about 15 currency units." ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gbm_1_Deltagbm_2_Delta
majorminor
0.80factor32.00032.000
value27.19531.665
0.85factor34.00034.000
value29.64934.377
0.90factor36.00036.000
value33.23437.365
0.95factor38.00038.000
value38.12440.617
1.00factor40.00040.000
value44.11244.112
1.05factor42.00042.000
value51.05747.820
1.10factor44.00044.000
value58.96551.729
1.15factor46.00046.000
value67.64155.803
1.20factor48.00048.000
value76.97760.021
\n", "
" ], "text/plain": [ " gbm_1_Delta gbm_2_Delta\n", "major minor \n", "0.80 factor 32.000 32.000\n", " value 27.195 31.665\n", "0.85 factor 34.000 34.000\n", " value 29.649 34.377\n", "0.90 factor 36.000 36.000\n", " value 33.234 37.365\n", "0.95 factor 38.000 38.000\n", " value 38.124 40.617\n", "1.00 factor 40.000 40.000\n", " value 44.112 44.112\n", "1.05 factor 42.000 42.000\n", " value 51.057 47.820\n", "1.10 factor 44.000 44.000\n", " value 58.965 51.729\n", "1.15 factor 46.000 46.000\n", " value 67.641 55.803\n", "1.20 factor 48.000 48.000\n", " value 76.977 60.021" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "deltas" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gbm_1_Deltagbm_2_Delta
majorminor
0.80value-16.917-12.447
0.85value-14.463-9.735
0.90value-10.878-6.747
0.95value-5.988-3.495
1.00value0.0000.000
1.05value6.9453.708
1.10value14.8537.617
1.15value23.52911.691
1.20value32.86515.909
\n", "
" ], "text/plain": [ " gbm_1_Delta gbm_2_Delta\n", "major minor \n", "0.80 value -16.917 -12.447\n", "0.85 value -14.463 -9.735\n", "0.90 value -10.878 -6.747\n", "0.95 value -5.988 -3.495\n", "1.00 value 0.000 0.000\n", "1.05 value 6.945 3.708\n", "1.10 value 14.853 7.617\n", "1.15 value 23.529 11.691\n", "1.20 value 32.865 15.909" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "deltas.loc(axis=0)[:, 'value'] - benchvalue" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Copyright, License & Disclaimer**\n", "\n", "© Dr. Yves J. Hilpisch | The Python Quants GmbH\n", "\n", "DX Analytics (the \"dx library\" or \"dx package\") is licensed under the GNU Affero General\n", "Public License version 3 or later (see http://www.gnu.org/licenses/).\n", "\n", "DX Analytics comes with no representations or warranties, to the extent\n", "permitted by applicable law.\n", "\n", "http://tpq.io | [dx@tpq.io](mailto:team@tpq.io) |\n", "http://twitter.com/dyjh\n", "\n", "\"The
\n", "\n", "**Quant Platform** | http://pqp.io\n", "\n", "**Python for Finance Training** | http://training.tpq.io\n", "\n", "**Certificate in Computational Finance** | http://compfinance.tpq.io\n", "\n", "**Derivatives Analytics with Python (Wiley Finance)** |\n", "http://dawp.tpq.io\n", "\n", "**Python for Finance (2nd ed., O'Reilly)** |\n", "http://py4fi.tpq.io" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" } }, "nbformat": 4, "nbformat_minor": 1 }