9
Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend to design an efficient framework that can estimate the price of options. The price of the options is of great importance for option investors. Based on our assumptions, if the price of the option estimated is more valuable, it is more likely to have a tidy profit from it. The economic module we used in the framework is well-known Monte Carlo module. And as we know, there are various types of options including Asian options, knock-in or knock-out options, and lookback options. Although these options are somewhat different in definition, during computing the price, the module and the method used are similar so that a well-designed program can reduce most redundancy. The rest of our paper is organized as follows. In Section 2, we introduce the algorithm we use, and our improvement of the classical algorithm. Section 3 shows the implement of the algorithm which is divided as the server and client part, and by utilizing the polymorphism of C#, the codes are more brief and readable. The risk assessment is listed in Section 4, and the way to choose options according to the prices estimated is given. Section 5 gives the parallel performance of our test. Finally, we conclude our experience in this contest. 2. Algorithm 2.1 Monte Carlo Method In mathematical finance, a Monte Carlo option model uses Monte Carlo methods to calculate the value of an option with multiple sources of uncertainty or with complicated features. In terms of theory, Monte Carlo valuation relies on risk neutral valuation. The price of the option is its discounted expected value; see risk neutrality and Rational pricing: Risk Neutral Valuation.

Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

Microsoft – Morgan Stanley Finance Contest

Final Report Endeavor Team

2011/10/28

1. Introduction

In this project, we intend to design an efficient framework that can estimate the price of options.

The price of the options is of great importance for option investors. Based on our assumptions, if

the price of the option estimated is more valuable, it is more likely to have a tidy profit from it.

The economic module we used in the framework is well-known Monte Carlo module. And as we

know, there are various types of options including Asian options, knock-in or knock-out options,

and lookback options. Although these options are somewhat different in definition, during

computing the price, the module and the method used are similar so that a well-designed

program can reduce most redundancy. The rest of our paper is organized as follows. In Section 2,

we introduce the algorithm we use, and our improvement of the classical algorithm. Section 3

shows the implement of the algorithm which is divided as the server and client part, and by

utilizing the polymorphism of C#, the codes are more brief and readable. The risk assessment is

listed in Section 4, and the way to choose options according to the prices estimated is given.

Section 5 gives the parallel performance of our test. Finally, we conclude our experience in this

contest.

2. Algorithm

2.1 Monte Carlo Method

In mathematical finance, a Monte Carlo option model uses Monte Carlo methods to calculate the

value of an option with multiple sources of uncertainty or with complicated features.

In terms of theory, Monte Carlo valuation relies on risk neutral valuation. The price of the option

is its discounted expected value; see risk neutrality and Rational pricing: Risk Neutral Valuation.

Page 2: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

The technique applied then, is (1) to generate several thousand possible (but random) price paths

for the underlying via simulation, and (2) to then calculate the associated exercise value (i.e.

"payoff") of the option for each path. (3) These payoffs are then averaged and (4) discounted to

today. This result is the value of the option.

An option on equity may be modelled with one source of uncertainty: the price of the underlying

stock in question. Here the price of the underlying instrument is usually modelled such that it

follows a geometric Brownian motion with constant drift and volatility . So, where is found via a

random sampling from a normal distribution; see further under Black-Scholes. (Since the

underlying random process is the same, for enough price paths, the value of a european option

here should be the same as under Black Scholes).

Simulation can similarly be used to value options where the payoff depends on the value of

multiple underlying assets such as a Basket option or Rainbow option. Here, correlation between

assets is likewise incorporated.

As can be seen, Monte Carlo Methods are particularly useful in the valuation of options with

multiple sources of uncertainty or with complicated features, which would make them difficult to

value through a straightforward Black-Scholes-style or lattice based computation. The technique

is thus widely used in valuing path dependent structures like lookback and Asian options and in

real options analysis. Additionally, as above, the model is not limited as to the probability

distribution assumed.

2.2 The method of simulation of Brownian motion

2.2.1 Initial Method

Figure 1 gives the method of simulation of geometric Brownian motion by the binomial model.

p = erΔt − d

u − d (1)

u = eσ√Δt (2)

d = e−σ√Δt (3)

Sd

Su

S

p

1-p

Figure 1 Binomial Model

Page 3: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

We can see, when the random number is bigger than p we get a new price Su , others we get Sd .

And from formulation (1), (2), (3), we see that when Δt is infinitely small, and n is infinitely large,

the simulation is similar to the geometric Brownian motion.

2.2.2 Improved Method

