SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
Danske Bank
Financial Cash-Flow Scripting:
Beyond Valuation
Antoine Savine
antoine@asavine.com
Scripting
Danske Bank
2
xVA, capital and other regulatory calculations:
Computational challenges
Challenge Industry standard Danske Bank
Thousands of heterogeneous
transactions:
aggregation, compression and
manipulation
? Scripting
Heavy, high dimensional Monte-Carlo:
hybrid models with multi-factor rates
Distributed parallelism Multithreaded
simulations
Sensitivity to thousands market variables Distributed bumping,
Increasingly AAD
AAD
Future PVs within simulations Nested simulations,
Closed-form
approximations,
Regression (LSM) proxies
Regression proxies
Accurate LSM proxies Large number of
simulations
Machine Learning:
auto-regularization,
deep ANNs
Mitigate inaccuracy of LSM proxies None POI (only in indicators)
Scripting
Danske Bank
3
Regulatory calculations on light hardware
• 2 Options:
1. Stitch exisiting FO systems, accumulate hardware, use large data centres
2. Rethink FO systems, write new algorithms to calculate accurately and quickly on light hardware
• Danske Bank invested on the second option
− Wrote FO and XVA system around:
model hierarchies, cash-flow scripting, multithreaded simulations, LSM and AAD
− Publically demonstrated sizeable netting set XVA on a laptop in seconds, full risk in minutes
− Gave series of talks titled ”XVA on iPad Mini”
− Won the In-House System of the Year 2015 Risk award
− Now publishing our solutions
Scripting
Danske Bank
4
Modern Computational Finance (Wiley, 2018)
• All about AAD
− Complete from mathematics to efficient implementation
− Detailed coverage of use in finance
− Textbook style with pedagogical explanations
− With complete, professional C++ code
• Parallel simulations
− How to write multithreaded programs in C++
− How to develop generic, efficient, parallel MC libraries
− Connection with AAD
• Curriculum for Numerical Finance,
MSc Mathematics-Economics,
Copenhagen University
Scripting
Danske Bank
5
Modern Computational Finance (Wiley, 2018)
All about scripting
− Textbook style with complete, pedagogical explanations
− Covers implementation in C++
− And use for risk management and XVA
− With complete, professional C++ code
Scripting
Danske Bank
6
Modern Computational Finance (Wiley, 2018)
Modern Computational Finance
LSM and other algorithms
For XVA, capital and regulatory calculations
Jesper Andreasen, Brian Huge
and Antoine Savine
Wiley, xMas 2018
• All about LSM
• Effective XVA calculation and differentiation
Scripting
Danske Bank
7
Introduction to Scripting
Scripting
Danske Bank
8
Financial Simulations and Modular Library Design
Models
Produce Scenarios
Linear Models
1 scenario : realizes forwards
Smile Models
All call prices for expiry T
Scenarios: 1 point from density
 ,C K T
 
 2
2
,
T
C K T
f x
K



Dynamic Models
Monte-Carlo simulations, scenario = random path
• Black-Scholes
• Bachelier
• Dupire
• Stoch. Vol.
• SLV
• Merton
• Rates (HJM/BGM)
• Multi-underlying
• Multi-currency  quanto effects
• Hybrid models: joint paths for rates, currencies and equities
dS S dW
dS dW
 ,dS S t dW
 0,dS S vdW dv k v v dt vdZ    
 ,dS S t vdW
dS S dW JdN dt   
Products
Cash Flows function(al)s of Scenario
Scenario
Market Variables on Event Dates
Scripting
Danske Bank
9
Loose Coupling and Product Scripting
• Loose Coupling
− Models = dynamics for state and market variables, know nothing about products
Responsibility: produce scenarios
− Products = cash flows as functions of path, know nothing about dynamics
Responsibility: compute payoff = sum of (numeraire discounted) cash flows, given scenario
− Value = expected payoff = approx. average among scenarios
− Communication only through scenarios
− Before simulations: Product communicates event dates and nature of market variables
− During simulations: Model generates scenarios = market variables on event dates
• Scripting
− A (programming?) language for describing the cash-flows of the Product
− Model agnostic
− Let users define products in real time
− Mix and match products and models on the fly
Scripting
Danske Bank
10
How does it work?
Model Product
Scenario
pays
var
opt
max
const
0
-
const
strike
spot
Parser
Expression Tree
Evaluator
-depth first visitor-
Scripting
Danske Bank
11
Visitors
• Expression Trees
− Store the structure of cash flows in their DNA
− Are not black boxes, trees can be traversed – or visited – in many ways
• Evaluation against a path = traversal of the tree
− Depth first: leaves to top
− Visit to nodes conduct calculations that determine payoff
− Picking market variables on the path
− And storing (intermediate) results on the stack
• Evaluation = one particular example of traversal
• Visitor = object that traverses nodes, (generally) depth first
− Collects information
− (Possibly modifies nodes)
− Maintains state
pays
var
opt
max
const
0
-
const
strike
spot
Scripting
Danske Bank
12
Visitors: Pre Processors
• Pre-processors do their work before simulations take place
• Pre-processors collect relevant information about the Product and:
− Perform all computations to prepare and optimize simulation-time calculations
− Conduct ”administrative” work: memory allocation, schedule generation, …
− Index all product and market variables so they are directly accessed in memory during simulations
− Example: ”x = x + y” becomes ”v[0] = v[0] + v[1]”
• Pre-processors is what make script valuation
virtually the same speed as hard coded payoffs
Scripting
Danske Bank
13
Visitors: Readers
Visitors don’t work with the script (as a string) but with the tree
Some visitors traverse trees and identify:
• Market variables for event dates  scenario definition + indexing
• Non linearities, path dependencies  model selection
• Dependecies between product variables  optimize LSM
• Value domain of product variables and expressions  required for fuzzy logic
• Schedule of fixings and payments  helps middle office processing
• And a lot more
Scripting
Danske Bank
14
Visitors: Modifiers
Other visitors modify trees directly :
For example, we use 3 visitors to compute xVA
• Aggregate cash-flows from transactions within a netting set
• Compress cash-flows to align fixings and payments on a master schedule
• Decorate transaction scripts to compute xVA and other regulatory calculations
Scripting
Danske Bank
15
Scripting is not only for Structuring and Exotics
• Not even that convenient for exotics
− Model still needs to be specified and calibrated so it is relevant for a particular Exotic
− Although (in theory) visitors can analyze cash-flows and select/calibrate model accordingly
− And we now have models that calibrate (decently) to everything
• What scripting offers is
− A consistent representation of all transactions
− Down to cash flows
− That can be read and modified by visitors
• Scripts are best suited as an internal representation of transactions
• This versatility is generally not well known
− No publication on the subject
− No active development in most houses
− Tendency to limit usage to the structuring of exotics
Scripting
Danske Bank
16
Script Examples: equity/commodity/forex
predefined vectors
vectors
loops
Scripting
Danske Bank
17
Script Examples: Rates
Scripting
Danske Bank
18
Script Examples: LSM
LSM
Regression
proxies
LSM
− Founding Papers
Carriere, 1996
Longstaff & Schwartz, 2001
− Modern Implementation
Differentiation
and Application to xVA
Andreasen, Huge & Savine
Wiley, 2018
Scripting
Danske Bank
19
xVA
Scripting
Danske Bank
20
xVA
• (Idealized, one-sided, uncollateralized) CVA =
contingent to default
0 strike put
on the future value of the netting set
• Payoff =
• Value (CVA) =
• Where
     1
