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

certified management of financial contracts
SMART_READER_LITE
LIVE PREVIEW

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

Certified Management of Financial Contracts Patrick Bahr Jost Berthold Martin Elsman University of Copenhagen, Department of Computer Science (DIKU) 26th Nordic Workshop on Programming Theory, 2014 Introduction What are financial contracts?


slide-1
SLIDE 1

Certified Management of Financial Contracts

Patrick Bahr Jost Berthold Martin Elsman

University of Copenhagen, Department of Computer Science (DIKU)

26th Nordic Workshop on Programming Theory, 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. ◮ Formally verified!

2 / 15

slide-6
SLIDE 6

Contract Language Goals in Detail

◮ Compositionality.

Contracts are time-relative ⇒ straightforward 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 (obsB(X, 0), 90, trade, zero) where trade = scale(100, both(transfer(Y , X, USD), pay)) pay = scale(r, transfer(X, Y , DKK))

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

Core Calculus of Contracts

zero : Contr transfer : Party × Party × Currency → Contr both : Contr × Contr → Contr scale : ExprR × Contr → Contr translate : N × Contr → Contr if : ExprB × N × Contr × Contr → Contr

6 / 15

slide-11
SLIDE 11

An Overview of the Contract Language

Core Calculus of Contracts

zero : Contr transfer : Party × Party × Currency → Contr both : Contr × Contr → Contr scale : ExprR × Contr → Contr translate : N × Contr → Contr if : ExprB × N × Contr × Contr → Contr

Expression Language

ExprR, ExprB: real-valued resp. Boolean-valued expressions.

6 / 15

slide-12
SLIDE 12

An Overview of the Contract Language

Core Calculus of Contracts

zero : Contr transfer : Party × Party × Currency → Contr both : Contr × Contr → Contr scale : ExprR × Contr → Contr translate : N × Contr → Contr if : ExprB × N × Contr × Contr → Contr

Expression Language

ExprR, ExprB: real-valued resp. Boolean-valued expressions.

  • bsα : Labelα × Z → Exprα

accα : (Exprα → Exprα) × N × Exprα → Exprα

6 / 15

slide-13
SLIDE 13

Example: Asian Option

translate(90, if (obsB(X, 0), 0, trade, zero)) where trade = scale(100, both(transfer(Y , X, USD), pay)) pay = scale(rate, transfer(X, Y , DKK)) rate = 1 30 · acc(λr.r + obsR(FX USD/DKK, 0), 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 × Currency → 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 × Currency → 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 × Currency → 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

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-20
SLIDE 20

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?

10 / 15

slide-21
SLIDE 21

Contract Equivalences

translate(d, zero) ≃ zero scale(r, zero) ≃ zero scale(0, c) ≃ zero both(c, zero) ≃ c scale(s1, scale(s2, c)) ≃ scale(s1 · s2, c) translate(d1, translate(d2, c)) ≃ translate(d1 + d2, c) translate(d, both(c1, c2)) ≃ both(translate(d, c1), translate(d, c2)) scale(x, both(c1, c2)) ≃ both(scale(x, c1), scale(x, c2)) translate(d, scale(s, c)) ≃ scale(s/d, translate(d, c)) translate(d, if (b, e, c1, c2)) ≃ if (b/d, e,translate(d, c1), translate(d, c2)) both(scale(x, transfer(a, b, c)),scale(y, transfer(a, b, c))) ≃ scale(x + y, transfer(a, b, c))

11 / 15

slide-22
SLIDE 22

Reduction Semantics c

τ

= ⇒ρ c′

12 / 15

slide-23
SLIDE 23

Reduction Semantics c

τ

= ⇒ρ c′

transfer(p1, p2, c)

τp1,p2,c

= ⇒ ρ zero

12 / 15

slide-24
SLIDE 24

Reduction Semantics c

τ

= ⇒ρ c′

transfer(p1, p2, c)

τp1,p2,c

= ⇒ ρ zero c

τ

= ⇒ρ c′ E eρ = v scale(e, c) v∗τ = ⇒ρ scale(e/−1, c′)

12 / 15

slide-25
SLIDE 25

Reduction Semantics c

τ

= ⇒ρ c′

transfer(p1, p2, c)

τp1,p2,c

= ⇒ ρ zero c

τ

= ⇒ρ c′ E eρ = v scale(e, c) v∗τ = ⇒ρ scale(e/−1, c′) . . .

12 / 15

slide-26
SLIDE 26

Reduction Semantics c

τ

= ⇒ρ c′

transfer(p1, p2, c)

τp1,p2,c

= ⇒ ρ zero c

τ

= ⇒ρ c′ E eρ = v scale(e, c) v∗τ = ⇒ρ scale(e/−1, 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′.

12 / 15

slide-27
SLIDE 27

Code Extraction

Coq formalisation

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

13 / 15

slide-28
SLIDE 28

Code Extraction

Coq formalisation

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

13 / 15

slide-29
SLIDE 29

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

13 / 15

slide-30
SLIDE 30

Future Work

◮ improve code extraction ◮ advanced analyses and transformations

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

◮ combine this work with numerical methods

14 / 15

slide-31
SLIDE 31

Conclusion

The code is available from http://j.mp/contractDSL including

◮ full Coq proofs ◮ code extraction ◮ Prototype Haskell implementation ◮ example contracts ◮ technical report with all details

15 / 15