Composing contracts An adventure in financial engineering Simon Peyton Jones and Julian Seward, Microsoft Research and Jean Marc Eber, LexiFi Technologies.

Slides:



Advertisements
Similar presentations
Credit Risk. Credit risk Risk of financial loss owing to counterparty failure to perform its contractual obligations. For financial institutions credit.
Advertisements

The Fun of Programming Chapter 6 How to Write a Financial Contract by Simon Peyton Jones Roger L. Costello July
CC 2007, 2011 attribution - R.B. Allen Tasks and Activities.
Present Value Comparison Construction Engineering 221 Economic Analysis.
IAAnalyzer: Towards a Model-Driven Modeling and Analysis Framework for C ONNECT(ors) Massimo Tivoli, University of L’Aquila (UNIVAQ)
Chapter 12: Basic option theory
MATH 224 – Discrete Mathematics
Compositional Description, Valuation, and Management of Financial Contracts: The MLFi Language Jean-Marc Eber, LexiFi Based on.
Chapter 3: Modules, Hierarchy Charts, and Documentation
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Chris Dzera.  Explore specific inputs into Vasicek’s model, how to find them and whether or not we can get the mean back after simulations with realistic.
Derivatives Workshop Actuarial Society October 30, 2007.
CHAPTER NINETEEN OPTIONS. TYPES OF OPTION CONTRACTS n WHAT IS AN OPTION? Definition: a type of contract between two investors where one grants the other.
Week 4 Options: Basic Concepts. Definitions (1/2) Although, many different types of options, some quite exotic, have been introduced into the market,
Currency Option Valuation stochastic Option valuation involves the mathematics of stochastic processes. The term stochastic means random; stochastic processes.
Financial Innovation & Product Design II Dr. Helmut Elsinger « Options, Futures and Other Derivatives », John Hull, Chapter 22 BIART Sébastien The Standard.
Valuation of Financial Options Ahmad Alanani Canadian Undergraduate Mathematics Conference 2005.
Derivatives  A derivative is a product with value derived from an underlying asset.  Ask price – Market-maker asks for the high price  Bid price –
Framework is l Reusable Code, often domain specific (GUI, Net, Web, etc) l expressed as l a set of classes and l the way objects in those classes collaborate.
1 FASB’s MOVE TOWARDS FAIR VALUE AND ACADEMIC RESEARCH Derivatives Contingencies Financial instruments Stock Options – 123R Guarantees – Int. 45 Fair value.
FIXatdl and the 2010 Flash Crash Robert Golan – DBmind Technologies Rick Labs - CL&B Capital Management, LLC (& FIXatdl Co-Chair) Please Note: This is.
The Z Specification Language
Planning under Uncertainty
The Unified Software Development Process - Workflows Ivar Jacobson, Grady Booch, James Rumbaugh Addison Wesley, 1999.
Derivatives Options on Bonds and Interest Rates Professor André Farber Solvay Business School Université Libre de Bruxelles.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Operational Semantics.
Vienna, 18 Oct 08 A perturbative approach to Bermudan Options pricing with applications Roberto Baviera, Rates Derivatives Trader & Structurer, Abaxbank.
University of Minnesota, Jan. 21, 2011 Equity Derivatives Dave Engebretson Quantitative Analyst Citigroup Derivative Markets, Inc. January 21, 2011.
Chapter 9 Domain Models 1CS6359 Fall 2012 John Cole.
Mathematics throughout the CS Curriculum Support by NSF #
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Fundamentals of Python: From First Programs Through Data Structures
1 L07SoftwareDevelopmentMethod.pptCMSC 104, Version 8/06 Software Development Method Topics l Software Development Life Cycle Reading l Section 1.4 – 1.5.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Fundamentals of Python: First Programs
1 Shawlands Academy Higher Computing Software Development Unit.
Implementation Yaodong Bi. Introduction to Implementation Purposes of Implementation – Plan the system integrations required in each iteration – Distribute.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Speaking Bluntly about SharpHDL: Some Old Stuff and Some Other Proposed Future Extensions Gordon J. Pace & Christine Vella Synchron’05 Malta, November.
D. M. ChanceAn Introduction to Derivatives and Risk Management, 6th ed.Ch. 4: 1 Chapter 4: Option Pricing Models: The Binomial Model You can think of a.
CHAPTER 8 OPTIONS DERIVATIVES.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Chapter 10: Options Markets Tuesday March 22, 2011 By Josh Pickrell.
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Chapter 5 Hedging Interest-Rate Risk with Duration FIXED-INCOME SECURITIES.
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
CMSC 1041 Algorithms II Software Development Life-Cycle.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
I Power Higher Computing Software Development The Software Development Process.
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
Intermediate 2 Software Development Process. Software You should already know that any computer system is made up of hardware and software. The term hardware.
GEK Frederick H. Willeboordse Compound & Prosper!
1 MGT 821/ECON 873 Financial Derivatives Lecture 1 Introduction.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Adobe Photoshop CS5 – Illustrated Unit A: Getting Started with Photoshop CS5.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
CHAPTER NINETEEN OPTIONS. TYPES OF OPTION CONTRACTS n WHAT IS AN OPTION? Definition: a type of contract between two investors where one grants the other.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Course: Software Engineering – Design I IntroductionSlide Number 1 What is a specification Description of a (computer) system, which:  is precise;  defines.
Adobe Photoshop CS4 – Illustrated Unit A: Getting Started with Photoshop CS4.
11.1 Options and Swaps LECTURE Aims and Learning Objectives By the end of this session students should be able to: Understand how the market.
Primbs, MS&E More Applications of Linear Pricing.
PROGRAMMING: What’s It All About?
Topic: Python’s building blocks -> Variables, Values, and Types
Algorithms II Software Development Life-Cycle.
Built by Schools for Schools
Chapter 15 QUERY EXECUTION.
Microsoft Visual Basic 2005 BASICS
Top-Down Design & JSP Skill Area Part D
Presentation transcript:

