Certified Management of Financial Contracts Patrick Bahr DIKU - - PowerPoint PPT Presentation

certified management of financial contracts
SMART_READER_LITE
LIVE PREVIEW

Certified Management of Financial Contracts Patrick Bahr DIKU - - PowerPoint PPT Presentation

Certified Management of Financial Contracts Patrick Bahr DIKU paba@diku.dk joint work with Jost Berthold & Martin Elsman 10th December, 2014 Introduction What are financial contracts? stipulate future transactions between different


slide-1
SLIDE 1

Certified Management of Financial Contracts

Patrick Bahr

DIKU paba@diku.dk joint work with Jost Berthold & Martin Elsman

10th December, 2014

slide-2
SLIDE 2

Introduction

What are financial contracts?

◮ stipulate future transactions between different parties ◮ have time constraints ◮ may depend on stock prices, exchange rates etc.

2 / 15

slide-3
SLIDE 3

Introduction

What are financial contracts?

◮ stipulate future transactions between different parties ◮ have time constraints ◮ may depend on stock prices, exchange rates etc.

Example (Foreign Exchange Option)

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

2 / 15

slide-4
SLIDE 4

Introduction

What are financial contracts?

◮ stipulate future transactions between different parties ◮ have time constraints ◮ may depend on stock prices, exchange rates etc.

Example (Foreign Exchange Option)

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

Goals

◮ Express such contracts in a formal language ◮ Symbolic manipulation and analysis of such contracts.

2 / 15

slide-5
SLIDE 5

Introduction

What are financial contracts?

◮ stipulate future transactions between different parties ◮ have time constraints ◮ may depend on stock prices, exchange rates etc.

Example (Foreign Exchange Option)

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

Goals

◮ Express such contracts in a formal language ◮ Symbolic manipulation and analysis of such contracts. ◮ Formal verification

2 / 15

slide-6
SLIDE 6

Contract Language Goals in Detail

◮ Compositionality.

Contracts are time-relative ⇒ facilitates compositionality

◮ Multi-party.

Specify obligations and opportunities for multiple parties, (which opens up the possibility for specifying portfolios)

◮ Contract management.

Contracts can be managed and symbolically evolved; a contract gradually reduces to the empty contract.

◮ Contract utilities (symbolic).

Contracts can be analysed in a variety of ways

◮ Contract pricing (numerical, staged).

Code for payoff can be generated from contracts (input to a stochastic pricing engine)

3 / 15

slide-7
SLIDE 7

Example

Contract in natural language

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

4 / 15

slide-8
SLIDE 8

Example

Contract in natural language

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

Translation into contract language

if obs(X exercises option) within 90 then 100 × (USD(Y → X) & r × DKK(X → Y )) else ∅

4 / 15

slide-9
SLIDE 9

Contributions

◮ Denotational semantics based on cash-flows ◮ Reduction semantics (sound and complete) ◮ Correctness proofs for common contract analyses and

transformations

◮ Formalised in the Coq theorem prover ◮ Certified implementation via code extraction

5 / 15

slide-10
SLIDE 10

An Overview of the Contract Language

∅ empty contract with no obligations a(p1 → p2) p1 has to transfer one unit of a to p2 c1 & c2 conjunction of c1 and c2 e × c multiply all obligations in c by e d ↑ c shift c into the future by d days let x = e in c observe today’s value of e at any time (via x)

6 / 15

slide-11
SLIDE 11

An Overview of the Contract Language

∅ empty contract with no obligations a(p1 → p2) p1 has to transfer one unit of a to p2 c1 & c2 conjunction of c1 and c2 e × c multiply all obligations in c by e d ↑ c shift c into the future by d days let x = e in c observe today’s value of e at any time (via x) if e within d then c1 else c2

◮ behave like c1 as soon as e becomes true ◮ if e does not become true within d days behave like c2

6 / 15

slide-12
SLIDE 12

An Overview of the Contract Language

