Certified Symbolic Management of Financial Multi-Party Contracts - - PowerPoint PPT Presentation

certified symbolic management of financial multi party
SMART_READER_LITE
LIVE PREVIEW

Certified Symbolic Management of Financial Multi-Party Contracts - - PowerPoint PPT Presentation

Certified Symbolic Management of Financial Multi-Party Contracts Patrick Bahr 1 Jost Berthold 2 Martin Elsman 3 1 IT University of Copenhagen 2 Commonwealth Bank of Australia 3 University of Copenhagen ICFP 2015 Example: American Option Contract


slide-1
SLIDE 1

Certified Symbolic Management of Financial Multi-Party Contracts

Patrick Bahr1 Jost Berthold2 Martin Elsman3

1IT University of Copenhagen 2Commonwealth Bank of Australia 3University of Copenhagen

ICFP 2015

slide-2
SLIDE 2

Example: American Option

Contract in natural language

◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1.1 of USD.

2 / 13

slide-3
SLIDE 3

Example: American Option

Contract in natural language

◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1.1 of USD.

Translation into our contract language

if obs(X exercises option, 0) within 90 then 100 × (EUR(Y → X) & (1.1 × USD(X → Y ))) else ∅

2 / 13

slide-4
SLIDE 4

Example: American Option

Contract in natural language

◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1.1 of USD.

Translation into our contract language

if obs(X exercises option, 0) within 90 then 100 × (EUR(Y → X) & (1.1 × USD(X → Y ))) else ∅

2 / 13

slide-5
SLIDE 5

Example: American Option

Contract in natural language

◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1.1 of USD.

Translation into our contract language

if obs(X exercises option, 0) within 90 then 100 × (EUR(Y → X) & (1.1 × USD(X → Y ))) else ∅

2 / 13

slide-6
SLIDE 6

Example: American Option

Contract in natural language

◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1.1 of USD.

Translation into our contract language

if obs(X exercises option, 0) within 90 then 100 × (EUR(Y → X) & (1.1 × USD(X → Y ))) else ∅

2 / 13

slide-7
SLIDE 7

Example: American Option

Contract in natural language

◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1.1 of USD.

Translation into our contract language

if obs(X exercises option, 0) within 90 then 100 × (EUR(Y → X) & (1.1 × USD(X → Y ))) else ∅

2 / 13

slide-8
SLIDE 8

Example: American Option

Contract in natural language

◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1.1 of USD.

Translation into our contract language

if obs(X exercises option, 0) within 90 then 100 × (EUR(Y → X) & (1.1 × USD(X → Y ))) else ∅

2 / 13

slide-9
SLIDE 9

Example: American Option

Contract in natural language

◮ At any time within the next 90 days, ◮ party X may decide to ◮ buy EUR 100 from party Y, ◮ for a fixed rate 1.1 of USD.

Translation into our contract language

if obs(X exercises option, 0) within 90 then 100 × (EUR(Y → X) & (1.1 × USD(X → Y ))) else ∅

2 / 13

slide-10
SLIDE 10

Goals

◮ Combinators that capture financial contracts ◮ time constraints ◮ external events/data ◮ multi-party ◮ portfolios

3 / 13

slide-11
SLIDE 11

Goals

◮ Combinators that capture financial contracts ◮ Symbolic analysis of contracts

3 / 13

slide-12
SLIDE 12

Goals

◮ Combinators that capture financial contracts ◮ Symbolic analysis of contracts ◮ Certified implementation

3 / 13

slide-13
SLIDE 13

Overview

◮ Denotational semantics based on cash-flows ◮ Type system causality ◮ Reduction semantics ◮ Formalised in the Coq theorem prover ◮ Certified implementation via code extraction

4 / 13

slide-14
SLIDE 14

An Overview of the Contract Language

Contract combinators

◮ ∅ ◮ a(p → q) ◮ c1 & c2 ◮ e × c ◮ if e within d then c1 else c2

5 / 13

slide-15
SLIDE 15

An Overview of the Contract Language

Contract combinators

◮ ∅ ◮ a(p → q) ◮ c1 & c2 ◮ e × c ◮ if e within d then c1 else c2 ◮ d ↑ c ◮ let x = e in c

5 / 13

slide-16
SLIDE 16

An Overview of the Contract Language

Contract combinators

◮ ∅ ◮ a(p → q) ◮ c1 & c2 ◮ e × c ◮ if e within d then c1 else c2 ◮ d ↑ c ◮ let x = e in c

Expression Language

Real-valued and Boolean-valued expressions, extended by

  • bs(l, d) observe the value of l at time d

acc(f , d, e) accumulation over the last d days

5 / 13

slide-17
SLIDE 17

Example: Credit Default Swap