1 R 1 max 0,p pp p
RN
T TT T
p
E V  
 
 
 

     1
exposure date
recovery exposuredefault indicator
loss given default (LGD)
1 1 max 0,p pp p
T TT T
p
R V  

p p
k P
RN
T T k
T T
V E CF

 
  
 

Scripting
Danske Bank
21
Rewriting xVA
• (Idealized) CVA
• Using
• Injecting V (not in indicator)
• Using boxed expectations
• Reversing sums
• CVA = value of the cash flows discounted by path-dependent process h
• Note future PV V
− Only intervenes in the equation for h
− And only inside positivity indicator
     1
1 R 1 max 0, ,p p p pp p
k P
RN RN
T T T T kT T
p T T
CVA E V V E CF  

  
     
   
 
     1 0
1 R 1 1p pp p Tp
RN
T TT T V
p
CVA E V   
 
  
 
   0
1 x
x x



     1 0
1 R 1 1p pp p Tp
k P
RN RN
T T kT T V
p T T
CVA E E CF   

   
   
   
 
     1 0
1 R 1 1p p p Tp
k P
RN
T kT T V
p T T
CVA E CF   

  
  
  
 
     
           
1
1
1 1 1
1
0
0
0
0
1 R 1 1
0
where 1 R 1 1 or
1 R 1 1
p p p Tp
P k
k k p p p Tp
i i iP k i i Ti
RN
T kT T V
k T T
RN
T k T T T T V
T T Tk T T T T V
CVA E CF
E CF



h
h h
h h


  

  

  
   
   
   
   
  
         
 
 
Scripting
Danske Bank
22
POI: Proxies only in Indicators
• Using LSM proxies directly in
− Accuracy of CVA depends on the accuracy of proxy (to the 1st order both in bias and stderr)
− Either spend massive CPU time in LSM to produce accurate proxies or accept the inaccuracy
• If we use proxies only in indicators
− Accuracy of CVA independent (to 1the 1st order) on the accuracy of the proxy
− We have an accurate CVA even with quick proxies
     1
1 R 1 max 0, pp p p
RN
T T T
p
TVCVA E   
 
  
 

         
            
       
0
0
0 1 , 0 1 0
0 0
0
0
proxy error
1st order exposure err 1 1or
V
V
P V E corr P V P V Var
P V E corr V s d
V
P t
V V
E V E V E V E V E
  
 

  

  
 
       
   

 
         
 
 
            0 00
0
proxy error
1st order exposure error 1 11 V VV
V V
E E V E V VV V E V E V V  

 


  
 
       
      
Scripting
Danske Bank
23
POI: illustration
• Example: biased proxy
− Call on V, strike K
− Our proxy is biased:
• Strategy 1: use proxy in payoff
− Wrong strike:
− Error magnitude: , order m
• Strategy 2: use proxy in indicator
− Proxy payoff:
− Error magnitude: , order
V V m 
   V K V K m
 
     
m
   1 KV
KV

  2
dens V K m 
2
m
Scripting
Danske Bank
24
Putting it all together
• CVA = value of cash-flows discounted with path-dependent process h
• Using LSM proxies in place of future PVs:
• We end up with an algorithm that is:
− Accurate: (to the 1st order) proxies are only used in indicators
− Efficient: value xVA for the cost of netting set valuation (+ simulation of discounting process)
− Practical: CF valuation scripts are decorated so payments are discounted by h
• The same holds for some other xVAs
− Immediate for DVA, FVA
− With adjustments for RWA, kVA (see Flyger-Huge-Savine, 2015-2016)
     1 0
where 1 R 1 1k k p p p Tp
P k
RN
T k T T T T V
k T T
CVA E CF 
h h
   

 
   
 
 
     1 0
1 R 1 1
T
k p p p
p
P k
T T T T
T
V
T

h
   

 
Scripting
Danske Bank
25
xVA with Collateral
• Fully collateralized CVA with MPR q:
• That cannot be directly written as
− Consider one exposure:
− The LHS can be rewritten as previously
− But the not the RHS because is not T*- q –measurable so
     1
1 R 1 max 0,p pp p pT TT T
p
TCVA E V V 
 
 
  




kT k
k
CVA E CFh
 
  
 

       ** * * ** * ** max 0 1, 1 T T T T TVV VT T TV
e T E V V E V E V      
        
 
 
 * *
1 T TV V q
 * *
*
1
T T
k
kV V
T T
LHS E CF


 
  
 

 * *
* *
*
1
T T
k
T T kV V
T T
RHS E E E CF

 
 

            

Scripting
Danske Bank
26
Branching Simulations
• Branching (McKean 1975, Henry-Labordere 2012)
− For each path, also generate one Branch that “sticks out” at margin date…
− And starts a parallel path that obeys the same SDE but independently from the main path
• Branching is not like nested simulations
− For every path, we only generate one Branch (per margin date) as part of that simulation
− Averaging is correctly performed by the outer expectation operator
Scripting
Danske Bank
27
Branching Proxies
• Consider a proxy picked on a secondary branch
− Constructed with the same regression coefficients, but regression variables simulated on the branch
− Conditionally to filtration at the margin date , the main and secondary branches are:
− Independent
− Identically distributed
• We can now compute the RHS from the collateralized exposure equation
mrg
T T  
Scripting
Danske Bank
28
Branching Solution
• We finally get the complete formula for the collateralized exposure
• And the collateralized CVA
• All the comments from the uncollateralized case apply
− Essentially the same algorithm
− Except the discounting process is simulated with branches
kT k
k
CVA E CFh
 
  
 