Composing contracts An adventure in financial engineering Simon Peyton Jones and Julian Seward, Microsoft Research and Jean Marc Eber, LexiFi Technologies

The big picture Financial engineering Programming language design and implementation Jean Marc Simon and Julian

The big picture Financial engineering Programming language design and implementation Jean Marc Simon and Julian Swaps, caps, options, european, bermudan, straddle, floors, swaptions, swallows, spreads, futures

Combinator library Denotational semantics Operational semantics

What we want to do Precise description of a contract Scheduling for back office Valuation and hedging Legal and documentation etc….

What we want to do Precise description of a pudding Compute sugar content Estimate time to make Instructions to make it etc….

What we want to do Precise description of a pudding Compute sugar content Estimate time to make Instructions to make it Bad approach List all puddings ( trifle, lemon upside down pudding, Dutch apple cake, Christmas pudding) For each pudding, write down sugar content, time to make, instructions etc

What we want to do Precise description of a pudding Compute sugar content Estimate time to make Instructions to make it Good approach Define a small set of pudding combinators Define all puddings in terms of these combinators Calculate sugar content from these combinators too

Creamy fruit salad On top of Take Whipped 1 pintCream Mixture Take Chopped 3Apples Take 6Oranges Optional Combinators combine small puddings into bigger puddings

Trees can be written as text On top of Take Whipped 1 pintCream Mixture Take Chopped 3Apples Take 6Oranges Optional salad = onTopOf topping main_part topping = whipped (take pint cream) main_part = mixture apple_part orange_part apple_part = chopped (take 3 apple) orange_part = optional (take 6 oranges) Notation: parent child1 child2 function arg1 arg2 Slogan: a domain-specific language for describing puddings

Building a simple contract c1 :: Contract c1 = zcb (date 1 Jan 2010) 100 Pounds zcb :: Date -> Float -> Currency -> Contract -- Zero coupon bond Receive £100 on 1 Jan 2010 Combinators will appear in blue boxes

Combing contracts c1,c2,c3 :: Contract c1 = zcb (date 1 Jan 2010) 100 Pounds c2 = zcb (date 1 Jan 2011) 100 Pounds c3 = and c1 c2 and :: Contract -> Contract -> Contract -- Both c1 and c2 and zcb t1 100 Poundszcb t2 100 Pounds c1c2 c3

Inverting a contract and zcb t1 100 Poundszcb t2 100 Pounds give :: Contract -> Contract -- Invert role of parties c4 = c1 `and` give c2 give c2 c4 c1 and is like addition give is like negation Backquotes for infix notation

New combinators from old andGive :: Contract -> Contract -> Contract andGive u1 u2 = u1 `and` give u2 andGive is a new combinator, defined in terms of simpler combinators To the user, andGive is no different to a primitive, built-in combinator This is the key to extensibility: users can write their own libraries of combinators to extend the built-in ones

Defining zcb Indeed, zcb is not primitive: zcb :: Date -> Float -> Currency -> Contract zcb t f k = at t (scaleK f (one k)) one :: Currency -> Contract -- Receive one unit of currency immediately scaleK :: Float -> Contract -> Contract -- Acquire specified number of contracts at :: Date -> Contract -> Contract -- Acquire the contract at specified date

Acquisition dates one :: Currency -> Contract -- Receive one unit of currency immediately at :: Date -> Contract -> Contract -- Acquire the underlying contract at specified date If you acquire the contract (one k), you receive one unit of currency k immediately If you acquire the contract (at t u) at time s<t, then you acquire the contract u at the (later) time t. You cannot acquire (at t u) after t. The latest acquisition date of a contract is its horizon.

Choice An option gives the flexibility to Choose which contract to acquire (or, as a special case, whether to acquire a contract) Choose when to acquire a contract (exercising the option = acquiring the underlying contract)

Choose which or :: Contract -> Contract -> Contract -- Acquire either c1 or c2 immediately zero :: Contract -- A worthless contract european :: Date -> Contract -> Contract european t u = at t (u `or` zero) European option: at a particular date you may choose to acquire an underlying contract, or to decline

Reminder… Remember that the underlying contract is arbitrary c5 :: Contract c5 =european t1 (european t2 c1) This is already beyond what current systems can handle

