Serving the Quantitative Finance Community

 
User avatar
festivie
Topic Author
Posts: 0
Joined: October 8th, 2005, 7:41 pm

Help in MC Simulation!

December 7th, 2005, 6:43 pm

Hello All,I need to price barrier options with Monte Carlo Simulations in GUI. My code is,function [Price,CI] = BlsMCAV(S0,X,r,T,sigma,NRepl)nuT = (r-0.5*sigma^2)*T;siT = sigma * sqrt(T);Veps = randn(NRepl,1);Payoff1 = max(0, S0*exp(nuT+siT*Veps)-X);Payoff2 = max(0, S0*exp(nuT+siT*(-Veps))-X); DiscPayoff = exp(-r*T) * 0.5 * (Payoff1+Payoff2);[Price, VarPrice, CI] = normfit(DiscPayoff); Can you help me to write the code for simulationit. I am trying but it does not work out. Thanks in advance. RegardsFestivie
 
User avatar
Claudio2323
Posts: 0
Joined: October 8th, 2004, 1:13 pm

Help in MC Simulation!

December 8th, 2005, 10:54 pm

sorry, do you need MATLAB code for Barrier?
 
User avatar
festivie
Topic Author
Posts: 0
Joined: October 8th, 2005, 7:41 pm

Help in MC Simulation!

December 9th, 2005, 2:56 pm

Hi,Yes I need matlab code for barrier. Can you help me?
 
User avatar
MF05JY
Posts: 1
Joined: December 6th, 2005, 6:36 pm

Help in MC Simulation!

December 10th, 2005, 12:27 am

Hi FestivieI try to run your programme in Matlab. It works. But, what's your equation for the barrier option??? >> BlsMCAV(100,100,0.2,1,0.1,4)nuT = 0.1950siT = 0.1000Veps = -0.1867 0.7258 -0.5883 2.1832Payoff1 = 19.2831 30.6797 14.5875 51.1827Payoff2 = 23.8215 13.0230 28.8955 0DiscPayoff = 17.6455 17.8904 17.8004 20.9524Price = 18.5722VarPrice = 1.5900CI = 16.0421 21.1023ans = 18.5722
 
User avatar
Claudio2323
Posts: 0
Joined: October 8th, 2004, 1:13 pm

Help in MC Simulation!

December 10th, 2005, 12:47 pm

Hi,try this book from Paolo Brandimarte: "Numerical methods in finance: a MATLAB-based introduction" you can find MC or QMC for Barrier... (think you can find some code on the web as well....)hope it helps,
 
User avatar
festivie
Topic Author
Posts: 0
Joined: October 8th, 2005, 7:41 pm

Help in MC Simulation!

December 10th, 2005, 2:25 pm

Hello MF05JY,Thanks for your reply and help. I am a beginner in Matlab GUI. I have got the analytical results but find difficulty in the simulation part. If it is ok can you tell me how did u simualte it (I mean the code for simulation)? The formula for pricing barrier options:The price of an option is :C0 = E[e-rT(max(0, ST-K1)I { ST/2≤L} + max (0, ST-K2)I { ST/2>L})] where as usual, C0 = E[Y] whereY:=e-rT/2(c(ST/2, T/2, K1,r, σ )I{ ST/2≤L} + c(ST/2, T/2, K2,r, σ )I{ ST/2≥L})where c(x,t,k,r,σ ) is the price of European call option with strike k, interest rate r, volatility σ, time to maturity t, and initial stock price x. Thanks again.Festivie
 
User avatar
festivie
Topic Author
Posts: 0
Joined: October 8th, 2005, 7:41 pm

Help in MC Simulation!

December 10th, 2005, 2:27 pm

Hello Claudio,Thanks for your help.Festivie
 
User avatar
MF05JY
Posts: 1
Joined: December 6th, 2005, 6:36 pm

Help in MC Simulation!

December 11th, 2005, 12:12 am

Hi Festivie, It seems the Matlab code and your equations are not matching each other. I think your orginal code is the Monte Carlo of European Call with a variance reduction method. It is not a barrier option. For the equation, are you trying to price two different European Option together with a line at ST/2??Anyway, I just copy your code in the Matlab and run. Of course, I put some number in the function.