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 parties ◮ have time constraints ◮ may depend on stock prices, exchange rates etc. 2 / 15
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
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
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
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
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
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
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
An Overview of the Contract Language ∅ empty contract with no obligations a ( p 1 → p 2 ) p 1 has to transfer one unit of a to p 2 c 1 & c 2 conjunction of c 1 and c 2 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
An Overview of the Contract Language ∅ empty contract with no obligations a ( p 1 → p 2 ) p 1 has to transfer one unit of a to p 2 c 1 & c 2 conjunction of c 1 and c 2 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 c 1 else c 2 ◮ behave like c 1 as soon as e becomes true ◮ if e does not become true within d days behave like c 2 6 / 15
An Overview of the Contract Language ∅ empty contract with no obligations a ( p 1 → p 2 ) p 1 has to transfer one unit of a to p 2 c 1 & c 2 conjunction of c 1 and c 2 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 c 1 else c 2 ◮ behave like c 1 as soon as e becomes true ◮ if e does not become true within d days behave like c 2 Expression Language Real-valued and Boolean-valued expressions, extended by obs ( l , d ) observe the value of l at time d acc ( f , d , e ) accumulation over the last d days 6 / 15
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
Denotational Semantics The semantics of a contract is given by the cash-flow it stipulates. C � · � · : Contr → CashFlow 8 / 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
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
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
Contract Analyses Examples ◮ contract dependencies ◮ contract causality ◮ contract horizon 9 / 15
Contract Analyses Examples obs ( FX USD / DKK , 1) × DKK ( X → Y ) ◮ contract dependencies ◮ contract causality ◮ contract horizon 9 / 15
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
Contract Causality Refined Types ◮ e : Expr t value of e available at time t (or later) α ◮ c : Contr t no obligations strictly before t 10 / 15
Contract Causality Refined Types ◮ e : Expr t value of e available at time t (or later) α ◮ c : Contr t no obligations strictly before t Typing Rules t 1 , t 2 ∈ Z l ∈ Label α t 1 ≤ t 2 p 1 , p 2 ∈ Party a ∈ Asset Γ ⊢ obs ( l , t 1 ) : Expr t 2 ⊢ a ( p 1 → p 2 ) : Contr 0 α 10 / 15
Contract Causality Refined Types ◮ e : Expr t value of e available at time t (or later) α ◮ c : Contr t no obligations strictly before t Typing Rules t 1 , t 2 ∈ Z l ∈ Label α t 1 ≤ t 2 p 1 , p 2 ∈ Party a ∈ Asset Γ ⊢ obs ( l , t 1 ) : Expr t 2 ⊢ a ( p 1 → p 2 ) : Contr 0 α ⊢ e : Expr t ⊢ c : Contr t ⊢ c : Contr t d ∈ N R ⊢ e × c : Contr t ⊢ d ↑ c : Contr t + d 10 / 15
Contract Causality Refined Types ◮ e : Expr t value of e available at time t (or later) α ◮ c : Contr t no obligations strictly before t Typing Rules t 1 , t 2 ∈ Z l ∈ Label α t 1 ≤ t 2 p 1 , p 2 ∈ Party a ∈ Asset Γ ⊢ obs ( l , t 1 ) : Expr t 2 ⊢ a ( p 1 → p 2 ) : Contr 0 α ⊢ e : Expr t ⊢ c : Contr t ⊢ c : Contr t d ∈ N R ⊢ e × c : Contr t ⊢ d ↑ c : Contr t + d . . . 10 / 15
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? 11 / 15
Contract Equivalences e 1 × ( e 2 × c ) ≃ ( e 1 · e 2 ) × c d ↑ ∅ ≃ ∅ d 1 ↑ ( d 2 ↑ c ) ≃ ( d 1 + d 2 ) ↑ c r × ∅ ≃ ∅ d ↑ ( c 1 & c 2 ) ≃ ( d ↑ c 1 ) &( d ↑ c 2 ) 0 × c ≃ ∅ e × ( c 1 & c 2 ) ≃ ( e × c 1 ) &( e × c 2 ) c & ∅ ≃ c d ↑ ( e × c ) ≃ ( d ⇑ e ) × ( d ↑ c ) c 1 & c 2 ≃ c 2 & c 1 d ↑ if b within e then c 1 else c 2 ≃ if d ⇑ b within e then d ↑ c 1 else d ↑ c 2 ( e 1 × a ( p 1 → p 2 )) &( e 2 × a ( p 1 → p 2 )) ≃ ( e 1 + e 2 ) × a ( p 1 → p 2 ) 12 / 15
Reduction Semantics τ ⇒ ρ c ′ = c 13 / 15
Reduction Semantics τ ⇒ ρ c ′ = c τ a , p 1 , p 2 a ( p 1 → p 2 ) = ⇒ ρ ∅ 13 / 15
Reduction Semantics τ ⇒ ρ c ′ = c τ = ⇒ ρ c ′ E � e � ρ = v c e × c v ∗ τ τ a , p 1 , p 2 = ⇒ ρ ( − 1 ⇑ e ) × c ′ a ( p 1 → p 2 ) = ⇒ ρ ∅ 13 / 15
Reduction Semantics τ ⇒ ρ c ′ = c τ = ⇒ ρ c ′ E � e � ρ = v c e × c v ∗ τ τ a , p 1 , p 2 = ⇒ ρ ( − 1 ⇑ e ) × c ′ a ( p 1 → p 2 ) = ⇒ ρ ∅ . . . 13 / 15
Reduction Semantics τ ⇒ ρ c ′ = c τ = ⇒ ρ c ′ E � e � ρ = v c e × c v ∗ τ τ a , p 1 , p 2 = ⇒ ρ ( − 1 ⇑ e ) × c ′ a ( p 1 → p 2 ) = ⇒ ρ ∅ . . . Theorem (Reduction semantics correctness) τ ⇒ ρ c ′ , then (i) If c = (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
Recommend
More recommend