Scripting
Danske Bank
29
Practical xVA: Aggregation
• Before computing xVA, all transactions in a netting set must be aggregated
• This is generally a conundrum
• Scripted transactions are relatively easy to merge
• Note we need a proper visitor
− Merging scripts is not enough
− We must also duplicate all payments on a single variable that represents the netting set
Scripting
Danske Bank
30
Practical xVA: Compression
• Avoid linear growth of CPU and memory load with number of transactions
• Align event dates on a master schedule
• De-interpolate fixings and payments on surrounding dates
in the master schedule
• Aggregate notionals
• We call this process “compression”
− Conducted by specialized (and complicated) visitors
− Fully automated leveraging on the visitor design
Scripting
Danske Bank
31
Practical xVA: Decoration
• We have our (compressed) schedule for all cash flows in the NS:
• We want to compute:
     10 1 0
0, 1 R 1
k
i i i Ti
T k
k
T T T i i V
CVA E CF
S T S T
h
h h h  
 
  
 
        

Scripting
Danske Bank
32
Decoration (2)
• We duplicate all payments, multiply them by h:
• And add an additional schedule for the simulation of h:
• This is conducted by a dedicated visitor called decorator
Scripting
Danske Bank
33
Fuzzy Logic
Scripting
Danske Bank
34
Discontinuous payoffs with Monte-Carlo
• Discontinuous profiles produce unstable risks with Monte-Carlo
− Example: 110 1y Digital in Black-Scholes MC, vol = 20%
− 10,000 to 250,000 simulations
− Seed changed between pricings
− Decent convergence on price, risk all over the place
Scripting
Danske Bank
Payoff smoothing
35
• Payoff smoothing is a simple (and yet surprinsingly effective) method:
Replace discontinuous payoffs by ”close” continuous ones
− Digital  Call spread
− Barrier  Smooth barrier
• One benefit: work on payoffs only, no work required on models
• One problem: must identify and smooth all discontinuities
• Today, this is a manual process:
Traders rewrite payoffs one by one
using a ”call-spread” or ”smooth” function:
smooth(x,p,n,e)
=
0 e/2-e/2
n
p
x
Scripting
Danske Bank
Smoothing a digital
36
• Digital  Call Spread
• Dig =
 CS = finite difference continuous approximation
• Alt. interpretation: spread the notional
evenly across strikes between (K-e/2,K+e/2)
C
K



Scripting
Danske Bank
Smoothing a barrier
37
• Spread notional across barriers in (B-/2,B+/2)
• Example: 1y 110-120 RKO in Black-Scholes (20%)
• Weekly monitoring, barrier shifted by 0.60 std
• Smooth barrier: knock-out part of the notional
depending on how far we land in (B-/2,B+/2)
total KO
partial KO
no KO
Scripting
Danske Bank
Smoothing everything
38
• Many transactions with discontinuous profile besides digitals and barriers
• Popular example: simplified Autocallable
− If spot declines 3 years in a row, lose 50% of notional
− Otherwise make 10% per annum until spot raises above initial level
• All those products can’t be reliably risk managed unless smoothed
• Traders must manually apply smoothing for every (type of) transaction
• We describe that process, assuming a scripting platform
Scripting
Danske Bank
Identifying discontinuities
39
• In programming, incl. scripting, discontinuities come from control flow
− If this then that pattern
− Calls to discontinuous functions (meaning themselves implement if this then that statements)
• Autocallable:
− 3 control flows
− Unstable risk
Scripting
Danske Bank
Manual smoothing
40
• Replace if this then that by smooth (remindeer: smooth = ”call spread” function)
• Does the job, but hard to write and read and error prone, even in simple cases
smooth(x,p,n,e)
=
0 e/2-e/2
n
p
x
Scripting
Danske Bank
Automatic smoothing
41
• Automatically turn
− Nice, easy, natural scripts
− Into smoothed scripts that produce stable risks
• Visitor technology means :
Program knows the script and can apply smoothing the same way traders do
• In practice, rule based algorithms invalidated by counter examples
Scripting
Danske Bank
Fuzzy Logic to the rescue
42
• The one realization that brings everything together:
smoothing = use of Fuzzy Logic
• In classical (sharp) logic, a condition is true or false
− Schrodinger’s cat is dead or alive
• In fuzzy logic, a condition is true to a degree = degree of truth or DT
− Schrodinger’s cat is dead and alive
− For instance, it can be alive with DT 65% and dead with DT 35%
• Note: DT is not a probability
 Financial interpretation: condition applies to DT% of the notional
− A barrier is 65% alive means 35% of the notional knocked out, the rest is still going
− It does not mean that it is hit with proba 35%, which makes no sense on a given scenario
Scripting
Danske Bank
Fuzzy Logic
43
• Invented in the 1960s by Lotfi Zadeh
• Not to smooth financial risks
• But to build the first expert systems
• Automate expert opinions
− Expert: it is dangerous for the engine to be fast and hot
− Programmer: what do you mean by ”fast” and ”hot”?
− Expert: say fast = ”>100mph” and hot = ”>50C”
Code: if speed > 100 and heat > 50 then danger = true else danger = false endIf
Makes no sense: (99.9,90)  safe, (100.1,50.1)  dangerous !!
Scripting
Danske Bank
 
 
1 2 1 2
1 2 1 2 1 2or
DT C and C DT DT
DT C C DT DT DT DT
 
   
More Fuzzy Logic
44
• With fuzzy logic:
− isFast and isHot are DTs = smooth functions resp. of speed and heat valued in [0,1]
− DTs combine like booleans alt.
Code: isDangerous = fuzzyAnd( isFast( speed), isHot( heat))
Results make sense: (99.9,90)  50% dangerous, (100.1,50.1)  25% dangerous
   
   
1 2 1 2
1 2 1 2
min ,
or max ,
DT C and C DT DT
DT C C DT DT


Scripting
Danske Bank
Smoothing = Fuzzy Logic
45
• Remarkable result:
established smoothing exactly is application of Fuzzy Logic
 Digital smoothing = apply fuzzy logic to if spot>strike then pay 1
 Barrier smoothing = apply fuzzy logic to if spot>barrier then alive = 0
• That explains, in hindsight, why smoothing performs so remarkably well
 Not a hack
 (In hindsight) based on established scientific theory
• And gives us the means to correctly, automatically smooth everything
 Smoothing everything = apply fuzzy logic to the evaluation of all conditions
 Without modifying scripts in any way