Choose when: American options anytime :: Contract -> Contract -- Acquire the underlying contract at -- any time before it expires (but -- you must acquire it) The option to acquire 10 Microsoft shares, for $100, anytime between t1 and t2 years from now golden_handcuff = anytime shares shares = zero `or` (scaleK -100 (one Dollar) `and` scaleK 10 (one MSShare)) anytime : Choose when MS shares are a currency or : Choose whether

Setting the window golden_handcuff = at t1 (anytime (truncate t2 shares)) truncate :: Date -> Contract -> Contract -- Truncate the horizon of a contract at :: Date -> Contract -> Contract -- Acquire the underlying contract at specified date Cant acquire shares after t2 Acquire the anytime rights at t1

Observables Pay me $1000 * (the number of inches of snow - 10) on 1 Jan 2002 c :: Contract c = at 1 Jan 2002 (scale scale_factor (one Dollar)) scale_factor :: Observable scale_factor = 1000 * (snow - 10) scale :: Observable -> Contract -> Contract -- Scale the contract by the value of the observable -- at the moment of acquisition snow :: Observable (*), (-) :: Observable -> Observable -> Observable

Summary so far Only 10 combinators (after many, many design iterations) Each combinator does one thing Can be combined to describe a rich variety of contracts Surprisingly elegant

But what does it all mean? We need an absolutely precise specification of what the combinators mean: their semantics And we would like to do something useful with our (now precisely described) contracts One very useful thing is to compute a contracts value

Processing puddings Wanted: S(P), the sugar content of pudding P S( onTopOf p1 p2 ) = S( p1 ) + S( p2 ) S( whipped p ) = S( p ) S( take q i )= q * S(i) …etc… When we define a new recipe, we can calculate its sugar content with no further work Only if we add new combinators or new ingredients do we need to enhance S

Processing puddings Wanted: S(P), the sugar content of pudding P S( onTopOf p1 p2 ) = S( p1 ) + S( p2 ) S( whipped p ) = S( p ) S(take q i)= q * S(i) …etc… S is compositional To compute S for a compound pudding, Compute S for the sub-puddings Combine the results in some combinator-dependent way

What is the denotation of a contract? The denotation of a program is a mathematical value that embodies what the program means Two programs are equivalent if they have the same denotation A denotational semantics should be compositional: the denotation of (P1 + P2) is gotten by combining somehow the denotations of P1 and P2

What is the denotation of a contract? Main idea: the denotation of a contract is a random process that models the value of acquiring the contract at that moment. : Contract -> RandomProcess RandomProcess = Time -> RandomVariable Uncertainty increases with time Time

Compositional valuation ( c1 `and` c2 ) = ( c1 ) + ( c2 ) ( c1 `or` c2 )= max( ( c1 ), ( c2 ) ) ( give c )= - ( c ) ( anytime c )= snell( ( c ) ) ( at t c )= discount( ( c )[t] ) …etc… This is a major payoff! Deal with the 10-ish combinators, and we are done with valuation! Add random processes point-wise

Valuation There are many numerical methods to compute discrete approximations to random processes (tons and tons and tons and tons and tons and tons and tons and tons and tons and tons of existing work) Contract Model of world (e.g. interest rates) Valuation engine

One possible evaluation model: BDT contract C 5% 6% 4% zcb Pounds interest rate model M Value tree (C) Valuation engine

Space and time Obvious implementation computes the value tree for each sub-contract But these value trees can get BIG And often, parts of them are not needed at t t simple discounting

Haskell to the rescue Lazy evaluation means that data structures are computed incrementally, as they are needed (so the trees never exist in memory all at once) parts that are never needed are never computed Slogan We think of the tree as a first class value all at once but it is only materialised piecemeal

An operational semantics As time goes on, a contract evolves e.g. zcb t1 n k `and` zcb t2 n k Want to value your current contract book So we want to say formally how a contract, or group of contract evolves with time, and how it interacts with its environment (e.g. emit cash, make choice) Work on the operational semantics of programming languages is directly relevant (e.g. bisimulation)

Reasoning about equivalence Using this semantics we can prove (for example) that anytime (anytime c) = anytime c Depends on algebra of random processes (snell, discount, etc). Bring on the mathematicians!

A compiler for contracts Contract Take semantics Random process Transform using algebraic laws Code generation Valuation program

A compiler for contracts Contract Take semantics Random process Code generation Valuation program Evolve using operational semantics

Summary A small set of built-in combinators: named and tamed A user-extensible library defines the zoo of contracts Compositional denotational semantics, leads directly to modular valuation algorithms Risk Magazine Software Product of the Year Prize Jean-Marc has started a company, LexiFi, to commercialise the ideas Routine for us, radical stuff for financial engineers

Summary A small set of built-in combinators: named and tamed A user-extensible library defines the zoo of contracts Compositional denotational semantics, leads directly to modular valuation algorithms Risk Magazine Software Product of the Year Prize Jean-Marc has started a company, LexiFi, to commercialise the ideas Beats higher order logic hands down for party conversation Routine for us, radical stuff for financial engineers