Matlab: pricing nonstandard fictitious option using monte carlo simulation

  • Thread starter Thread starter Bhoj
  • Start date Start date
I literally gave you the exact way to do this. normrnd(0, 1, 10, numsim). 10*normrnd just multiplies each element of the vector by 10. You dont want to create 10 sample paths, you want to create numsum sample paths. Each sample path has 10 random variables.

you need to do cumprod before multiplying by s0. Also note that cumprod will return a matrix, not a vector...you need the last element of each column of the matrix. I would suggest coding this with a small numsum (say 5) and looking at the results each line gives (just leave off the semicolon). That will show you what is going on.
 
thanks again. sorry I am bothering you a lot. But I again get error"not enough input argument" in the line where there normrnd. I used ur code literally. I didnot understand you mean that I need to use cumprod before I do payoffs. here is the new code.
Code:
%function to price non standard option using monte carlo
function [C,Cl,Cu] = assignment(S0,Rt,T,sigma,delta, numsim)
%S0=initial stock price, Rt=excess return over risk free rate, T=time,
%sigma=volatility,numsim=number of simulations, delta=devidend yield
R=0.03;%risk free rate is constant over lifetime of option
delta=0.02;%dividend given
S0=100;%given initial stock price
sigma=0.3;%given volatility
r=log(1+R);
mat=normrnd(0,1,10,numsim);
cumprod(mat)
%put mat definition here (using my suggestion for matrix of random variables)
Rt=exp(r-delta-0.5*sigma*sigma+sigma*mat)-1;
%put code for max(Rt, R) and cumprod("result") here
payoffs(XT)=S0(1+max(R,Rt));
g=exp(-r*T)*payoffs;
C=mean(g);s=std(g);
Cl=C-1.96/sqrt(numsim)*s;
Cu=C+1.96/sqrt(numsim)*s;
 
DStahl man you need to help fix this shit matrix mat. I tried every possible way but it gives me error telling me not enough input argument. As for cumprod I have put it before result. Please check and let me know.
Code:
%function to price non standard option using monte carlo
function [C,Cl,Cu] = assignment(S0,Rt,T,sigma,delta, numsim)
%S0=initial stock price, Rt=excess return over risk free rate, T=time,
%sigma=volatility,numsim=number of simulations, delta=devidend yield
R=0.03;%risk free rate is constant over lifetime of option
delta=0.02;%dividend given
S0=100;%given initial stock price
sigma=0.3;%given volatility
r=log(1+R);
[COLOR=#ff0000]mat=normrnd(0,1,[10,numsim]);[/COLOR]
%put mat definition here (using my suggestion for matrix of random variables)
[COLOR=#ff0000]Rt=cumprod(exp(r-delta-0.5*sigma*sigma+sigma*mat)-1);[/COLOR]
%put code for max(Rt, R) and cumprod("result") here
payoffs(XT)=S0(1+max(R,Rt));
g=exp(-r*T)*payoffs;
C=mean(g);s=std(g);
Cl=C-1.96/sqrt(numsim)*s;
Cu=C+1.96/sqrt(numsim)*s;
 
I have no idea why normrnd(0, 1, 10, numsim) isnt working...its working for me.

Rt was defined better before...the cumprod should occur after you do the 1+max(Rt, R) function. cumprod takes the cumulative product of the rows in each column of the matrix, which is the payoff given in the problem.

I am just going to attach my function code.

Script file:
Code:
s=100;
sigma=.3;
R=.03;
delta=.02;
t=10;
numsim=1000000;
tic
[answ, stder, conf]=nonstandard(s, R, t, sigma, delta, numsim)
toc

function file:
Code:
function [ x0, stder, conf ] = nonstandard(s, R, t, sigma, delta, numsim )
r=log(R+1);
randmat=normrnd(0, 1, t, numsim);
rt=exp((r-delta-sigma*sigma*.5)+sigma*randmat)-1;
p=1+max(rt, R);
x=cumprod(p, 1);
x=s*x(t, : );
x0=exp(-r*t)*mean(x);
stder=std(x)/sqrt(numsim);
conf=[x0-1.96*stder, x0+1.96*stder];
end

my output is

answ =

280.0079


stder =

0.2302


conf =

279.5567 280.4591

Elapsed time is 2.126252 seconds.
 
Thanks man! your program seems to work but mine always gives this stupid error. Now I need to do question 5, could you please give me hint how can I incorporate control variate in the program that we have. I don't know how to deduce the question 2 to show price of F0 is FT. That would be good starting point for me to start coding. Thanks a lot for help.
 
To be honest I have no idea what they mean by control variate in this case. It seems to me that knowing Ft says something about X, but nothing overly precise (ie, not helpful in doing Monte Carlo).

Question two can be deduced (I am assuming) by using the hint...if you need help on the formula for a call option google "black scholes call option formula".
 
Back
Top