Bond

if obs(X defaults, 0) within 30 then ∅ else 1000 × EUR(X → Y )

6 / 13

slide-18
SLIDE 18

Example: Credit Default Swap

Bond

if obs(X defaults, 0) within 30 then ∅ else 1000 × EUR(X → Y )

Credit Default Swap

(10 × EUR(Y → Z)) & if obs(X defaults, 0) within 30 then 900 × EUR(Z → Y ) else ∅

6 / 13

slide-19
SLIDE 19

Example: Credit Default Swap

Bond

Cbond = if obs(X defaults, 0) within 30 then ∅ else 1000 × EUR(X → Y )

Credit Default Swap

CCDS = (10 × EUR(Y → Z)) & if obs(X defaults, 0) within 30 then 900 × EUR(Z → Y ) else ∅

6 / 13

slide-20
SLIDE 20

Example: Credit Default Swap

Bond

Cbond = if obs(X defaults, 0) within 30 then ∅ else 1000 × EUR(X → Y )

Credit Default Swap

CCDS = (10 × EUR(Y → Z)) & if obs(X defaults, 0) within 30 then 900 × EUR(Z → Y ) else ∅ Cbond & CCDS

6 / 13

slide-21
SLIDE 21

Example: Credit Default Swap

Bond

Cbond = if obs(X defaults, 0) within 30 then ∅ else 1000 × EUR(X → Y )

Credit Default Swap

CCDS = (10 × EUR(Y → Z)) & if obs(X defaults, 0) within 30 then 900 × EUR(Z → Y ) else ∅ Cbond & CCDS ≡ (10 × EUR(Y → Z)) & if obs(X defaults, 0) within 30 then 900 × EUR(Z → Y ) else 1000 × EUR(X → Y )

6 / 13

slide-22
SLIDE 22

Denotational Semantics

·· : Contr × Env → CashFlow cρ = T0 T1 T2 T3 T4 . . . time

1 2 3 4

cρ ∈ CashFlow = N → Transactions Ti ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R

7 / 13

slide-23
SLIDE 23

Denotational Semantics

·· : Contr × Env → CashFlow cρ = T0 T1 T2 T3 T4 . . . time

1 2 3 4

R0 R1 R2 R3 R4 . . . cρ ∈ CashFlow = N → Transactions Ti ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R

7 / 13

slide-24
SLIDE 24

Denotational Semantics

·· : Contr × Env → CashFlow cρ = T0 T1 T2 T3 T4 . . . time

1 2 3 4

−1 −2 −3 −4 R0 R1 R−1 R2 R−2 R3 R−3 R4 R−4 . . . . . . cρ ∈ CashFlow = N → Transactions Ti ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R

7 / 13

slide-25
SLIDE 25

Denotational Semantics

·· : Contr × Env → CashFlow cρ = T0 T1 T2 T3 T4 . . . time

1 2 3 4

−1 −2 −3 −4 R0 R1 R−1 R2 R−2 R3 R−3 R4 R−4 . . . . . . ρ cρ ∈ CashFlow = N → Transactions Ti ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R

7 / 13

slide-26
SLIDE 26

Denotational Semantics

·· : Contr × Env → CashFlow cρ = T0 T1 T2 T3 T4 . . . time

1 2 3 4

−1 −2 −3 −4 R0 R1 R−1 R2 R−2 R3 R−3 R4 R−4 . . . . . . ρ cρ ∈ CashFlow = N → Transactions Ti ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R

7 / 13

slide-27
SLIDE 27

Denotational Semantics

·· : Contr × Env → CashFlow cρ = T0 T1 T2 T3 T4 . . . time

1 2 3 4

−1 −2 −3 −4 R0 R1 R−1 R2 R−2 R3 R−3 R4 R−4 . . . . . . ρ cρ ∈ CashFlow = N → Transactions Ti ∈ Transactions = Party × Party × Asset → R ρ ∈ Env = Label × Z → B ∪ R

7 / 13

slide-28
SLIDE 28

Type System

Time-Indexed Types

◮ e : Realt, e : Boolt

value of e available at time t (and later)

◮ c : Contrt

no obligations strictly before t

8 / 13

slide-29
SLIDE 29

Type System

Time-Indexed Types

◮ e : Realt, e : Boolt

value of e available at time t (and later)

◮ c : Contrt

no obligations strictly before t

Typing Rules

Γ ⊢ e : Reals Γ ⊢ c : Contrs t ≤ s Γ ⊢ e × c : Contrt l ∈ Labelτ t ≤ s Γ ⊢ obs(l, t) : τ s t ≤ 0 Γ ⊢ a(p → q) : Contrt

. . .

8 / 13

slide-30
SLIDE 30

