Financial Simulation
Essay by juan • April 17, 2017 • Coursework • 481 Words (2 Pages) • 921 Views
Mike Pena
Prof. Aparna Gupta
Financial Simulation
HW10
1 Exchange Option
Note: 99% CI taken into account in Width.
OUTPUT
Q1. Exchange Option
Price: 15.3804, Width: 0.1421
[pic 1]
2 Compound Option
Note: 99% CI taken into account in Width.
OUTPUT
Q2. Compound Option
Price: 1.2389, Width: 0.0105
3 Control Variates
Note: 99% CI taken into account in Width. Additionally, there is a significant improvement in the tightness of the confidence interval for both options after control variates were implemented. Strong positive correlation is visible in the scatter plot replications of discounted exchange option pay-off against repliations of European Call pay-off at option maturity. This correlation was utilized in the design of the control variate method. Method used 12.9 from Risk Management and Simulation (Gupta) as we know the theoretical mean of the control variate.
Q3. Control Variates
Exchange Option: Price (15.3804), Width (0.0334)
Compound Option: Price (1.2389), Width (0.0000)
[pic 2]
MATLAB CODE
% First clear the memory and close all open figures:
clear all; close all;
% Clear the screen:
clc;
% Change the working directory: This is the working directory
% where MATLAB looks for files (data inputs, .m files such as
% functions, etc.) and outputs results.
cd 'C:\Users\penam2\Desktop\RPI\Spring 2017\Financial Simulation\Homework\HW10';
% If you want to read files from another folder (maybe you
% have data stored in another location), you can use the addpath
% function:
addpath 'C:\Users\penam2\Desktop\RPI\Spring 2017\Financial Simulation\Homework\HW10';
% Quandl authentication token
Quandl.api_key('xokQnzdREAWG5absGuY3');
%% Question 1. Exchange Option
% Obtain Data:
stock{1}='GOOG/NYSE_GS';
n=length(stock);
for i=1:n
data{i}=Quandl.get(stock{i},'collapse','daily', ...
'start_date','2014-1-1','end_date','2017-1-1','type','data');
end
% Extract prices and compute returns:
prices_Dates=data{1}(:,1);
prices_GS=data{1}(:,5);
returns_Dates=data{1}(1:end-1,1);
returns_GS=log(prices_GS(1:end-1,:)./prices_GS(2:end,:));
% Compute Statistics:
P0_GS=prices_GS(1);
Mean_GS=mean(returns_GS(:));
Std_GS=std(returns_GS(:));
% Annualize Statistics:
Mean_GS=mean(returns_GS(:))*250;
Std_GS=std(returns_GS(:))*sqrt(250);
% Obtain Data:
stock{1}='GOOG/NYSE_JPM';
n=length(stock);
for i=1:n
data{i}=Quandl.get(stock{i},'collapse','daily', ...
'start_date','2014-1-1','end_date','2017-1-1','type','data');
end
% Extract prices and compute returns:
prices_Dates=data{1}(:,1);
prices_JPM=data{1}(:,5);
returns_Dates=data{1}(1:end-1,1);
returns_JPM=log(prices_JPM(1:end-1,:)./prices_JPM(2:end,:));
% Compute Statistics:
P0_JPM=prices_JPM(1);
Mean_JPM=mean(returns_JPM(:));
Std_JPM=std(returns_JPM(:));
% Annualize Statistics:
Mean_JPM=mean(returns_JPM(:))*250;
Std_JPM=std(returns_JPM(:))*sqrt(250);
% Compute Correlation:
rho=corr(returns_GS,returns_JPM);
% Set variable inputs:
T=1;step=500;dt=T/step;
N=1e3;alpha=0.5;r=0.02;
K_GS=P0_GS;
K_JPM=P0_JPM;
% Joint GBM Simulation:
[spath_GS,spath_JPM]=Joint_GBM(P0_GS,P0_JPM,Mean_GS,Mean_JPM,Std_GS,Std_JPM,rho,T,step,N);
% Compute Exchange Option:
q_GS=0.5;q_JPM=1.2;
payoff_Ex_Option=max(q_GS.*spath_GS(:,end)-q_JPM.*spath_JPM(:,end),0).*exp(-r*T);
[p_Ex_Option,~,ci_Ex_Option,~]=normfit(payoff_Ex_Option,0.01);
width=(ci_Ex_Option(2)-ci_Ex_Option(1))/p_Ex_Option;
fprintf('Q1. Exchange Option \n');
fprintf('Price: %3.4f, Width: %3.4f\n',p_Ex_Option,width);
fprintf('\n');
% Plot Paths:
figure
yyaxis left
plot(0:dt:T,spath_GS(end,:));
hold on
yyaxis right
plot(0:dt:T,spath_JPM(end,:));
title('Q1. Joing GBM Paths');
legend('GS','JPM');
%% Question 2. Compound Option
% Set Variable Inputs:
p1=prices_GS;
S0=p1(1);
T1=0.5;T2=1;
K1=0.5;K2=S0;
nstep=1;dt=(T2-T1)/nstep;
alpha=0.5;
rf=0.0112;
N=1e3;
step=500;
% Calibrate Model:
mu=mean((p1(1:end-1)-p1(2:end))./(p1(2:end).^alpha)./((p1(2:end).^(1-alpha)).*dt));
sigma= (std((p1(1:end-1)-p1(2:end)-mu*dt.*p1(2:end))./(p1(2:end).^alpha)))/(sqrt(dt));
% Simulate Prices:
stockpath_lp=CEVmodel(S0,sigma,mu,T2,step,N,alpha);
...
...