32
Using C++ to Evaluate the Using C to Evaluate the Physics of Finance This course will discuss numerical methods such as finite differences and Monte Carlo techniques to solve PDEs differences and Monte Carlo techniques to solve PDEs. Furthermore, the basics C++ will be presented in such a way that each participant will develop his own OO class library that i bl t l lt i f it d i ti fi il is capable to calculate prices of equity derivative financial products. Su ƒ Begin: Friday 17 th October ƒ u Sd S ƒ Begin: Friday 17 th October Time: 12:30-14:00 Recitation: 14:15-15:00 Sd ƒ d http://www.ep1.rub.de/vorlesungen.html

Using CUsing C++ to Evaluate theto Evaluate the Physics …ep1.rub.de/lehre/veranstaltungen/alt/ws0809/cppfin/skript/pof01.pdf · ... C++ to Evaluate theto Evaluate the Physics of

Embed Size (px)

Citation preview

Using C++ to Evaluate theUsing C to Evaluate the Physics of Finance

This course will discuss numerical methods such as finite differences and Monte Carlo techniques to solve PDEsdifferences and Monte Carlo techniques to solve PDEs. Furthermore, the basics C++ will be presented in such a way that each participant will develop his own OO class library that i bl t l l t i f it d i ti fi i lis capable to calculate prices of equity derivative financial products. Su

ƒBegin: Friday 17th October ƒu

Sd

Begin: Friday 17th OctoberTime: 12:30-14:00 Recitation: 14:15-15:00

Sdƒd

ƒhttp://www.ep1.rub.de/vorlesungen.html

ContactJames RitmanRaum NB 2-167Tel 23532Tel. [email protected]

Tobias StockmannsForschungzentrum Juelich02461 61 [email protected]

http://www.ep1.rub.de/vorlesungen.html

Overview• Basics of Forwards, Futures,

and Options • Greek Letters

Fi i diff dp

• Introduction to C++, basic facilities

• Properties of Stock Option

• Finite differences and PDEs

• Estimating volas and• Properties of Stock Option Prices & trading strategies

• Classes in C++

Estimating volas and correlations

• FFT and Moment i f i• Trees for Option Pricing

• C++ && Random Number Generation

generating functions

Generation• Model of Stock Price Behavior

and Black ScholesI l i T d M• Implementing Trees and Monte Carlo Methods in C++

Book List (a)Book List (a)

J C Hull Opti F t d Oth D i tiJ.C. Hull, Options, Futures, and Other Derivatives, 7th ed. (2008) http://www.rotman.utoronto.ca/~hull/ofod/

Darrell Duffy, Dynamic Asset Pricing Theory, Princeton UnivPress 1996.Press 1996.

H P Deutsch Derivate und Interne Modell 2001H.-P. Deutsch, Derivate und Interne Modell, 2001.

Book List (b)

lW. Press et al., Numerical Recipes in Chttp://www.ulib.org/webRoot/Books/Numerical_Recipes/bookcpdf.html

H.M.Deitel and P.J.Deitel C++ How to Program Prentice Hall.

B. Stroustrup, The C++ Programming Language Addison-Wesley.

"C makes it easy to shoot yourself in the foot; C++ makes it harder, y y ,but when you do it blows your whole leg off." (B.S).

Online C++ Resources

There are many online C++ web tutorials that one can easily find with one of the main search engines. g

One “randomly” chosen web tutorial from Peter Müller ishttp://www.desy.de/user/projects/C++/courses/cc/Tutorial/tutorial.htmlp://www.desy.de/use /p ojec s/C /cou ses/cc/ u o a / u o a .

I t d tiIntroduction

Chapter 1

These foil are taken directly from Hull’s web page

7Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C. Hull 2008

The Nature of Derivatives

A derivative is an instrument whose value depends on the values of other more basic underlying variables

Types of Derivatives• Swaps• Options• Forward Contracts• Futures Contracts

Ways Derivatives are Used• To hedge risksTo hedge risks• To speculate (take a view on the

future direction of the market))• To lock in an arbitrage profit• To change the nature of a liabilityTo change the nature of a liability• To change the nature of an investment

without incurring the costs of selling ou cu g e cos s o se gone portfolio and buying another

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

9

Foreign Exchange Quotes for GBP, July 20, 2007 (See page 4)

Bid OfferSpot 2 0558 2 0562Spot 2.0558 2.0562

1-month forward 2.0547 2.0552

3-month forward 2.0526 2.0531

6-month forward 2.0483 2.0489

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

10

Forward PriceForward Price• The forward price for a contract is

the delivery price that would be applicable to the contract if were negotiated today (i.e., it is the delivery price that would make the contract worth exactly zero)

• The forward price may be different p yfor contracts of different maturities

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

11

Terminology

• The party that has agreed to buy has what is termed a long position

• The party that has agreed to p y gsell has what is termed a short positionp

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

12

Example (page 4)

• On July 20, 2007 the treasurer of a corporation enters into a long forward p gcontract to buy £1 million in six months at an exchange rate of 2.0489g

• This obligates the corporation to pay $2 048 900 for £1 million on January 20$2,048,900 for £1 million on January 20, 2008

• What are the possible outcomes?Options, Futures, and Other

Derivatives, 7th Edition, Copyright © John C Hull 2008

13

• What are the possible outcomes?

Profit from aProfit from aLong Forward Position

Profit

Price of UnderlyingPrice of Underlyingat Maturity, STK

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

14

Profit from aProfit from a Short Forward Position

Profit

Price of UnderlyingPrice of Underlyingat Maturity, STK

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

15

Futures Contracts (page 6)

• Agreement to buy or sell an asset for a certain price at a certain time