Type System

Time-Indexed Types

◮ e : Realt, e : Boolt

value of e available at time t (and later)

◮ c : Contrt

no obligations strictly before t

Typing Rules

Γ ⊢ e : Reals Γ ⊢ c : Contrs t ≤ s Γ ⊢ e × c : Contrt l ∈ Labelτ t ≤ s Γ ⊢ obs(l, t) : τ s t ≤ 0 Γ ⊢ a(p → q) : Contrt

. . .

8 / 13

slide-31
SLIDE 31

Reduction Semantics c

T

= ⇒ρ c′

9 / 13

slide-32
SLIDE 32

Reduction Semantics c

T

= ⇒ρ c′

ρ =

T0 T1 T2 T3 T4 T5 . . . c′ˆ

ρ =

time

1 2 3 4 5 6

9 / 13

slide-33
SLIDE 33

Reduction Semantics c

T

= ⇒ρ c′

ρ =

T0 T1 T2 T3 T4 T5 . . . c′ˆ

ρ =

time

1 2 3 4 5 6

9 / 13

slide-34
SLIDE 34

Reduction Semantics c

T0

= ⇒ρ c′

ρ =

T0 T1 T2 T3 T4 T5 . . . c′ˆ

ρ =

time

1 2 3 4 5 6

9 / 13

slide-35
SLIDE 35

Reduction Semantics c

T0

= ⇒ρ c′

ρ =

T0 T1 T2 T3 T4 T5 . . . c′ˆ

ρ =

time

1 2 3 4 5 6

9 / 13

slide-36
SLIDE 36

Reduction Semantics c

T0

= ⇒ρ c′

ρ =

T0 T1 T2 T3 T4 T5 . . . c′ˆ

ρ = T1

T2 T3 T4 T5 T6 . . . time

1 2 3 4 5 6

9 / 13

slide-37
SLIDE 37

Reduction Semantics c

T0

= ⇒ρ c′

ρ =

T0 T1 T2 T3 T4 T5 . . . c′ˆ

ρ = T1

T2 T3 T4 T5 T6 . . . time

1 2 3 4 5 6

9 / 13

slide-38
SLIDE 38

Reduction Semantics c

T0

= ⇒ρ c′

ρ =

T0 T1 T2 T3 T4 T5 . . . c′ˆ

ρ = T1

T2 T3 T4 T5 T6 . . . time

1 2 3 4 5 6

c

T0

= ⇒ˆ

ρ c1 T1

= ⇒ˆ

ρ c2 T2

= ⇒ˆ

ρ c3 T3

= ⇒ˆ

ρ c4 T4

= ⇒ˆ

ρ c5 T5

= ⇒ˆ

ρ

. . .

9 / 13

slide-39
SLIDE 39

Formalisation and Implementation

Coq formalisation

Denotational semantics is the starting point

◮ Adequacy of reduction semantics ◮ Type safety (well-typed causal) ◮ Soundness & completeness of type inference ◮ Soundness of partial evaluation & horizon inference

10 / 13

slide-40
SLIDE 40

Formalisation and Implementation

Coq formalisation

Denotational semantics is the starting point

◮ Adequacy of reduction semantics ◮ Type safety (well-typed causal) ◮ Soundness & completeness of type inference ◮ Soundness of partial evaluation & horizon inference

Extraction of executable Haskell code

◮ efficient Haskell implementation ◮ embedded domain-specific language for contracts ◮ contract analyses and contract management

10 / 13

slide-41
SLIDE 41

Contracts in Haskell – Example

{−# LANGUAGE RebindableSyntax #−} import RebindableEDSL bond :: Contr bond = if bObs (Default X) 0 ‘within‘ 30 then zero else 1000 # transfer X Y USD cds :: Contr cds = payment & settlement where payment = 10 # transfer Y Z USD settlement = if bObs (Default X) 0 ‘within‘ 30 then 900 # transfer Z Y USD else zero

11 / 13

slide-42
SLIDE 42

Conclusion

Future Work

◮ combining symbolic and numeric methods ◮ continuous time model ◮ more sophisticated analyses

12 / 13

slide-43
SLIDE 43

Conclusion

Future Work

◮ combining symbolic and numeric methods ◮ continuous time model ◮ more sophisticated analyses

Source code available at http://bit.ly/contract-DSL

◮ Coq formalisation ◮ Extracted Haskell implementation ◮ Example contracts

12 / 13

slide-44
SLIDE 44

Certified Symbolic Management of Financial Multi-Party Contracts

Patrick Bahr1 Jost Berthold2 Martin Elsman3

1IT University of Copenhagen 2Commonwealth Bank of Australia 3University of Copenhagen

http://bit.ly/contract-DSL