We derive the evaluator into a fuzzy evaluator that overrides visits to if
nodes and conditions and evaluates them with Fuzzy Logic
Scripting
Danske Bank
Evaluation of ”if this then that” with fuzzy logic
46
• Evaluation with sharp logic
1. Evaluate condition C
2. If C is true, evaluate statements between then and else or endIf
3. If C is false, evaluate statements between else and endIf if any
• Evaluation with fuzzy logic
1. Record state S0 (all variables and products) just before the ”if” statement
2. Evaluate the degree of truth (DT) of the condition
3. Evaluate ”if true” statements
4. Record resulting state S1
5. Restore state to S0
6. Evaluate ”else” statements if any
7. Record resulting state S2
8. Set final state S = DT * S1 + (1-DT) * S2
Scripting
Danske Bank
Fuzzy Logic : results
47
• No modification to scripts
• Override evaluation of if this then that statements, conditions and combinators
• Effectively stabilises risks sensitivities with minimal PV impact
• (With proper optimization) just as fast as normal
• Easily flick between sharp (pricing) and fuzzy (risk) evaluation
Scripting
Danske Bank
48
Thank You
scriptingCentral@asavine.com

Weitere ähnliche Inhalte

Was ist angesagt?

EPS Liquidity Risk Management Implementation for FBOs-client presentation
EPS Liquidity Risk Management Implementation for FBOs-client presentationEPS Liquidity Risk Management Implementation for FBOs-client presentation
EPS Liquidity Risk Management Implementation for FBOs-client presentation
sarojkdas
 

Was ist angesagt? (20)

Cancelable Swap Valuation and Risk
Cancelable Swap Valuation and RiskCancelable Swap Valuation and Risk
Cancelable Swap Valuation and Risk
 
Lf 2020 options
Lf 2020 optionsLf 2020 options
Lf 2020 options
 
Counterparty Credit Risk and CVA under Basel III
Counterparty Credit Risk and CVA under Basel IIICounterparty Credit Risk and CVA under Basel III
Counterparty Credit Risk and CVA under Basel III
 
Credit risk (2)
Credit risk (2)Credit risk (2)
Credit risk (2)
 
Interest rate risk teacher edition
Interest rate risk teacher editionInterest rate risk teacher edition
Interest rate risk teacher edition
 
Lf 2020 bachelier
Lf 2020 bachelierLf 2020 bachelier
Lf 2020 bachelier
 
Cmt learning objective 14 applied cycle analysis
Cmt learning objective 14   applied cycle analysisCmt learning objective 14   applied cycle analysis
Cmt learning objective 14 applied cycle analysis
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
FRTB Capital Charge
FRTB Capital ChargeFRTB Capital Charge
FRTB Capital Charge
 
FRTB
FRTBFRTB
FRTB
 
Cardiology Quizzes Tips, first edition
Cardiology Quizzes Tips,  first editionCardiology Quizzes Tips,  first edition
Cardiology Quizzes Tips, first edition
 
FRTB - Market Risk Capital Charge Calculation
FRTB - Market Risk Capital Charge CalculationFRTB - Market Risk Capital Charge Calculation
FRTB - Market Risk Capital Charge Calculation
 
Value At Risk Sep 22
Value At Risk Sep 22Value At Risk Sep 22
Value At Risk Sep 22
 
Chapter 17
Chapter 17Chapter 17
Chapter 17
 
Understanding VC Term Sheets
Understanding VC Term SheetsUnderstanding VC Term Sheets
Understanding VC Term Sheets
 
financial institutions and markets
financial institutions and markets financial institutions and markets
financial institutions and markets
 
EPS Liquidity Risk Management Implementation for FBOs-client presentation
EPS Liquidity Risk Management Implementation for FBOs-client presentationEPS Liquidity Risk Management Implementation for FBOs-client presentation
EPS Liquidity Risk Management Implementation for FBOs-client presentation
 
Chapter11 International Finance Management
Chapter11 International Finance ManagementChapter11 International Finance Management
Chapter11 International Finance Management
 
XVA, The Front Office Way
XVA, The Front Office WayXVA, The Front Office Way
XVA, The Front Office Way
 
Handbook of credit derivatives and structured credit strategies, Morgan Stanl...
Handbook of credit derivatives and structured credit strategies, Morgan Stanl...Handbook of credit derivatives and structured credit strategies, Morgan Stanl...
Handbook of credit derivatives and structured credit strategies, Morgan Stanl...
 

Ähnlich wie Financial Cash-Flow Scripting: Beyond Valuation by Antoine Savine

Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...
Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...
Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...
Flink Forward
 
Streaming Analytics and Internet of Things - Geesara Prathap
Streaming Analytics and Internet of Things - Geesara PrathapStreaming Analytics and Internet of Things - Geesara Prathap
Streaming Analytics and Internet of Things - Geesara Prathap
WithTheBest
 

Ähnlich wie Financial Cash-Flow Scripting: Beyond Valuation by Antoine Savine (20)

GOTO 2016_real_final
GOTO 2016_real_finalGOTO 2016_real_final
GOTO 2016_real_final
 
HBaseCon2017 Quanta: Quora's hierarchical counting system on HBase
HBaseCon2017 Quanta: Quora's hierarchical counting system on HBaseHBaseCon2017 Quanta: Quora's hierarchical counting system on HBase
HBaseCon2017 Quanta: Quora's hierarchical counting system on HBase
 
Data Stream Management
Data Stream ManagementData Stream Management
Data Stream Management
 
James Tomaney - Automated Testing for the ATM Channel
James Tomaney - Automated Testing for the ATM Channel James Tomaney - Automated Testing for the ATM Channel
James Tomaney - Automated Testing for the ATM Channel
 
Managing Large Scale Financial Time-Series Data with Graphs
Managing Large Scale Financial Time-Series Data with Graphs Managing Large Scale Financial Time-Series Data with Graphs
Managing Large Scale Financial Time-Series Data with Graphs
 
SWEET - A Tool for WCET Flow Analysis - Björn Lisper
SWEET - A Tool for WCET Flow Analysis - Björn LisperSWEET - A Tool for WCET Flow Analysis - Björn Lisper
SWEET - A Tool for WCET Flow Analysis - Björn Lisper
 
Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...
Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...
Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...
 
Lec13
Lec13Lec13
Lec13
 
Differential Machine Learning Masterclass
Differential Machine Learning MasterclassDifferential Machine Learning Masterclass
Differential Machine Learning Masterclass
 
Streaming Analytics and Internet of Things - Geesara Prathap
Streaming Analytics and Internet of Things - Geesara PrathapStreaming Analytics and Internet of Things - Geesara Prathap
Streaming Analytics and Internet of Things - Geesara Prathap
 
