Euler scheme for coinitial swap rates

Discuss code issues here

Euler scheme for coinitial swap rates

Postby stochan » Thu Aug 23, 2012 2:29 pm

Hi all,

reading the paper from Joshi, Yang (2009) I decided to implement the algorithm suggested for the Euler drift freezing scheme. But it won't work when I compare my results with the ones provided in table 3.1.

Here is the Matlab code: it retrieves all the parameters we need to implement the step. I use initial suggested correlation matrix and displacement coefficients.

Code: Select all
function [barA, a, mu]=fun(SR)

% From a state of the vector SR_1,... SR_10 we find the parameters
% barA = discounted annuities, a=pseudo-square root of Cov, mu=drifts
rho=zeros(10);
mu=zeros(1,10);

for i=1:10
    for j=1:10
        rho(i,j)=exp(-0.05*abs(i-j));
    end
end

%IV=csvread('IV.csv');
%alpha=csvread('alpha.csv');

IV=.2; %
alpha=.02*ones(1,10); %displacements all set at 2%
         
sigma=zeros(1,10); %this is sigma^alpha

for i=1:10
    sigma(i)=IV*SR(i)/(SR(i)+alpha(i)); %Rebonato approximation
end

covmat=diag(sigma)*rho*diag(sigma); %this is where  I could be wrong

a=chol(covmat)'; %pseudo square root..

P=zeros(1,10); %bond prices deflated by P0
barA=zeros(1,10);
for i=1:10
    if i==1
        aaa=0;
    else
        aaa=barA(i-1);
    end
    P(i)=(1-SR(i)*aaa)/(1+SR(i)); %formula (2.10)
    barA(i)=aaa+P(i);  %(2.8)
end

cv=zeros(10); %cv(i,j)= cross variation Z_k, A_j

for k=1:10
    for i=1:10
        if i==1
            aaa=0;
        else
            aaa=cv(k,i-1);
        end
        temp=aaa-a(i,k)*(SR(i)+alpha(i))*barA(i); %(2.6)
        cv(k,i)=temp/(1+SR(i));
    end
end


the step itself is done like

Code: Select all
function SR=step(S)
%we implement the formula (2.11)

SR=S;

alpha=0.02*ones(1,10);

[barA,a,mu]=fun(S);

Z=randn(1,10);

for i=1:10
    temp=0;
   
    for k=1:10
        temp=temp+a(i,k)*Z(k)-a(i,k)^2/2;
    end
   
    SR(i)=(S(i)+alpha(i))*exp(mu(i)+temp)-alpha(i);
end
stochan
 
Posts: 4
Joined: Thu Aug 23, 2012 7:44 am

Re: Euler scheme for coinitial swap rates

Postby stochan » Fri Aug 24, 2012 9:46 am

Any clue on why it is not working?
stochan
 
Posts: 4
Joined: Thu Aug 23, 2012 7:44 am

Re: Euler scheme for coinitial swap rates

Postby mj » Mon Aug 27, 2012 11:39 pm

i can't go through code
mj
Site Admin
 
Posts: 1340
Joined: Fri Jul 27, 2007 7:21 am

Re: Euler scheme for coinitial swap rates

Postby coool12 » Thu Nov 29, 2012 4:55 am

If I want to work as a quant, can you please rank New York, London, Singapore and Sydney in terms of:
(1) Buiding attractive experience on the cv.
(2) Salary level.
(3) Future job growth opportunity.
coool
coool12
 
Posts: 1
Joined: Thu Nov 29, 2012 4:50 am

Re: Euler scheme for coinitial swap rates

Postby mj » Thu Nov 29, 2012 7:31 am

ask in the careers forum not on a trhead in the code forum
mj
Site Admin
 
Posts: 1340
Joined: Fri Jul 27, 2007 7:21 am

Re: Euler scheme for coinitial swap rates

Postby Garret2 » Wed Jan 23, 2013 12:18 pm

mj wrote:ask in the careers forum not on a trhead in the code forum

You are right. :D
Garret2
Garret2
 
Posts: 2
Joined: Tue Jan 08, 2013 4:42 am


Return to Code

Who is online

Users browsing this forum: No registered users and 1 guest