Computational Methods for Finance

Computational Methods for Finance

Computational Methods for (Quantitative) Finance

This University course focused on numerical solutions for some Quantitative Finance problems.

Notably, it included:

  • Tree methods for the pricing of European contingent claims and empirical check of the convergence of the results to the Black and Scholes formula in the case of put and call options. Computation of the delta. Application of the methods in the case of American contingent claims
  • Finite differences methods (implicit, explicit, Crank-Nicholson) for the pricing of European and American contingent claims. Stability and convergence
  • Monte Carlo methods: Euler scheme for the simulation of trajectories of stochastic processes. Use of Monte Carlo methods for derivative pricing

it also involved:

  • Monte Carlo integration
  • Pseudorandom number generator (Linear congruential generator)
  • Generation of random numbers from any kinds of distribution, continuous or discrete, given its Pdf or Cdf, and an uniform random number generator (inverse Cdf method)

Examples from my final exam:

Three correlated Geometric Brownian Motions:

 

 

 

 

 

 

 

 

 

 

 

 

European Call Option, Crank-Nicholson method:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
% CALLER SCRIPT

s0 = 120;
k = 150;
t = 1;
sig = 0.3;
r = 0.02;

prezzi = (80:2:130);
mat = (0.1:0.05:1);

[X, Y] = meshgrid(prezzi, mat);
Z = zeros(size(X));
for i=1:length(prezzi)
for j=1:length(mat)
pr = es2(prezzi(i), k, mat(j),sig,r);
Z(j,i) = pr;
end
end

mesh(X, Y, Z);

% FUNCTION

function pr = es2(s0, k, t,sig,r)
%ES2 Summary of this function goes here
% Detailed explanation goes here

% s0 = 120;
% k = 150;
% t = 1;
% sig = 0.3;
% r = 0.02;

n = 252;
dt = t/n;

xMax = log(3);
dx = sig*sqrt(3*dt);
m = ceil(xMax/dx);

payoff = max(0,s0*exp((-m:m)'*dx)-k);
D = zeros(2*m+1, n+1);
D(:,end) = payoff;
fs = 1/(1+r*dt);
nu = r-0.5*sig^2;
a = (dt/4)*(-nu/dx+sig^2/dx^2);
b = -0.5*dt*(r+(sig^2)/dx^2);
c = (dt/4)*(nu/dx+sig^2/dx^2);

A =-a*diag(ones(2*m,1),-1)+(1-b)*diag(ones(2*m+1,1))-c*diag(ones(2*m,1),1);
A(1,1:2) = [1 0];
A(end, end-2:end) = [1 -2 1];

B =a*diag(ones(2*m,1),-1)+(1+b)*diag(ones(2*m+1,1))+c*diag(ones(2*m,1),1);
B(1,1:2) = [fs 0];
B(end, end-2:end) = [0 0 0];

for i=n:-1:1
d = B*D(:,i+1);
D(:,i) = A\d;
end
pr = D(m+1,1);

Comments are closed, but trackbacks and pingbacks are open.