c-quilibrium R forecasting integration
c-quilibrium R forecasting integrationc-quilibrium R forecasting integration
c-quilibrium R forecasting integration
 
Springone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and ReactorSpringone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and Reactor
 
Using Graph Analysis and Fraud Detection in the Fintech Industry
Using Graph Analysis and Fraud Detection in the Fintech IndustryUsing Graph Analysis and Fraud Detection in the Fintech Industry
Using Graph Analysis and Fraud Detection in the Fintech Industry
 
Using Graph Analysis and Fraud Detection in the Fintech Industry
Using Graph Analysis and Fraud Detection in the Fintech IndustryUsing Graph Analysis and Fraud Detection in the Fintech Industry
Using Graph Analysis and Fraud Detection in the Fintech Industry
 
Introduction to-vhdl
Introduction to-vhdlIntroduction to-vhdl
Introduction to-vhdl
 
The End of a Myth: Ultra-Scalable Transactional Management
The End of a Myth: Ultra-Scalable Transactional ManagementThe End of a Myth: Ultra-Scalable Transactional Management
The End of a Myth: Ultra-Scalable Transactional Management
 
Architectual Comparison of Apache Apex and Spark Streaming
Architectual Comparison of Apache Apex and Spark StreamingArchitectual Comparison of Apache Apex and Spark Streaming
Architectual Comparison of Apache Apex and Spark Streaming
 
Distributed Caches: A Developer’s Guide to Unleashing Your Data in High-Perfo...
Distributed Caches: A Developer’s Guide to Unleashing Your Data in High-Perfo...Distributed Caches: A Developer’s Guide to Unleashing Your Data in High-Perfo...
Distributed Caches: A Developer’s Guide to Unleashing Your Data in High-Perfo...
 
Data streaming fundamentals- EUDAT Summer School (Giuseppe Fiameni, CINECA)
Data streaming fundamentals- EUDAT Summer School (Giuseppe Fiameni, CINECA)Data streaming fundamentals- EUDAT Summer School (Giuseppe Fiameni, CINECA)
Data streaming fundamentals- EUDAT Summer School (Giuseppe Fiameni, CINECA)
 
Dubbo and Weidian's practice on micro-service architecture
Dubbo and Weidian's practice on micro-service architectureDubbo and Weidian's practice on micro-service architecture
Dubbo and Weidian's practice on micro-service architecture
 

Kürzlich hochgeladen

VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
dipikadinghjn ( Why You Choose Us? ) Escorts
 
VIP Call Girl Service Andheri West ⚡ 9920725232 What It Takes To Be The Best ...
VIP Call Girl Service Andheri West ⚡ 9920725232 What It Takes To Be The Best ...VIP Call Girl Service Andheri West ⚡ 9920725232 What It Takes To Be The Best ...
VIP Call Girl Service Andheri West ⚡ 9920725232 What It Takes To Be The Best ...
dipikadinghjn ( Why You Choose Us? ) Escorts
 
VIP Independent Call Girls in Mira Bhayandar 🌹 9920725232 ( Call Me ) Mumbai ...
VIP Independent Call Girls in Mira Bhayandar 🌹 9920725232 ( Call Me ) Mumbai ...VIP Independent Call Girls in Mira Bhayandar 🌹 9920725232 ( Call Me ) Mumbai ...
VIP Independent Call Girls in Mira Bhayandar 🌹 9920725232 ( Call Me ) Mumbai ...
dipikadinghjn ( Why You Choose Us? ) Escorts
 

Kürzlich hochgeladen (20)

Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
 
WhatsApp 📞 Call : 9892124323 ✅Call Girls In Chembur ( Mumbai ) secure service
WhatsApp 📞 Call : 9892124323  ✅Call Girls In Chembur ( Mumbai ) secure serviceWhatsApp 📞 Call : 9892124323  ✅Call Girls In Chembur ( Mumbai ) secure service
WhatsApp 📞 Call : 9892124323 ✅Call Girls In Chembur ( Mumbai ) secure service
 
The Economic History of the U.S. Lecture 20.pdf
The Economic History of the U.S. Lecture 20.pdfThe Economic History of the U.S. Lecture 20.pdf
The Economic History of the U.S. Lecture 20.pdf
 
Top Rated Pune Call Girls Sinhagad Road ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Sinhagad Road ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Sinhagad Road ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Sinhagad Road ⟟ 6297143586 ⟟ Call Me For Genuine S...
 
The Economic History of the U.S. Lecture 30.pdf
The Economic History of the U.S. Lecture 30.pdfThe Economic History of the U.S. Lecture 30.pdf
The Economic History of the U.S. Lecture 30.pdf
 
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
 
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
 
VIP Call Girl Service Andheri West ⚡ 9920725232 What It Takes To Be The Best ...
VIP Call Girl Service Andheri West ⚡ 9920725232 What It Takes To Be The Best ...VIP Call Girl Service Andheri West ⚡ 9920725232 What It Takes To Be The Best ...
VIP Call Girl Service Andheri West ⚡ 9920725232 What It Takes To Be The Best ...
 
Stock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdfStock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdf
 
VIP Independent Call Girls in Mira Bhayandar 🌹 9920725232 ( Call Me ) Mumbai ...
VIP Independent Call Girls in Mira Bhayandar 🌹 9920725232 ( Call Me ) Mumbai ...VIP Independent Call Girls in Mira Bhayandar 🌹 9920725232 ( Call Me ) Mumbai ...
VIP Independent Call Girls in Mira Bhayandar 🌹 9920725232 ( Call Me ) Mumbai ...
 
Call Girls in New Friends Colony Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escort...
Call Girls in New Friends Colony Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escort...Call Girls in New Friends Colony Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escort...
Call Girls in New Friends Colony Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escort...
 
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
 
Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
 
The Economic History of the U.S. Lecture 26.pdf
The Economic History of the U.S. Lecture 26.pdfThe Economic History of the U.S. Lecture 26.pdf
The Economic History of the U.S. Lecture 26.pdf
 
Indore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdfIndore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdf
 
The Economic History of the U.S. Lecture 17.pdf
The Economic History of the U.S. Lecture 17.pdfThe Economic History of the U.S. Lecture 17.pdf
The Economic History of the U.S. Lecture 17.pdf
 
Booking open Available Pune Call Girls Shivane 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Shivane  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Shivane  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Shivane 6297143586 Call Hot Indian Gi...
 
Gurley shaw Theory of Monetary Economics.
Gurley shaw Theory of Monetary Economics.Gurley shaw Theory of Monetary Economics.
Gurley shaw Theory of Monetary Economics.
 
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Booking
 