The initial method of simulation has a disadvantage that the value calculated by each step is

discrete (e.g. we do 100 step but get 101 discrete values) . So when n is not large enough, we

cannot simulate geometric Brownian motion well. To overcome this shortage, we think a better

version.

First Step:

We use 12 uniform distribution of 0-1 to generate a standard normal distribution value.

Let ε1, ε2, … , εn, … be independent, and each of them is meets [0, 1] uniformly distribution, so

ε1 + ε2 + ⋯ + εn can be considered as normal variables. Generally, we take a small n that can

meet requirement. In the Monte Carlo method, we take n as 12 in normal cases. And use the

following formula to get a new random number sequence.

ηk = ∑ ε12(k−1)+i − 612i=1 , k = 1,2, … (4)

Where ηk is a random number in the normal distribution, and ε12(k−1)+i is a random number

which subjects to a 0-1 uniform distribution. The code is implemented as Figure 2.

Second Step:

We map the standard normal distribution to a log normal distribution (i.e. geometric Brownian

motion) as the following formulation:

public double gaussDistribution(Random rand)

{

double sum = 0;

for (int i = 0; i < 12; i++)

sum += rand.NextDouble();

return sum - 6.0;

}

Figure 2 Gaussian distribution generated by 0-1 uniform distribution

Page 4: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

S(t + Δt) = S(t)e[(μ−1

2σ2)t+σηΔt] (5)

Where every S (t + Δt) is a continuous variable, rather than a discrete binomial value in binomial

model. The code is implemented as Figure 3.

3. Implement

3.1 Server Design

As there are many types of options which have similar way to compute the prices, it is instinctive

to build a parent class and all the real options inherit from the parent class. The most critical and

the only diverse function of the framework is to compute the price of the option, which can be

overridden by the child classed. By doing this, the polymorphism of the object-oriented language

can be fully utilized and lots of redundancy can be reduced. The class diagram of our design is as

shown in Figure 1.

The variables that decide the types of the options should be paid attention to. When typeId is 1,

it is an Asian Option. The price of the option is computed by the average price from buying the

option to expiry. When typeId is 2, it is a knock-in or knock-out option. This kind of option is

valid or invalid once the price reaches some threshold. Otherchoice in this type determine which

one it is. When typeId is 3, it is a lookback option. The price is computed according to the

maximum or minimum of the price. Another four variables that decide the computation diversity

are isCall, isFixed, isUp and isAverage, which record whether the option is a call, fixed, up (if it is

knock-in or knock-out option) option and whether arithmetic average of geometric average

should be used.

public double nextPrice(double curPrice, Random rand, double sigma, double

interest, double deltaT)

{

return Math.Exp(deltaT * (interest - 0.5 * Math.Pow(sigma, 2)) + sigma *

Math.Pow(deltaT, 0.5) * gaussDistribution(rand));

}

Figure 3 Simulation of geometric Brownian motion

Page 5: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

+BasedOptions()+compute_price() : double+Log()+gaussDistribution() : double+nextPrice() : double

#typeId : int#dayNum : int#interest : double#initial : double#exercise : double#up : double#down : double#deltaT : double#threshold : double#isCall : bool#isfixed : bool#isUp : bool#isAverage : int#otherChoice : int#var : double#brownApproxiMethod : int#sigma : double

BasedOptions

+AsianOption()+compute_price() : double

AsianOption

+KnockInOutOption()+compute_price() : double

KnockInOutOption

+LookBackOption()+compute_price() : double

LookBackOption

Figure 4. Class diagram of the server design

The only function we overridden is the critical one, compute_price(), where somewhat different

computation of various options is implemented. Then, the interface exposed to the client only

needs one function, where 3 steps are needed. First, according to the typeId, create the

corresponding instance. Then, invoke the compute_price() function of instance.

Figure 5. Pseudo code of the function exposed to client

public double ComputeOption(int typeId…){

BasedOptions op;

switch(typeId){

case 1:

op = new AsianOption(typeId,

dayNum, …);

break;

…}

return op.compute_price(runs, periods, clientId);

}

Page 6: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

3.2 Client Design

Since server has encapsulate the function we should use, so in the client, the major work is to

create the session, read the data, send request to the server, and get the response. Once the

client send request to the server, the server will invoke the ComputeOpiton function and

compute the price. Here, we support continuously process several options. Meanwhile, to utilize

the multi cores on the server, for every option, we send clientNum requests, and each request