∅ empty contract with no obligations a(p1 → p2) p1 has to transfer one unit of a to p2 c1 & c2 conjunction of c1 and c2 e × c multiply all obligations in c by e d ↑ c shift c into the future by d days let x = e in c observe today’s value of e at any time (via x) if e within d then c1 else c2

◮ behave like c1 as soon as e becomes true ◮ if e does not become true within d days behave like c2

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

6 / 15

slide-13
SLIDE 13

Example: Asian Option

90 ↑ if obs(X exercises option) within 0 then 100 × (USD(Y → X) &(rate × DKK(X → Y ))) else ∅ where rate = 1 30 · acc(λr.r + obs(FX USD/DKK), 30, 0)

7 / 15

slide-14
SLIDE 14

Denotational Semantics

The semantics of a contract is given by the cash-flow it stipulates. C ·· : Contr → CashFlow

8 / 15

slide-15
SLIDE 15

Denotational Semantics

The semantics of a contract is given by the cash-flow it stipulates. C ·· : Contr → CashFlow CashFlow = N → Transactions Transactions = Party × Party × Asset → R

8 / 15

slide-16
SLIDE 16

Denotational Semantics

The semantics of a contract is given by the cash-flow it stipulates. C ·· : Contr × Env → CashFlow Env = Label × Z → B ∪ R CashFlow = N → Transactions Transactions = Party × Party × Asset → R

8 / 15

slide-17
SLIDE 17

Denotational Semantics

The semantics of a contract is given by the cash-flow it stipulates. C ·· : Contr × Env → CashFlow Env = Labelα × Z → α CashFlow = N → Transactions Transactions = Party × Party × Asset → R

8 / 15

slide-18
SLIDE 18

Contract Analyses

Examples

◮ contract dependencies ◮ contract causality ◮ contract horizon

9 / 15

slide-19
SLIDE 19

Contract Analyses

Examples

◮ contract dependencies ◮ contract causality ◮ contract horizon

  • bs(FX USD/DKK, 1) × DKK(X → Y )

9 / 15

slide-20
SLIDE 20

Contract Analyses

Examples

◮ contract dependencies ◮ contract causality ◮ contract horizon

Semantics vs. Syntax

◮ these analyses have precise semantic definition ◮ they cannot be effectively computed ◮ we provide sound approximations, e.g. type system

9 / 15

slide-21
SLIDE 21

Contract Causality

Refined Types

◮ e : Exprt α

value of e available at time t (or later)

◮ c : Contrt

no obligations strictly before t

10 / 15

slide-22
SLIDE 22

Contract Causality

Refined Types

◮ e : Exprt α

value of e available at time t (or later)

◮ c : Contrt

no obligations strictly before t

Typing Rules

t1, t2 ∈ Z l ∈ Labelα t1 ≤ t2 Γ ⊢ obs(l, t1) : Exprt2

α

p1, p2 ∈ Party a ∈ Asset ⊢ a(p1 → p2) : Contr0

10 / 15

slide-23
SLIDE 23

Contract Causality

Refined Types

◮ e : Exprt α

value of e available at time t (or later)

◮ c : Contrt

no obligations strictly before t

Typing Rules

t1, t2 ∈ Z l ∈ Labelα t1 ≤ t2 Γ ⊢ obs(l, t1) : Exprt2

α

p1, p2 ∈ Party a ∈ Asset ⊢ a(p1 → p2) : Contr0 ⊢ e : Exprt

R

⊢ c : Contrt ⊢ e × c : Contrt d ∈ N ⊢ c : Contrt ⊢ d ↑ c : Contrt+d

10 / 15

slide-24
SLIDE 24

Contract Causality

Refined Types

◮ e : Exprt α

value of e available at time t (or later)

◮ c : Contrt

no obligations strictly before t

Typing Rules

t1, t2 ∈ Z l ∈ Labelα t1 ≤ t2 Γ ⊢ obs(l, t1) : Exprt2

α

p1, p2 ∈ Party a ∈ Asset ⊢ a(p1 → p2) : Contr0 ⊢ e : Exprt

R

