plotting the situation for some geometric brownian motions hitting the optimal stopping boundary
Show older comments
Hello People
I am new to plotting using Matlab...But I have to use it in my thesis to plot the situation of two or three sample paths of independent geometric brownian motions which hit the optimal exercise boundary. In the Xlabel i want to show the price paths for those prices which effectively hit the boundary and at the Ylabel the time which the geometric brownian motion S hits the optimal stopping boundary.
Can someone kindly help me with solving this problem using matlab? I just need to see how this can be done in Matlab...
Here is my code to my problem:
%Simulate N trajectories of a geometric Brownian motion in [t0,t0+T].
%Case1: Feed-in tariffs.
%INPUT:
% nb_traj : Number of trajectories
% num_dt : Number of time steps
% t0 : initial time
% S1Begin : initial value
% T : Length of the simulation interval [t0,t0+T]
% drift , sigma : parameters of the process
% the constant parameters a,b,A,B.
%OUTPUT:
%t : Times at which the trajectory is monitored
%S : Simulation of nb_traj trajectories of geometric Brownian motion
clear all
r = 0.05; % risk free rate
T = 10; %time to maturity
sigma = 0.6270; %0.2; %Volatility of steel
drift = 0.0250; %0.04; %Drift, risk-neural of steel
nb_traj = 100; %Number of trajectories
num_dt = 2500; %Number of time steps
dt = T/num_dt; %Time steps
b = 0.12; %0.12; %Constant parameter, b < alpha/(alpha -1)
a = 5; %0.3Constant parameter
A = 0.9; %1.5; %Constant parameter
B = 1.2; %2; %Constant parameter
F = 50; %Constant feed-in tariff
rho = 1/r; %The rate at which the price of a derivative changes relative to a change in the risk-free rate of interest
S1Begin = 500; %300; %Initial price of steel, S1Begin < S1Optimal
alpha = 0.5-drift/(sigma^2)-sqrt((0.5-drift/(sigma^2))^2+2*r/(sigma^2)); %alpha nel caso feed-in tariffs
S1Optimal = (((1-alpha)*(1-b)-1)*B/((1-alpha)*b*A))^(1-b)*a*b*rho*F/B; %the trigger for undertaking the investment
[S, t] = geom_brownian( sigma, T, S1Begin, drift, dt, nb_traj);
%Calcolo del optiotion value: beta = (A/((1-alpha)*(1-b)-1))*S1Optimal^(1-alpha); optionValue = beta*S1Begin^alpha;
%The optimal capacity to install optimalCapacity = a*b*rho*F/(B*S1Begin)^1/(1-b);
% Upon investment, the value of installing this capacity is: projectValue = ((1-b)/b* (optimalCapacity*B*S1Begin)) - A*S1Begin;
steps = T/dt + 1; tInf = zeros(1,nb_traj); %for j = 1:nb_traj; % tInf(j) = T; %end numtau=0; for tr = 1:nb_traj; for i = 1:steps; % if ((S(i,tr) <= S1Optimal) && t(i) < (tInf(tr))) if ((S(i,tr) <= S1Optimal)) tInf(tr) = t(i); numtau=numtau+1; break end end end
sumTimes = 0; for k = 1:nb_traj; sumTimes = sumTimes + tInf(k); end timeToInvest = sumTimes/numtau;
%Plot the graph figure('Color',[0.9412 0.9412 0.9412 ]); plot(t,S, 'linewidth',2); axis([t(1) t(end) min(S(:)) max(S(:))]); xlabel('time');ylabel('value S'); title(sprintf('%d trajectories', size(S,2)));
I am looking forward to your respond.
Thanks
Answers (0)
Categories
Find more on Price and Analyze Financial Instruments in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!