AllBestEssays.com - All Best Essays, Term Papers and Book Report
Search

Financial Simulation Hw

Essay by   •  April 17, 2017  •  Coursework  •  570 Words (3 Pages)  •  929 Views

Essay Preview: Financial Simulation Hw

Report this essay
Page 1 of 3

Mike Pena

Prof. Aparna Gupta

Financial Simulation

HW09

1 Implied Volatility

Note: Implied Vol Decreases as option becomes ITM

[pic 1]

[pic 2]

2 CEV

[pic 3]


2 Protective Put

[pic 4]

[pic 5]

OUTPUT

Q2. Protective Put

Initial Cost:230.4262

Payoff per Share: mean (4.7916), sd (6.4967)

Profit per Share: mean (1.0354), sd (6.4967)

2 Stop Loss

OUTPUT

Q2. Stop-Loss

Cost of Strategy:1.3356


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\HW09';

% 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\HW09';

% Quandl authentication token

Quandl.api_key('xokQnzdREAWG5absGuY3');

 

%% Question 1. Implied Volatility

% Obtain Data:

stock{1}='GOOG/NYSE_GS';

n=length(stock);

for i=1:n

    data{i}=Quandl.get(stock{i},'collapse','monthly', ...

        '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(:));

% Obtain Data:

stock{1}='GOOG/NYSE_JPM';

n=length(stock);

for i=1:n

    data{i}=Quandl.get(stock{i},'collapse','monthly', ...

        '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(:));

% Set the variable inputs:

% Goldman Sachs Calls

S0=226.67;%4/13/2017 @ 11:48AM

K_GS=[70,75,80,180,185,190,270,280,290];

r=.02;

T=9.2/12; %4/13/2017 - 1/19/2018

vol=Std_GS;

P=[178.82,172.14,168.9,51.9,50.55,45.1,4.63,3.15,2.2];

[m,n]=size(P);

Implied_Vol_GS=zeros(m,n);

% Option Implied Volatility:

% Set the variable inputs:

a=0;

b=10;

x0=2;

tol=1e-5;

for i=1:n

    target=P(i);

    K=K_GS(i);

    c=@(vol) S0*normcdf((log(S0/K)+(r+(vol^2)/2)*T)/(vol*sqrt(T)))-K*exp(-r*T)*normcdf((log(S0/K)+(r+(vol^2)/2)*T)/(vol*sqrt(T))-(vol*sqrt(T)));

    dc=@(vol) (S0*exp(-(log(S0/K) + T*(vol^2/2 + r))^2/(2*T*vol^2))*((2^(1/2)*T^(1/2))/2 - (2^(1/2)*(log(S0/K) + T*(vol^2/2 + r)))/(2*T^(1/2)*vol^2)))/pi^(1/2) + (2^(1/2)*K*exp(-T*r)*exp(-(T^(1/2)*vol - (log(S0/K) + T*(vol^2/2 + r))/(T^(1/2)*vol))^2/2)*(log(S0/K) + T*(vol^2/2 + r)))/(2*T^(1/2)*vol^2*pi^(1/2));

    p =@(vol) -S0*normcdf(-((log(S0/K)+(r+(vol^2)/2)*T)/(vol*sqrt(T))))+K*exp(-r*T)*normcdf(-((log(S0/K)+(r+(vol^2)/2)*T)/(vol*sqrt(T))-(vol*sqrt(T))));

    dp=@(vol) (S0*exp(-(log(S0/K) + T*(vol^2/2 + r))^2/(2*T*vol^2))*((2^(1/2)*T^(1/2))/2 - (2^(1/2)*(log(S0/K) + T*(vol^2/2 + r)))/(2*T^(1/2)*vol^2)))/pi^(1/2) + (2^(1/2)*K*exp(-T*r)*exp(-(T^(1/2)*vol - (log(S0/K) + T*(vol^2/2 + r))/(T^(1/2)*vol))^2/2)*(log(S0/K) + T*(vol^2/2 + r)))/(2*T^(1/2)*vol^2*pi^(1/2));

    % Compute implied Vol for call options:

    [ vol0, iter0 ] = myBisection( c, a, b, tol, target );

    Implied_Vol_GS(i)=vol0;

end

figure

plot(K_GS,Implied_Vol_GS);

title('Q1. Implied Volatility (GS)');

xlabel('K') % x-axis label

ylabel('Implied Vol') % y-axis label

% JP Morgan Calls

S0=85.75;%4/13/2017 @ 11:48AM

K_JPM=[40,45,57.4,60,75,80,85];

r=.02;

T=2.1/12; %4/13/2017 - 6/16/2017

vol=Std_JPM;

P=[47.28,41.99,30.15,27.35,11.91,7.48,3.48];

[m,n]=size(P);

Implied_Vol_JPM=zeros(m,n);

% Option Implied Volatility:

% Set the variable inputs:

a=0;

b=10;

x0=2;

tol=1e-5;

...

...

Download as:   txt (7.1 Kb)   pdf (179.8 Kb)   docx (55.6 Kb)  
Continue for 2 more pages »
Only available on AllBestEssays.com