⊢ c : Contrt ⊢ e × c : Contrt d ∈ N ⊢ c : Contrt ⊢ d ↑ c : Contrt+d . . .

10 / 15

slide-25
SLIDE 25

Contract Transformations

Contract equivalences

When can we replace a sub-contract with another one, without changing the semantics of the contract?

Reduction semantics

What does the contract look like after n days have passed?

Contract Specialisation

What does the contract look like after we learned the actual value

  • f some observables?

11 / 15

slide-26
SLIDE 26

Contract Equivalences

e1 × (e2 × c) ≃ (e1 · e2) × c d1 ↑ (d2 ↑ c) ≃ (d1 + d2) ↑ c d ↑ (c1 & c2) ≃ (d ↑ c1) &(d ↑ c2) e × (c1 & c2) ≃ (e × c1) &(e × c2) d ↑ (e × c) ≃ (d ⇑ e) × (d ↑ c) d ↑ ∅ ≃ ∅ r × ∅ ≃ ∅ 0 × c ≃ ∅ c & ∅ ≃ c c1 & c2 ≃ c2 & c1 d ↑ if b within e then c1 else c2 ≃ if d ⇑ b within e then d ↑ c1 else d ↑ c2 (e1 × a(p1 → p2)) &(e2 × a(p1 → p2)) ≃ (e1 + e2) × a(p1 → p2)

12 / 15

slide-27
SLIDE 27

Reduction Semantics c

τ

= ⇒ρ c′

13 / 15

slide-28
SLIDE 28

Reduction Semantics c

τ

= ⇒ρ c′

a(p1 → p2)

τa,p1,p2

= ⇒ ρ ∅

13 / 15

slide-29
SLIDE 29

Reduction Semantics c

τ

= ⇒ρ c′

a(p1 → p2)

τa,p1,p2

= ⇒ ρ ∅ c

τ

= ⇒ρ c′ E eρ = v e × c v∗τ = ⇒ρ (−1 ⇑ e) × c′

13 / 15

slide-30
SLIDE 30

Reduction Semantics c

τ

= ⇒ρ c′

a(p1 → p2)

τa,p1,p2

= ⇒ ρ ∅ c

τ

= ⇒ρ c′ E eρ = v e × c v∗τ = ⇒ρ (−1 ⇑ e) × c′ . . .

13 / 15

slide-31
SLIDE 31

Reduction Semantics c

τ

= ⇒ρ c′

a(p1 → p2)

τa,p1,p2

= ⇒ ρ ∅ c

τ

= ⇒ρ c′ E eρ = v e × c v∗τ = ⇒ρ (−1 ⇑ e) × c′ . . .

Theorem (Reduction semantics correctness)

(i) If c

τ

= ⇒ρ c′, then

(a) C cρ (0) = τ, and (b) C cρ (i + 1) = C c′1⇑ρ (i) for all i ∈ N.

(ii) If C cρ (0) = τ, then there is a unique c′ with c

τ

= ⇒ρ c′.

13 / 15

slide-32
SLIDE 32

Code Extraction

Coq formalisation

◮ Denotational & reduction semantics ◮ Meta-theory of contracts (causality, monotonicity, . . . ) ◮ Definition of contract transformations and analyses ◮ Correctness proofs

14 / 15

slide-33
SLIDE 33

Code Extraction

Coq formalisation

◮ Denotational & reduction semantics ◮ Meta-theory of contracts (causality, monotonicity, . . . ) ◮ Definition of contract transformations and analyses ◮ Correctness proofs

14 / 15

slide-34
SLIDE 34

Code Extraction

Coq formalisation

◮ Denotational & reduction semantics ◮ Meta-theory of contracts (causality, monotonicity, . . . ) ◮ Definition of contract transformations and analyses ◮ Correctness proofs

Extraction of executable Haskell code

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

14 / 15

slide-35
SLIDE 35

Future Work

◮ improve code extraction ◮ further analyses and transformations

(e.g. scenario generation and “zooming”)

◮ combine this work with numerical methods

15 / 15