Kharghar Blowjob Housewife Call Girls NUmber-9833754194-CBD Belapur Internati...
Kharghar Blowjob Housewife Call Girls NUmber-9833754194-CBD Belapur Internati...Kharghar Blowjob Housewife Call Girls NUmber-9833754194-CBD Belapur Internati...
Kharghar Blowjob Housewife Call Girls NUmber-9833754194-CBD Belapur Internati...
 

Financial Cash-Flow Scripting: Beyond Valuation by Antoine Savine

  • 1. Danske Bank Financial Cash-Flow Scripting: Beyond Valuation Antoine Savine antoine@asavine.com
  • 2. Scripting Danske Bank 2 xVA, capital and other regulatory calculations: Computational challenges Challenge Industry standard Danske Bank Thousands of heterogeneous transactions: aggregation, compression and manipulation ? Scripting Heavy, high dimensional Monte-Carlo: hybrid models with multi-factor rates Distributed parallelism Multithreaded simulations Sensitivity to thousands market variables Distributed bumping, Increasingly AAD AAD Future PVs within simulations Nested simulations, Closed-form approximations, Regression (LSM) proxies Regression proxies Accurate LSM proxies Large number of simulations Machine Learning: auto-regularization, deep ANNs Mitigate inaccuracy of LSM proxies None POI (only in indicators)
  • 3. Scripting Danske Bank 3 Regulatory calculations on light hardware • 2 Options: 1. Stitch exisiting FO systems, accumulate hardware, use large data centres 2. Rethink FO systems, write new algorithms to calculate accurately and quickly on light hardware • Danske Bank invested on the second option − Wrote FO and XVA system around: model hierarchies, cash-flow scripting, multithreaded simulations, LSM and AAD − Publically demonstrated sizeable netting set XVA on a laptop in seconds, full risk in minutes − Gave series of talks titled ”XVA on iPad Mini” − Won the In-House System of the Year 2015 Risk award − Now publishing our solutions
  • 4. Scripting Danske Bank 4 Modern Computational Finance (Wiley, 2018) • All about AAD − Complete from mathematics to efficient implementation − Detailed coverage of use in finance − Textbook style with pedagogical explanations − With complete, professional C++ code • Parallel simulations − How to write multithreaded programs in C++ − How to develop generic, efficient, parallel MC libraries − Connection with AAD • Curriculum for Numerical Finance, MSc Mathematics-Economics, Copenhagen University
  • 5. Scripting Danske Bank 5 Modern Computational Finance (Wiley, 2018) All about scripting − Textbook style with complete, pedagogical explanations − Covers implementation in C++ − And use for risk management and XVA − With complete, professional C++ code
  • 6. Scripting Danske Bank 6 Modern Computational Finance (Wiley, 2018) Modern Computational Finance LSM and other algorithms For XVA, capital and regulatory calculations Jesper Andreasen, Brian Huge and Antoine Savine Wiley, xMas 2018 • All about LSM • Effective XVA calculation and differentiation
  • 8. Scripting Danske Bank 8 Financial Simulations and Modular Library Design Models Produce Scenarios Linear Models 1 scenario : realizes forwards Smile Models All call prices for expiry T Scenarios: 1 point from density  ,C K T    2 2 , T C K T f x K    Dynamic Models Monte-Carlo simulations, scenario = random path • Black-Scholes • Bachelier • Dupire • Stoch. Vol. • SLV • Merton • Rates (HJM/BGM) • Multi-underlying • Multi-currency  quanto effects • Hybrid models: joint paths for rates, currencies and equities dS S dW dS dW  ,dS S t dW  0,dS S vdW dv k v v dt vdZ      ,dS S t vdW dS S dW JdN dt    Products Cash Flows function(al)s of Scenario Scenario Market Variables on Event Dates
  • 9. Scripting Danske Bank 9 Loose Coupling and Product Scripting • Loose Coupling − Models = dynamics for state and market variables, know nothing about products Responsibility: produce scenarios − Products = cash flows as functions of path, know nothing about dynamics Responsibility: compute payoff = sum of (numeraire discounted) cash flows, given scenario − Value = expected payoff = approx. average among scenarios − Communication only through scenarios − Before simulations: Product communicates event dates and nature of market variables − During simulations: Model generates scenarios = market variables on event dates • Scripting − A (programming?) language for describing the cash-flows of the Product − Model agnostic − Let users define products in real time − Mix and match products and models on the fly
  • 10. Scripting Danske Bank 10 How does it work? Model Product Scenario pays var opt max const 0 - const strike spot Parser Expression Tree Evaluator -depth first visitor-
  • 11. Scripting Danske Bank 11 Visitors • Expression Trees − Store the structure of cash flows in their DNA − Are not black boxes, trees can be traversed – or visited – in many ways • Evaluation against a path = traversal of the tree − Depth first: leaves to top − Visit to nodes conduct calculations that determine payoff − Picking market variables on the path − And storing (intermediate) results on the stack • Evaluation = one particular example of traversal • Visitor = object that traverses nodes, (generally) depth first − Collects information − (Possibly modifies nodes) − Maintains state pays var opt max const 0 - const strike spot
  • 12. Scripting Danske Bank 12 Visitors: Pre Processors • Pre-processors do their work before simulations take place • Pre-processors collect relevant information about the Product and: − Perform all computations to prepare and optimize simulation-time calculations − Conduct ”administrative” work: memory allocation, schedule generation, … − Index all product and market variables so they are directly accessed in memory during simulations − Example: ”x = x + y” becomes ”v[0] = v[0] + v[1]” • Pre-processors is what make script valuation virtually the same speed as hard coded payoffs
  • 13. Scripting Danske Bank 13 Visitors: Readers Visitors don’t work with the script (as a string) but with the tree Some visitors traverse trees and identify: • Market variables for event dates  scenario definition + indexing • Non linearities, path dependencies  model selection • Dependecies between product variables  optimize LSM • Value domain of product variables and expressions  required for fuzzy logic • Schedule of fixings and payments  helps middle office processing • And a lot more
  • 14. Scripting Danske Bank 14 Visitors: Modifiers Other visitors modify trees directly : For example, we use 3 visitors to compute xVA • Aggregate cash-flows from transactions within a netting set • Compress cash-flows to align fixings and payments on a master schedule • Decorate transaction scripts to compute xVA and other regulatory calculations
  • 15. Scripting Danske Bank 15 Scripting is not only for Structuring and Exotics • Not even that convenient for exotics − Model still needs to be specified and calibrated so it is relevant for a particular Exotic − Although (in theory) visitors can analyze cash-flows and select/calibrate model accordingly − And we now have models that calibrate (decently) to everything • What scripting offers is − A consistent representation of all transactions − Down to cash flows − That can be read and modified by visitors • Scripts are best suited as an internal representation of transactions • This versatility is generally not well known − No publication on the subject − No active development in most houses − Tendency to limit usage to the structuring of exotics
  • 16. Scripting Danske Bank 16 Script Examples: equity/commodity/forex predefined vectors vectors loops
  • 18. Scripting Danske Bank 18 Script Examples: LSM LSM Regression proxies LSM − Founding Papers Carriere, 1996 Longstaff & Schwartz, 2001 − Modern Implementation Differentiation and Application to xVA Andreasen, Huge & Savine Wiley, 2018
  • 20. Scripting Danske Bank 20 xVA • (Idealized, one-sided, uncollateralized) CVA = contingent to default 0 strike put on the future value of the netting set • Payoff = • Value (CVA) = • Where      1 1 R 1 max 0,p pp p RN T TT T p E V               1 exposure date recovery exposuredefault indicator loss given default (LGD) 1 1 max 0,p pp p T TT T p R V    p p k P RN T T k T T V E CF         
  • 21. Scripting Danske Bank 21 Rewriting xVA • (Idealized) CVA • Using • Injecting V (not in indicator) • Using boxed expectations • Reversing sums • CVA = value of the cash flows discounted by path-dependent process h • Note future PV V − Only intervenes in the equation for h − And only inside positivity indicator      1 1 R 1 max 0, ,p p p pp p k P RN RN T T T T kT T p T T CVA E V V E CF                        1 0 1 R 1 1p pp p Tp RN T TT T V p CVA E V              0 1 x x x         1 0 1 R 1 1p pp p Tp k P RN RN T T kT T V p T T CVA E E CF                        1 0 1 R 1 1p p p Tp k P RN T kT T V p T T CVA E CF                                  1 1 1 1 1 1 0 0 0 0 1 R 1 1 0 where 1 R 1 1 or 1 R 1 1 p p p Tp P k k k p p p Tp i i iP k i i Ti RN T kT T V k T T RN T k T T T T V T T Tk T T T T V CVA E CF E CF    h h h h h                                              
  • 22. Scripting Danske Bank 22 POI: Proxies only in Indicators • Using LSM proxies directly in − Accuracy of CVA depends on the accuracy of proxy (to the 1st order both in bias and stderr) − Either spend massive CPU time in LSM to produce accurate proxies or accept the inaccuracy • If we use proxies only in indicators − Accuracy of CVA independent (to 1the 1st order) on the accuracy of the proxy − We have an accurate CVA even with quick proxies      1 1 R 1 max 0, pp p p RN T T T p TVCVA E                                           0 0 0 1 , 0 1 0 0 0 0 0 proxy error 1st order exposure err 1 1or V V P V E corr P V P V Var P V E corr V s d V P t V V E V E V E V E V E                                                         0 00 0 proxy error 1st order exposure error 1 11 V VV V V E E V E V VV V E V E V V                           
  • 23. Scripting Danske Bank 23 POI: illustration • Example: biased proxy − Call on V, strike K − Our proxy is biased: • Strategy 1: use proxy in payoff − Wrong strike: − Error magnitude: , order m • Strategy 2: use proxy in indicator − Proxy payoff: − Error magnitude: , order V V m     V K V K m         m    1 KV KV    2 dens V K m  2 m
  • 24. Scripting Danske Bank 24 Putting it all together • CVA = value of cash-flows discounted with path-dependent process h • Using LSM proxies in place of future PVs: • We end up with an algorithm that is: − Accurate: (to the 1st order) proxies are only used in indicators − Efficient: value xVA for the cost of netting set valuation (+ simulation of discounting process) − Practical: CF valuation scripts are decorated so payments are discounted by h • The same holds for some other xVAs − Immediate for DVA, FVA − With adjustments for RWA, kVA (see Flyger-Huge-Savine, 2015-2016)      1 0 where 1 R 1 1k k p p p Tp P k RN T k T T T T V k T T CVA E CF  h h                     1 0 1 R 1 1 T k p p p p P k T T T T T V T  h       
  • 25. Scripting Danske Bank 25 xVA with Collateral • Fully collateralized CVA with MPR q: • That cannot be directly written as − Consider one exposure: − The LHS can be rewritten as previously − But the not the RHS because is not T*- q –measurable so      1 1 R 1 max 0,p pp p pT TT T p TCVA E V V             kT k k CVA E CFh                ** * * ** * ** max 0 1, 1 T T T T TVV VT T TV e T E V V E V E V                     * * 1 T TV V q  * * * 1 T T k kV V T T LHS E CF            * * * * * 1 T T k T T kV V T T RHS E E E CF                    
  • 26. Scripting Danske Bank 26 Branching Simulations • Branching (McKean 1975, Henry-Labordere 2012) − For each path, also generate one Branch that “sticks out” at margin date… − And starts a parallel path that obeys the same SDE but independently from the main path • Branching is not like nested simulations − For every path, we only generate one Branch (per margin date) as part of that simulation − Averaging is correctly performed by the outer expectation operator
  • 27. Scripting Danske Bank 27 Branching Proxies • Consider a proxy picked on a secondary branch − Constructed with the same regression coefficients, but regression variables simulated on the branch − Conditionally to filtration at the margin date , the main and secondary branches are: − Independent − Identically distributed • We can now compute the RHS from the collateralized exposure equation mrg T T  
  • 28. Scripting Danske Bank 28 Branching Solution • We finally get the complete formula for the collateralized exposure • And the collateralized CVA • All the comments from the uncollateralized case apply − Essentially the same algorithm − Except the discounting process is simulated with branches kT k k CVA E CFh        
  • 29. Scripting Danske Bank 29 Practical xVA: Aggregation • Before computing xVA, all transactions in a netting set must be aggregated • This is generally a conundrum • Scripted transactions are relatively easy to merge • Note we need a proper visitor − Merging scripts is not enough − We must also duplicate all payments on a single variable that represents the netting set
  • 30. Scripting Danske Bank 30 Practical xVA: Compression • Avoid linear growth of CPU and memory load with number of transactions • Align event dates on a master schedule • De-interpolate fixings and payments on surrounding dates in the master schedule • Aggregate notionals • We call this process “compression” − Conducted by specialized (and complicated) visitors − Fully automated leveraging on the visitor design
  • 31. Scripting Danske Bank 31 Practical xVA: Decoration • We have our (compressed) schedule for all cash flows in the NS: • We want to compute:      10 1 0 0, 1 R 1 k i i i Ti T k k T T T i i V CVA E CF S T S T h h h h                   
  • 32. Scripting Danske Bank 32 Decoration (2) • We duplicate all payments, multiply them by h: • And add an additional schedule for the simulation of h: • This is conducted by a dedicated visitor called decorator
  • 34. Scripting Danske Bank 34 Discontinuous payoffs with Monte-Carlo • Discontinuous profiles produce unstable risks with Monte-Carlo − Example: 110 1y Digital in Black-Scholes MC, vol = 20% − 10,000 to 250,000 simulations − Seed changed between pricings − Decent convergence on price, risk all over the place
  • 35. Scripting Danske Bank Payoff smoothing 35 • Payoff smoothing is a simple (and yet surprinsingly effective) method: Replace discontinuous payoffs by ”close” continuous ones − Digital  Call spread − Barrier  Smooth barrier • One benefit: work on payoffs only, no work required on models • One problem: must identify and smooth all discontinuities • Today, this is a manual process: Traders rewrite payoffs one by one using a ”call-spread” or ”smooth” function: smooth(x,p,n,e) = 0 e/2-e/2 n p x
  • 36. Scripting Danske Bank Smoothing a digital 36 • Digital  Call Spread • Dig =  CS = finite difference continuous approximation • Alt. interpretation: spread the notional evenly across strikes between (K-e/2,K+e/2) C K   
  • 37. Scripting Danske Bank Smoothing a barrier 37 • Spread notional across barriers in (B-/2,B+/2) • Example: 1y 110-120 RKO in Black-Scholes (20%) • Weekly monitoring, barrier shifted by 0.60 std • Smooth barrier: knock-out part of the notional depending on how far we land in (B-/2,B+/2) total KO partial KO no KO
  • 38. Scripting Danske Bank Smoothing everything 38 • Many transactions with discontinuous profile besides digitals and barriers • Popular example: simplified Autocallable − If spot declines 3 years in a row, lose 50% of notional − Otherwise make 10% per annum until spot raises above initial level • All those products can’t be reliably risk managed unless smoothed • Traders must manually apply smoothing for every (type of) transaction • We describe that process, assuming a scripting platform
  • 39. Scripting Danske Bank Identifying discontinuities 39 • In programming, incl. scripting, discontinuities come from control flow − If this then that pattern − Calls to discontinuous functions (meaning themselves implement if this then that statements) • Autocallable: − 3 control flows − Unstable risk
  • 40. Scripting Danske Bank Manual smoothing 40 • Replace if this then that by smooth (remindeer: smooth = ”call spread” function) • Does the job, but hard to write and read and error prone, even in simple cases smooth(x,p,n,e) = 0 e/2-e/2 n p x
  • 41. Scripting Danske Bank Automatic smoothing 41 • Automatically turn − Nice, easy, natural scripts − Into smoothed scripts that produce stable risks • Visitor technology means : Program knows the script and can apply smoothing the same way traders do • In practice, rule based algorithms invalidated by counter examples
  • 42. Scripting Danske Bank Fuzzy Logic to the rescue 42 • The one realization that brings everything together: smoothing = use of Fuzzy Logic • In classical (sharp) logic, a condition is true or false − Schrodinger’s cat is dead or alive • In fuzzy logic, a condition is true to a degree = degree of truth or DT − Schrodinger’s cat is dead and alive − For instance, it can be alive with DT 65% and dead with DT 35% • Note: DT is not a probability  Financial interpretation: condition applies to DT% of the notional − A barrier is 65% alive means 35% of the notional knocked out, the rest is still going − It does not mean that it is hit with proba 35%, which makes no sense on a given scenario
  • 43. Scripting Danske Bank Fuzzy Logic 43 • Invented in the 1960s by Lotfi Zadeh • Not to smooth financial risks • But to build the first expert systems • Automate expert opinions − Expert: it is dangerous for the engine to be fast and hot − Programmer: what do you mean by ”fast” and ”hot”? − Expert: say fast = ”>100mph” and hot = ”>50C” Code: if speed > 100 and heat > 50 then danger = true else danger = false endIf Makes no sense: (99.9,90)  safe, (100.1,50.1)  dangerous !!
  • 44. Scripting Danske Bank     1 2 1 2 1 2 1 2 1 2or DT C and C DT DT DT C C DT DT DT DT       More Fuzzy Logic 44 • With fuzzy logic: − isFast and isHot are DTs = smooth functions resp. of speed and heat valued in [0,1] − DTs combine like booleans alt. Code: isDangerous = fuzzyAnd( isFast( speed), isHot( heat)) Results make sense: (99.9,90)  50% dangerous, (100.1,50.1)  25% dangerous         1 2 1 2 1 2 1 2 min , or max , DT C and C DT DT DT C C DT DT  
  • 45. Scripting Danske Bank Smoothing = Fuzzy Logic 45 • Remarkable result: established smoothing exactly is application of Fuzzy Logic  Digital smoothing = apply fuzzy logic to if spot>strike then pay 1  Barrier smoothing = apply fuzzy logic to if spot>barrier then alive = 0 • That explains, in hindsight, why smoothing performs so remarkably well  Not a hack  (In hindsight) based on established scientific theory • And gives us the means to correctly, automatically smooth everything  Smoothing everything = apply fuzzy logic to the evaluation of all conditions  Without modifying scripts in any way We derive the evaluator into a fuzzy evaluator that overrides visits to if nodes and conditions and evaluates them with Fuzzy Logic
  • 46. Scripting Danske Bank Evaluation of ”if this then that” with fuzzy logic 46 • Evaluation with sharp logic 1. Evaluate condition C 2. If C is true, evaluate statements between then and else or endIf 3. If C is false, evaluate statements between else and endIf if any • Evaluation with fuzzy logic 1. Record state S0 (all variables and products) just before the ”if” statement 2. Evaluate the degree of truth (DT) of the condition 3. Evaluate ”if true” statements 4. Record resulting state S1 5. Restore state to S0 6. Evaluate ”else” statements if any 7. Record resulting state S2 8. Set final state S = DT * S1 + (1-DT) * S2
  • 47. Scripting Danske Bank Fuzzy Logic : results 47 • No modification to scripts • Override evaluation of if this then that statements, conditions and combinators • Effectively stabilises risks sensitivities with minimal PV impact • (With proper optimization) just as fast as normal • Easily flick between sharp (pricing) and fuzzy (risk) evaluation