processes part of the total runs and works on a unique core. In reduceOptionPrice, the prices

from all the cores are collected and the function computes the final price. The process is similar

to famous map-reduce process.

Figure 6. Pseudo code of client

Main:

CreateSession

path[0] = @"C:\ContestData\1027-A.csv";

path[1]=…;

using(new client()){

for (int optionsId = 0; optionsId < OptionsNum; optionsId++){

readData(path[optionsId]);

mapOptionsPrice(session, client, optionsId);

}

client.EndRequests();

}

using(new client()){

for (int optionsId = 0; optionsId < OptionsNum; optionsId++){

reduceOptionsPrice(client, optionsId); }

}

session.Close();

mapOptionsPrice: Send Request to Server

for (int clientId = 0; clientId < ClientNum; clientId++){

ComputeOptionRequest request = new ComputeOptionRequest(…);

client.SendRequest<ComputeOptionRequest>(request, ctx);

}

reduceOptionsPrice: Get response from server

foreach (BrokerResponse<ComputeOptionResponse> response in

client.GetResponses<ComputeOptionResponse>()){

price += response.Result.ComputeOptionResult;

}

price = price/ClientNum;

Page 7: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

Today we have done two things. First is to reconstruct the codes. Second is to use a new

approach to measure the risk of options. We call it variance normalization method.

4. Risk Assessment

On the first day of this contest, we considered little about the risk of options and just evaluate an

option by the theoretical expectation payoff. However, when our team analyzed the first day data,

we discovered that some high fair value options also accompanied with high risk (such as option

B2). So we attempted to find some data which can describe the risk of Options.

On the second day, we use the sample variance to describe the risk. At each run of the Monte

Carlo method, we can get a fair value of a specific path. So we collected the samples and

calculated the degree of dispersion. This is an intuitive idea, because the more discrete of the fair

value the more uncertainty of the result. People are always risk aversion, so the uncertainty is the

negative impact of the options. But the results are not satisfactory, because the sample variance

not only describes the uncertainty of the fair value but also affected by the price of premium. So

it's hard to use this parameter to describe the uncertainty of two different options.

On fourth day, we improved our approach based on the sample variance method. And we call it

variance normalization method. We first normalized the sample fair value by the expectation fair

value and then calculate the variance with the normalized data. This method can eliminate the

effects of the premium price.

Figure 1 is the statistical result of Monte Carlo algorithm which runs 15 million times. Standard

Deviation is 0.0031, so the risk is less.

Figure 4 Product A-1 in Day 4 Standard Deviation

0

1

2

3

4

5

log(

n)

fair value - premium

0.00

0.05

0.10

0.15

0.20

0.25

0.30

0.35

Page 8: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

Figure 5 gives Product A-2 in Day 4 Standard Deviation, and the standard deviation is 0.0034, so

there is more risk in A-2.

Figure 5 Product A-2 in Day 4 Standard Deviation

5. Parallel Performance

In this contest, parallel programing contest, parallel performance is a key point of the final result.

So, we make some tests to get a best parameter of our algorithm.

As Figure 6 shows, because the limits of cores we can use, more request per loop does not get

more efficient work. And 32 request every loop gets the least time, so we choose this parameter.

Figure 6 Parallel Number of Time Table

More parameters is listed in Figure 7.

0

1

2

3

4

5

6

log(

n)

fair value - premium

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0

20

40

60

80

100

120

140

160

180

4 8 16 32 64 128

Tim

e(s

ecs

)

Core Number

Page 9: Microsoft Morgan Stanley Finance Contest Final Report · Microsoft – Morgan Stanley Finance Contest Final Report Endeavor Team 2011/10/28 1. Introduction In this project, we intend

Number of request 32

Number of total runs 5000000

Number of every cores runs 1000

Figure 7 More Parameters

6. Conclude

Thanks for the finance contest held improvement by Microsoft and Morgan Stanley, we learned

lots of options information and technology of parallel programming these days. We conclude our

experience of the contest day as following.

Day1: not included risk Assessment.

Day2: assess the risk by the variance, but the drawback is that the variance is affected by the

mean (i.e. the higher the option price, the greater the variance).

Day3: Normalize variance to evaluate the risk. This method solve the above shortage. The

specific method is that every sample is divided by the expected first, which makes the expected

value to 1, and then get the variance of the processed data.

∑(

xiE(x)

−1)2

N−1i=1N (6)

Day4: Reconstruct our code and make it more readable.

Day5: Write the final report, and conclude our experience in this contest.