CVA on an ipad Mini Part 3: XVA Algorithms Aarhus Kwant Factory PhD Course January 2014 Jesper Andreasen Danske Markets, Copenhagen kwant.daddy@danskebank.com
XVA Calculations The task is to compute T CVA E[ V( t) ( t) dt ] 0 At 10 out of 9 banks this is done by having quick models for computing Vt () for all t on all paths. This is doable and it gives job security: - Every time a new product comes along a new fast model for Vt () has to be developed and coded. - Massive amounts of hardware has to be used. 2
This is how pretty much all our competitors have designed their systems. For exotic products this approach starts running out of steam and many players (for example Barclays, BAML, Nordea, Murex, Numerix, etc) use the following approach: T C E[ V( t) ( t) dt ] 0... where V is a regression proxy for V which is obtained in a pre-simulation for each product. But in this, V needs to be a quite close (and stable) approximation of V for the calculation of E[ V( t ) ] not to go bananas due to some (or one) outlier/wing path. 3
This in turn creates a lot of work on the choice of regression basis and requires a lot of pre simulations => job security. 4
XVA Regressions Our approach is based on using the following T C E[ V( t) ( t) dt] 0 T E[ V( t) 1 ( t) dt] 0 Vt ( ) 0 regression proxy T T 0 t t futurecash flow Vt ( ) 0 T T E[ E [ c( u) du]1 ( t) dt] E[ c( u)1 ( t) dudt] 0 t Vt ( ) 0 T u E[ ( 1 ( t) dt) c( u) du] 0 0 Vt ( ) 0 CVA notional 5
We note that the approximation V is only used for determining whether V 0 We also note that the approach gives a lower bound. Effectively, what we are pricing is a contract that in case of counterparty default and portfolio value is positive to us, pays us the future cash-flows of the portfolio not the present value. Economically, there is no difference but we do not have to be able to accurately value the portfolio at default time only assess whether the portfolio has positive value to us and then simulate the cash flows. The first advantage of this is that the approximation V doesn t have to be accurate on the entire state space, it only needs to be accurate around V 0. 6
This in turn means that we do not have to work very hard on the regressions or use a very high number of pre simulations. We usually use 256-1024 pre simulations for the regressions. We have seen competitors that use 65,536 simulations in the regressions on their GPUs. 7
CVA Risk Our approach is based on using the following T C E[ V( t) ( t) dt] E[ V( t)1 ( t) dt ] 0 0 Vt ( ) 0 T... with equality only for V V. It follows that C 0 C 0 V V V V V V So if the approximation V is close to the true value around V 0, then the we can ignore re-estimating V during risk bumps. 8
Let a be a vector of parameters and let us write the CVA as C F( a, V( a), V( a )) We get C F F V F V a a V a V a dc duetochange dc duetochange 0 inbeast parameters in portfoliovalue peroptimality F F V a V a The quantity 9
F V V a... tells us what risks in the portfolio that affect the CVA and thus gives us ideas on how to restructure the portfolio to reduce the risks that affect the CVA. 10
Marginal Incremental CVA Consider the incremental CVA of changing the portfolio to V V W where 0, i.e. lim C lim { E[ [( V W)1 ]( t) ( t) dt]} 0 0 0 0 0 0 0 lim E[ [ W1 ( V W) ( V W)]( t) ( t) dt] V W 0 E[ [ W1 W1 1 V ( V)]( t) ( t) dt] V 0 V 0 W 0 E[ [ W1 W1 1 ]( t) ( t) dt] V V 0 V 0 W 0 For linear portfolios { Vt ( ) 0} has non-zero probability only if c( u) 0, u t. W 0 11
Hence, if T is the maturity of the original linear portfolio then the marginal incremental CVA splits in the two components 0 T 0 V 0 T W 0 F V on previousslides V a stand alonecva lim C E [ [ W 1 ]( t ) ( t ) dt ] E [ [ W 1 ]( t ) ( t ) dt ] If we write the original portfolio as V( t) ( S ( t) S (0)) A( t) A ( t) i i i i i i j j ATM swaps annuity positions V(0) V(0) A (0) 1 i Ai, S j i j 12
... then the marginal incremental CVA is individual par swaps and annuity trades are C F V W t A V(0) S t S A t lim, ( ) [ (0) 1 ]( ( ) (0)) ( ) 0 V S i i i i i Si lim C F V, W ( t ) [ V(0) ] A ( ) 0 i t V A S i i That is, for linear portfolios we can (more-or-less) read off the marginal CVA charge (+/-)for any vanilla trade from the risk report. So if we can create the risk reports quickly it will help us in structuring the client s portfolio. 13
Jive Infrastructure One of the primary advantages of the regression approach is that it fits (extremely) nice with the Danske infrastructure. Danske has since 2008 used a scripting language called Jive for all valuation in the quant library SuperFly. This includes everything that we trades from completely simple stuff such as FX forwards to exotic equity options. Vanilla trades typically get on-the-fly Ottomatically converted to Jive cash flows. We can reuse existing Ottomatic machinery that Jives the cash flows, we just need to modify the discounting of the simulated Jive cash flows. 14
Jive Overlay Note that there is a whole collection of different things that you want to compute once you can compute the CVA. After that you want the CVA, DVA, FVA, collateral options, CVA on collateralised counterparties, VaR, VaR on CVA, etc etc etc The new exotic are not the promised cash flows but how you discount them. This means that it makes a lot of sense give all xva calculations a Jive interface. This is what we have done with the sjivecva() function. 15
pos S S event rf_var regress() cva_ntl = cva_ntl + (1-recovery(enddate(), enddate(), SG))*(index(startdate(), startdate(), SG) - index(enddate(), enddate(), SG))*(proxy(RF_VAR)>0) pay var pay ntl rf_var 1 cva_var cva_ntl 16
This generates a script that looks something like 12-Jun-17 SWAP PAY(11JUN2018,CVG(12JUN2017,11JUN2018,ACT/360,),EUR) 12-Jun-17 _2 = CVG(12JUN2017,11JUN2018,ACT/360,) 11-Jun-18 RF_VAR REGRESS() 11-Jun-18 CVA_NTL = CVA_NTL + (1-RECOVERY(11JUN2018,11JUN2018,SG))*(INDEX(12JUN2017,12JUN2017,SG) - INDEX(11JUN2018,11JUN2018,SG))*(PROXY(RF_VAR)>0) 11-Jun-18 RF_VAR PAY(11JUN2018,1*_2,EUR,,"INT",11JUN2018,11JUN2018,) 11-Jun-18 CVA_VAR PAY(11JUN2018,CVA_NTL * _2,EUR) The structure is the following: - The yellow line is the original script. - The payment is recorded on the auxiliary variable _2 in the orange line. - The actual payment is executed on two extra variables RF_VAR and CVA_VAR in the blue lines. - The green lines specify how regressions and the CVA_NTL is updated. 17
Yellow, orange (with new var name) and blue lines are repeated for every payment. Green lines for other commands are inserted as specified by the user. Note that we can use existing Otto machinery we do not need to clone Otto to write the regression statements etc. The industrial kwant at work again! This methodology creates more lines of Jive to execute but it does not carry a higher overhead in terms market data that needs to be generated and stored during regressions. It ensures that the we correctly handle the accumulation of the CVA notional between fixing and payment. 18
...which is also useful for collateral options. 19
Regression Variables The regression variables are supplied by the Beast. Standard configuration is: - 1y and 30y zero rates for each currency. - Discount basis factor for each currency. - Fx rate for each currency pair. - Stochastic volatility factors. The actual zero rates used can be changed on the MFCs. The generated regression polynomial is only 1 st order but can be increased by the user on Beast level. 20
Note, however, that doing so can be criminal as the number of regression coefficients to be estimated will be squared. I.e. in this case (many) more pre simulations could be needed. Simulation: - Number of pre simulations.num PRE SIM = 256 - Number of simulations.num BATCH*.NUM SIM = 8*256 21
Compression Generally, the number of event dates and the amount of model data will increase linearly with the trade count and the length of the trades. For large portfolios we get to a situation where every date between here and maturity has to be simulated to and fixings have to be stored on. This is particularly a problem for the regressions because for these, bundles of paths need to be stored in the memory of the computer. However, nothing we compute here really needs daily resolution on the fixings, so it seems natural to try to standardise the dates that we simulate and the data that is being stored. 22
So the idea is to create super swaps where we distribute each payment to a standardised time and fixing grid, so that SWAP pay(1may2013, 1)...gets replaced by SWAP pay(1feb2013, 0.5) SWAP pay(1aug2013, 0.5) Further, if a portfolio consists of two swaps then we want to aggregate the pay statements so that SWAP1 pay(12aug2013, libor(),) SWAP2 pay(12aug2013, libor(),) 23
... gets replaced by PF pay(12aug2013, 2*libor(),) The idea was presented at Danske Kwant Fest (2012) by Alexander Antonov from NumeriX but I think the approach is wide spread. 24
Jive Compression Again, this task can be done without Otto intervention. First, we note that if a variable appears anywhere on the Right-Hand-Side in a Jive script, like VAR2 in VAR1 pay(12aug2014, VAR2) or VAR3 = 3*VAR2... then the payments of VAR2 cannot be compressed into payments on PF. 25
The visitor for analysing a Jive script for which variables can be compressed on is only 100 lines of code. 26
kjivecompressmachine, kjivecompressor, kjivecompresswriter The actual compression machinery is a bit more involved, about 2,000 lines of code. What it does is that it moves all dates inside fixings to be relative. For example 12may2013 SWAP pay(14aug2013, libor(12may2013, 14may2013, 14aug2013, ), )... is replaced by 1may2013 PF pay(fixdate(3m), 0.059783*libor(fixdate(), 2b, 3m), ) 1nov2013 PF pay(fixdate(3m), 0.940217*libor(fixdate(), 2b, 3m), ) 27
It is implemented as a special Jive evaluator that do +-*/ operations on map<string,double> rather than on double. 28
xva Calculation Summary Regressions are good but they have to be applied sensibly. Using the (near) optimality of the regressions largely simplify risk and marginal CVA calculations. Jive is the star of the show here. The SuperFly use of Jive for all model/product relation simplifies the CVA job greatly. By use of Jive we are able to strap on the xva calculations in a userconfigurable way. Jive also enables compression in a relatively painless way. 29
Compression is generally necessary even for 64 bit machinery.... and vice-versa: Some portfolios are so big that we need to run them on 64 bit machines even after compression. *LIVE* EXAMPLE. 30