certified management of financial contracts
play

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?


  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

  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

  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

  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

  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

  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

  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

  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 B ( X , 0) , 90 , trade , zero ) where trade = scale (100 , both ( transfer ( Y , X , USD) , pay )) pay = scale ( r , transfer ( X , Y , DKK)) 4 / 15

  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

  10. An Overview of the Contract Language Core Calculus of Contracts zero : Contr transfer : Party × Party × Currency → Contr both : Contr × Contr → Contr scale : Expr R × Contr → Contr translate : N × Contr → Contr if : Expr B × N × Contr × Contr → Contr 6 / 15

  11. An Overview of the Contract Language Core Calculus of Contracts zero : Contr transfer : Party × Party × Currency → Contr both : Contr × Contr → Contr scale : Expr R × Contr → Contr translate : N × Contr → Contr if : Expr B × N × Contr × Contr → Contr Expression Language Expr R , Expr B : real-valued resp. Boolean-valued expressions. 6 / 15

  12. An Overview of the Contract Language Core Calculus of Contracts zero : Contr transfer : Party × Party × Currency → Contr both : Contr × Contr → Contr scale : Expr R × Contr → Contr translate : N × Contr → Contr if : Expr B × N × Contr × Contr → Contr Expression Language Expr R , Expr B : real-valued resp. Boolean-valued expressions. obs α : Label α × Z → Expr α acc α : (Expr α → Expr α ) × N × Expr α → Expr α 6 / 15

  13. Example: Asian Option translate (90 , if ( obs B ( 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 + obs R (FX USD / DKK , 0) , 30 , 0) 7 / 15

  14. Denotational Semantics The semantics of a contract is given by the cash-flow it stipulates. C � · � · : Contr → CashFlow 8 / 15

  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

  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

  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

  18. Contract Analyses Examples ◮ contract dependencies ◮ contract causality ◮ contract horizon 9 / 15

  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

  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 of some observables? 10 / 15

  21. Contract Equivalences translate ( d , zero ) ≃ zero scale ( r , zero ) ≃ zero scale (0 , c ) ≃ zero both ( c , zero ) ≃ c scale ( s 1 , scale ( s 2 , c )) ≃ scale ( s 1 · s 2 , c ) translate ( d 1 , translate ( d 2 , c )) ≃ translate ( d 1 + d 2 , c ) translate ( d , both ( c 1 , c 2 )) ≃ both ( translate ( d , c 1 ) , translate ( d , c 2 )) scale ( x , both ( c 1 , c 2 )) ≃ both ( scale ( x , c 1 ) , scale ( x , c 2 )) translate ( d , scale ( s , c )) ≃ scale ( s / d , translate ( d , c )) translate ( d , if ( b , e , c 1 , c 2 )) ≃ if ( b / d , e , translate ( d , c 1 ) , translate ( d , c 2 )) both ( scale ( x , transfer ( a , b , c )) , scale ( y , transfer ( a , b , c ))) ≃ scale ( x + y , transfer ( a , b , c )) 11 / 15

  22. Reduction Semantics τ ⇒ ρ c ′ = c 12 / 15

  23. Reduction Semantics τ ⇒ ρ c ′ = c τ p 1 , p 2 , c transfer ( p 1 , p 2 , c ) = ⇒ ρ zero 12 / 15

  24. Reduction Semantics τ ⇒ ρ c ′ = c τ = ⇒ ρ c ′ E � e � ρ = v c scale ( e , c ) v ∗ τ τ p 1 , p 2 , c = ⇒ ρ scale ( e / − 1 , c ′ ) transfer ( p 1 , p 2 , c ) = ⇒ ρ zero 12 / 15

  25. Reduction Semantics τ ⇒ ρ c ′ = c τ = ⇒ ρ c ′ E � e � ρ = v c scale ( e , c ) v ∗ τ τ p 1 , p 2 , c = ⇒ ρ scale ( e / − 1 , c ′ ) transfer ( p 1 , p 2 , c ) = ⇒ ρ zero . . . 12 / 15

  26. Reduction Semantics τ ⇒ ρ c ′ = c τ = ⇒ ρ c ′ E � e � ρ = v c scale ( e , c ) v ∗ τ τ p 1 , p 2 , c = ⇒ ρ scale ( e / − 1 , c ′ ) transfer ( p 1 , p 2 , c ) = ⇒ ρ zero . . . 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

  27. Code Extraction Coq formalisation ◮ Denotational & reduction semantics ◮ Meta-theory of contracts (causality, monotonicity, . . . ) ◮ Definition of contract transformations and analyses ◮ Correctness proofs 13 / 15

  28. Code Extraction Coq formalisation ◮ Denotational & reduction semantics ◮ Meta-theory of contracts (causality, monotonicity, . . . ) ◮ Definition of contract transformations and analyses ◮ Correctness proofs 13 / 15

  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

  30. Future Work ◮ improve code extraction ◮ advanced analyses and transformations (e.g. scenario generation and “zooming”) ◮ combine this work with numerical methods 14 / 15

  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

Recommend


More recommend