Econometric, Option Valuation
Econometric, Option Valuation
Name
Institution
Date
Course
Mat lab code for Monte Carlo
%%%%%%%%%% Option parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S = 55; % Value of the underlying
K = 50; % Strike (exercise price)
r = 0.05; % Risk free interest rate
sigma = 0.25; % Volatility
T = 3; % Time to expiry
%%%%%%%%%% Monte-Carlo Method Parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
randn(state,0) % Repeatable trials on/off
M=1e7; % Number of Monte-Carlo trials
%%%%%%%%%% Use final values to compute
final_vals=S*exp((r-0.5*sigma^2)*T + sigma*sqrt(T)*randn(M,1));
option_values=max(K-final_vals,0); % Evaluate the Put option options
present_vals=exp(-r*T)*option_values; % Discount under r-n assumption
int=1.96*std(present_vals)/sqrt(M); % Compute confidence intervals
put_value=mean(present_vals); % Take the average
display(put_value)
display([put_value-int put_value+int])
Matlab code for data generating FTSE 100
A s c r i p t to produce the p l o t s f o r the p r i c e s and GARCH( 1 , 1 ) o f %
% the FTSE100 , S&P500 , and NIKKEI225 i n d i c e s . %
% %
%????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????%
% INPUTS: %
% % % This s c r i p t r e q u i r e s the Datastream Toolbox %
% %
% OUTPUTS: %
% % % Figure 1 ???? The thr e e i n d i c e s d a i l y adjus t ed c l o s i n g %
% pr i c e s f r om 1990 to today ( July 2012) % % Figure 2 ???? The d a i l y c ont inous l y compounded r e turns %
% o f a l l i n d i c e s from 1990 to today ( July 2012) ,% % ove r layed by the GARCH( 1 , 1 ) c o n d i t i o n a l %
% s tandard de v i a t i on . % % %
%????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????% % %
%????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????% % Chr i s t o s De l i v o r i a s ???? OR MSc Student %
% The Uni v e r s i t y o f Edinburgh % % August 2012 %
%????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????%
% Clear e x i s t i n g data and f i g u r e s c l f ;
c l e a r a l l ;
c l o s e a l l ;
format sho r t ;
% Connect to Yahoo Finance and f e t c h data
Connect = yahoo ;
dataFTSE=f e t c h (Connect , ^FTSE , Jan 1 1990 , today , d ) ;
dataN225=f e t c h (Connect , ^N225 , Jan 1 1990 , today , d ) ;
dataGSPC=f e t c h (Connect , ^GSPC , Jan 1 1990 , today , d ) ;
c l o s e (Connect ) ;
% Ca l cul a t e d a i l y r e turns and GARCH SD f o r each index
dataFTSEret = [ 0 . 0 p r i c e 2 r e t (dataFTSE ( : , end ) ) ] ;
retFTSE=f i n t s (dataFTSE ( : , 1 ) , dataFTSEret , retFTSE100 , d , . . .
retFTSE100 ) ;
[ c o e f f 1 , e r r o r s 1 , LLF1 , innovat ions1 , sigmas1 ] = . . .
g a r c h f i t ( dataFTSEret ) ;
sigmaFTSE = f i n t s (dataFTSE ( : , 1 ) , sigmas1 , retFTSE100 , . . .
d , retFTSE100 ) ;
dataN225ret = [ 0 . 0 p r i c e 2 r e t ( dataN225 ( : , end ) ) ] ;
retN225=f i n t s
( dataN225 ( : , 1 ) , dataN225ret , retNIKKEI , d , . . .
retNIKKEI ) ;
[ c o e f f 2 , e r r o r s 2 , LLF2 , innovat ions2 , sigmas2 ] = . . .
g a r c h f i t ( dataN225ret ) ;
sigmaN225 = f i n t s ( dataN225 ( : , 1 ) , sigmas2 , retNIKKEI , . . .
v
d , retNIKKEI ) ;
dataGSPCret = [ 0 . 0 p r i c e 2 r e t (dataGSPC ( : , end ) ) ] ;
retGSPC=f i n t s (dataGSPC( : , 1 ) , dataGSPCret , retSP500 , d , . . .
retSP500 ) ;
[ c o e f f 3 , e r r o r s 3 , LLF3 , innovat ions3 , sigmas3 ] = . . .
g a r c h f i t ( dataGSPCret ) ;
sigmaGSPC = f i n t s (dataGSPC( : , 1 ) , sigmas3 , retSP500 , . . .
d , retSP500 ) ;
% Create a f i n a n c i a l ins t rument f o r each index with d a i l y p r i c e s
tsFTSE=f i n t s (dataFTSE ( : , 1 ) ,dataFTSE ( : , end ) , . . .
FTSE100 , d , FTSE100 ) ;
tsN225=f i n t s ( dataN225 ( : , 1 ) , dataN225 ( : , end ) , . . .
NiKKEI225 , d , NiKKEI225 ) ;
tsGSPC=f i n t s (dataGSPC( : , 1 ) ,dataGSPC ( : , end ) , . . .
SP500 , d , SP500 ) ;
% Pl o t s the index p r i c e s
f i g u r e ( 1 ) ;
subplot 31 1;
pl o t ( tsFTSE) ;
x l a b e l ( Time ( date ) ) ;
y l a b e l ( Adjusted Close p r i c e ( $ ) ) ;
subplot 31 2;
pl o t ( tsGSPC) ;
x l a b e l ( Time ( date ) ) ;
y l a b e l ( Adjusted Close p r i c e ( $ ) ) ;
subplot 31 3;
pl o t ( tsN225 ) ;
x l a b e l ( Time ( date ) ) ;
y l a b e l ( Adjusted Close p r i c e ( $ ) ) ;
yt = ge t ( gca , YTick ) ;
s e t ( gca , YTickLabel , s p r i n t f ( %.0 f | , yt ) ) ;
% Plot the r e turns and GARCH
f i g u r e ( 2 ) ;
subplot 31 1; hold on ;
pl o t ( retFTSE) ; pl o t ( sigmaFTSE) ; hold o f f ;
subplot 31 2; hold on ;
pl o t ( retN225 ) ; pl o t ( sigmaN225 ) ; hold o f f ;
subplot 31 3; hold on ;
pl o t ( retGSPC) ; pl o t ( sigmaGSPC) ; hold o f f ;
Matlab code for FTSE 100
setdbprefs(DataReturnFormat, structure)
connection = database(SDE_Data, , );
cursor = exec(connection, SELECT ALL Dates,Canada,France,Germany,Japan,UK,US,
Euribor3M FROM Simulation_Data ORDER BY Dates ASC);
cursor = fetch(cursor);
close(cursor), close(connection)
SDE_Data = cursor.Data
SDE_Data =
Dates: [1359×1 double]
Canada: [1359×1 double]
France: [1359×1 double]
Germany: [1359×1 double]
Japan: [1359×1 double]
UK: [1359×1 double]
US: [1359×1 double]
Euribor3M: [1359×1 double]
fields = fieldnames(SDE_Data);
dates = SDE_Data.Dates;
countries = fields(2:end-1);
yields = SDE_Data.Euribor3M; % daily effective yields
yields = 360 * log(1 + yields); % continuous, annualized yields
for i = length(countries):-1:1
prices(:,i) = SDE_Data.(countries{i}); % daily closing prices
end
figure, plot(dates, ret2price(price2ret(prices))), datetick(x)
xlabel(Date), ylabel(Index Value), title (Normalized Daily Index Closings)
legend(countries, Location, NorthWest)
figure, plot(dates, 100 * yields)
datetick(x), xlabel(Date), ylabel(Annualized Yield (%))
title(Risk Free Rate (3-Month Euribor Continuously-Compounded))
Matlab code for estimating e-views
n = 200; k = 3; evec = randn(n,1);
xmat = [ones(n,1) randn(n,k)]; y = zeros(n,1); u = zeros(n,1);
beta = ones(k,1); beta(1,1) = 10.0; % constant term
for i=2:n; % generate a model with 1st order serial correlation
u(i,1) = 0.4*u(i-1,1) + evec(i,1);
y(i,1) = xmat(i,:)*beta + u(i,1);
end;
% truncate 1st 100 observations for startup
yt = y(101:n,1); xt = xmat(101:n,:);
n = n-100; % reset n to reflect truncation
Vnames = strvcat(y,cterm,x2?,x3?);
result = ols(yt,xt); prt(result,Vnames); plt(result);
Share this:
FacebookX