Margrabe Formula – R Code

This is a simple example of the Margrabe formula which is a closed-form solution for the right to exchange asset i over asset j at time T.


## Margrabe formula
## right to exchange the second asset for the first at time T
## payout: max(0, S1(T) - S2(T))

# clear environment and console
rm(list = ls())
cat("\014")

# inputs
S1 = 10 # initial stock 1 price
S2 = 10 # initial stock 2 price
sigma1 = 0.2 # volatility of stock 1
sigma2 = 0.3 # volatility of stock 2
rho = 0.3 # correlation of stock 1 and 2
q1 = 0 # expected dividends for stock 1
q2 = 0 # expected dividends for stock 2
T = 3 # number of years

# calculate price of call option

sigma = sqrt(sigma1^2 - 2 * rho * sigma1 * sigma2 + sigma2^2)
d1 = (log(S1/S2) + (q2 - q1 + 0.5 * sigma^2) * T)/ (sigma * sqrt(T))
d2 = d1 - sigma * sqrt(T)

v = S1 * exp(-q1 * T) * pnorm(d1) - S2 * exp(-q2 * T) * pnorm(d2)
v

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s