• Similar to forward contract• Whereas a forward contract is tradedWhereas a forward contract is traded

OTC, a futures contract is traded on an exchangean exchange

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

16

Exchanges Trading Futures

• Chicago Board of Trade• Chicago Mercantile ExchangeChicago Mercantile Exchange• LIFFE (London)

E (E )• Eurex (Europe)• BM&F (Sao Paulo, Brazil)• TIFFE (Tokyo)• and many more (see list at end of book)

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

17

and many more (see list at end of book)

Examples of Futures Contracts

A t tAgreement to:– Buy 100 oz. of gold @ US$900/oz. in

D b (NYMEX)December (NYMEX) – Sell £62,500 @ 2.0500 US$/£ in March

(CME)(CME)– Sell 1,000 bbl. of oil @ US$120/bbl. in

April (NYMEX)April (NYMEX)

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

18

1. Gold: An Arbitrage1. Gold: An Arbitrage Opportunity?

Suppose that:The spot price of gold is US$900The 1-year forward price of gold is

US$1 020US$1,020The 1-year US$ interest rate is 5% per

annumannumIs there an arbitrage opportunity?

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

19

2 Gold: Another Arbitrage2. Gold: Another Arbitrage Opportunity?

Suppose that:The spot price of gold is US$900- The spot price of gold is US$900

- The 1-year forward price of gold is US$900US$900

- The 1-year US$ interest rate is 5% per annum

Is there an arbitrage opportunity?

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

20

Th F d P i f G ldThe Forward Price of Gold

If the spot price of gold is S and the forward price for a contract d li bl i T i F thdeliverable in T years is F, then

F = S (1+r )T

where r is the 1-year (domestic currency) risk-free rate of interest.In our examples, S = 900, T = 1, and r=0.05 so that

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

21F = 900(1+0.05) = 945

1. Oil: An Arbitrage Opportunity?

S hSuppose that:- The spot price of oil is US$95

f f- The quoted 1-year futures price of oil is US$125

- The 1 year US$ interest rate is- The 1-year US$ interest rate is 5% per annum

- The storage costs of oil are 2%The storage costs of oil are 2% per annum

Is there an arbitrage opportunity?Options, Futures, and Other

Derivatives, 7th Edition, Copyright © John C Hull 2008

22

g pp y

2 Oil: Another Arbitrage2. Oil: Another Arbitrage Opportunity?

S th tSuppose that:- The spot price of oil is US$95

Th t d 1 f t i f- The quoted 1-year futures price of oil is US$80

- The 1 year US$ interest rate isThe 1-year US$ interest rate is 5% per annum

- The storage costs of oil are 2% gper annum

Is there an arbitrage opportunity?

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

23

g y

Options

• A call option is an option to buy a certain asset by a certain date for a ycertain price (the strike price)

• A put option is an option to sell a certainA put option is an option to sell a certain asset by a certain date for a certain price (the strike price)price (the strike price)

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

24

American vs European Options

• An American option can be exercised at any time during its lifey g

• A European option can be exercised only at maturityonly at maturity

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

25

Exchanges Trading Options

• Chicago Board Options Exchange• American Stock ExchangeAmerican Stock Exchange• Philadelphia Stock Exchange

P ifi E h• Pacific Exchange• LIFFE (London)• Eurex (Europe)• and many more (see list at end of book)

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

26

and many more (see list at end of book)

Options vs Futures/Forwards

• A futures/forward contract gives the holder the obligation to buy or sell at a g ycertain price

• An option gives the holder the right toAn option gives the holder the right to buy or sell at a certain price

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

27

Payoffs from OptionsWhat is the Option Position in Each Case?X = Strike price, ST = Price of asset at maturity

Payoff Payoff

XMust sell for X

ST STXX

Allowed to buy for X

Payoff Payoff

X

y

Must buy for X

ST STXX

Allowed to sell for XAllowed to sell for X

Intel Option Prices (Sept 12, 2006; Stock Price=19.56); See T bl 1 2 7 S CBOETable 1.2 page 7; Source: CBOE

Strike Price

Oct Call

Jan Call

Apr Call

Oct Put

Jan Put

Apr Put

15.00 4.650 4.950 5.150 0.025 0.150 0.27515.00 4.650 4.950 5.150 0.025 0.150 0.275

17.50 2.300 2.775 3.150 0.125 0.475 0.725

20.00 0.575 1.175 1.650 0.875 1.375 1.700

22.50 0.075 0.375 0.725 2.950 3.100 3.300

25.00 0.025 0.125 0.275 5.450 5.450 5.450

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

29

Types of TradersTypes of Traders

H d• Hedgers

• Speculatorsp

• ArbitrageursSome of the largest trading losses in derivatives have occurred because individuals who had a mandate to be hedgers or arbitrage rs s itched to being spec lators (Seehedgers or arbitrageurs switched to being speculators (See for example Barings Bank, Business Snapshot 1.2, page 15)

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

30

Hedging Examples (pages 10 11)Hedging Examples (pages 10-11)

• A US company will pay £10 million for imports from Britain in 3 months and decides to hedge using a long position i f d t tin a forward contract

• An investor owns 1,000 Microsoft shares c rrentl orth $28 per shareshares currently worth $28 per share. A two-month put with a strike price of $27 50 costs $1 The investor decides$27.50 costs $1. The investor decides to hedge by buying 10 contracts

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

31

Value of Microsoft Shares withValue of Microsoft Shares with and without Hedging (Fig 1.4, page 11)

35,000

40,000 Value of Holding ($)

30,000

No Hedging

Hedging

20,000

25,000

20 25 30 35 40

Stock Price ($)

Options, Futures, and Other Derivatives, 7th Edition, Copyright ©

John C Hull 2008

32