Anteprima
Vedrai una selezione di 11 pagine su 50
Appunti di financial and actuarial sciences Pag. 1 Appunti di financial and actuarial sciences Pag. 2
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 6
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 11
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 16
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 21
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 26
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 31
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 36
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 41
Anteprima di 11 pagg. su 50.
Scarica il documento per vederlo tutto.
Appunti di financial and actuarial sciences Pag. 46
1 su 50
D/illustrazione/soddisfatti o rimborsati
Disdici quando
vuoi
Acquista con carta
o PayPal
Scarica i documenti
tutte le volte che vuoi
Estratto del documento

Text Formatting with HTML Tags

X→ I obtain the same results but horizontal100 400 900 1600

X=MyVector.*MyVerticalArray

X→ I obtain an Array 4x4 that is a multiplication point by point

whos it says me the size, bytes and class of each variable

ones(n,m) returns a matrix of ones with n rows and m columns

zeros(n,m) returns a matrix of zeros with n rows and m columns

length counts element in an array, for vectors, the length is simply the number of elements

repmat(object,n,m) repeat copies of array

tril to obtain the lower triangular matrix

eye to obtain a diagonal matrix

inv to invert the matrix

for loop to repeat specified number of times

for:end cycle for loop to repeat specified number of times

bar allows to plot a histogram of the data

plot allows to represent a bi-dimensional graph of two variables on a cartesian plane

line plots a line in the current axes using the data in vectors x and y; if either x or y, or both, are matrices then line draws multiple lines

Can to be used + title(‘’) + grid on +

MyBoolean = x>y give us 1 for each true result and 0 for each false result 31 Bullet bond with fixed rate Let's define the variables: ->Notional value it's a scalar f_notional = 100 ->Interest rate it's a scalar f_rate = 3/100 ->Time to maturity it's a scalar (expressed in years) n_years = 7 ->ones(n_years,1) to create a column with 1 that has several rows how much the years are. ->zeros(n_years,1) to create a column with 0 that has several rows how much the years are. INTEREST FLOWS mx_interestFlows = ones(n_years,1)*f_rate*f_notional CAPITAL FLOW mx_capitalFlows = zeros(n_years,1)->mx_capitalFlows(7) = f_notional the last row has the value of the notional BOND FLOWS mx_bondFlows = mx_interestFlows + mx_capitalFlows YEARS n_year1 = 2021 mx_years = n_year1 -1 + (1:n_years) PLOT THE BOND bar(mx_years, mx_bondFlows) Exercise- Modify the code to handle an

extraordinary coupon

Let's plot in a bar chart the interest flows and bond flow

mx_interestFlows(4) = 6

mx_bondFlows = mx_interestFlows + mx_capitalFlows

bar(mx_years, mx_bondFlows)

for:endfor index=1:2:5

disp(index)

disp(index*3)

disp(['Multiplied' num2str(index) 'by 3 gives us' num2str(index*3)])

endrepeat from 1 to 5 each 2 numbers and repeat from 1 to 5 each 2 multiplying for 3 and put the description

for ii=1:3

for aa=1:5

disp(aa)

end

end

repeat from 1 to 5 three times 3233

Discount Factor

Discount Factor = fattore di sconto

Value = Flows * Discount Factors

Value / Flows = Discount Factors→irs interest rate swap→. make the product point by point→

to transpose (= rows become columns, viceversa)

mx_irs = [-0.50 -0.49 -0.46 -0.41 -0.35 -0.28 -0.22 -0.15 -0.08 -0.02]'./100;

n_quotes = length(mx_irs)

mx_ttm = (1:n_quotes)'→ time to maturity

tmp = repmat(mx_irs,1,n_quotes)→repmat(1,3,2) repeat 1 for tree rows and two columns.→tmp first

row represents first financial instrument, second row represents second financial instrument and so on; each column represents a period and we have to correct the rate for the periods.

for tt=1:10
    tmp3(tt,tt+1:end) = 0
end
disp(tmp3)

The result will be a LOW TRIANGULAR MATRIX.

mx_interestflows = tril(tmp)

eye(3) i.e. is a DIAGONAL MATRIX with 3 diagonal one and all the other values are zero.

mx_totalflows = mx_interestflows + eye(n_quotes)
mx_totalflows = tril(mr_irs...

inv () inv(x) = 1/x

mx_discountfactors = inv(mx_totalflows)*ones(n_quotes,1)

Another exercise

mx_irs = [-0.50 -0.49 -0.46 -0.41 -0.35 -0.28 -0.22 -0.15 -0.08 -0.02]'./100;
n_quotes = length(mx_irs)
mx_ttm = (1:n_quotes)'
tmp = repmat(mx_irs,1,n_quotes)
mx_interestflows = tril(tmp)
mx_totalflows = mx_interestflows + eye(n_quotes)
mx_discountfactors = inv(mx_totalflows)*ones(n_quotes,1)
plot(mx_ttm,

mx_discountfactors)MARKET SHIFT
If we want to add some values to irs we have to do:
mx_irs1 = mx_irs + 0.01
orf_marketShift = 0.01
mx_irs = [-0.50 -0.49 -0.46 -0.41 -0.35 -0.28 -0.22 -0.15 -0.08 -0.02]

'./100 +f_marketShift 34

FUNCTIONS
% mx_interestFlows = ones(n_years,1)*f_notional*f_rate;
mx_interestFlows = interestFlowsFunction(f_notional,f_rate,n_years);
% mx_capitalFlows = zeros(n_years,1);
% mx_capitalFlows(7) = f_notional;
mx_capitalFlows = capitalFlowsFunction(n_years,f_notional);
% mx_bondFlows = mx_interestFlows+mx_capitalFlows;
mx_bondFlows = totalFlowsFunction(n_years,f_notional,f_rate);

function mx_capitalFlows = capitalFlowsFunction(n_years,f_notional)
    mx_capitalFlows = zeros(n_years,1);
    mx_capitalFlows(end) = f_notional;
end

function mx_interestFlows = interestFlowsFunction(f_notional,f_rate,n_years)
    mx_interestFlows = ones(n_years,1);
    mx_interestFlows = mx_interestFlows*f_notional*f_rate;
end

function mx_totalFlows = totalFlowsFunction(n_years,f_notional,f_rate)
    mx_totalFlows

=capitalFlowsFunction(n_years,f_notional)+interestFlowsFunction(f_notional,f_rate,n_years);endfunction
mx_totalFlows = totalFlowsFunction(n_years,f_notional,f_rate)
mx_totalFlows =capitalFlowsFunction(n_years,f_notional)+interestFlowsFunction(f_notional,f_rate,n_years);end
3536Exercise for 17/03/2021
In the folder Lecture_Exercises\For_20210317, create a folder Surname_Name
Save all the files in the folder
Write Name, Surname, Student Number at the beginning of each file
1) Write a function to calculate interest rate flows
2) Write a function to calculate capital flows
3) Write a function to calculate extra coupons
4) Write a function to calculate total flows
5) Write a function to calculate discount factors
6) Write a function to calculate the value of a bond
7) Download the IRS from year 1 to year 10 from Sole 24 website
8) With the discount factors based on 7., compute the value of the following
bond:
Notional = 10000
Fixed Rate = 0.03
Maturity = 8 years
Extra coupon of 110 in year 5
9) Plot the
  1. Plot a bar chart with the bond flows
  2. function mx_interestFlows = interestFlowsFunction(f_notional,f_rate,n_years)
    mx_interestFlows = ones(n_years,1);
    mx_interestFlows = mx_interestFlows*f_notional*f_rate;
    end
  3. function mx_capitalFlows = capitalFlowsFunction(n_years,f_notional)
    mx_capitalFlows = zeros(n_years,1);
    mx_capitalFlows(end) = f_notional;
  4. f_extracoupon=10
    function mx_extracoupon = extracouponFunction(f_extracoupon,n_year1,n_years)
    mx_extracoupon = zeros(n_years,1);
    mx_extracoupon(n_year1) = f_extracoupon;
    mx_bondFlows = mx_interestFlows + mx_capitalFlows + mx_extracoupon
  5. function mx_totalFlows =totalFlowsFunction(n_years,f_notional,f_rate)+extracouponFunction(f_extracoupon,n_year1,n_years)
    mx_totalFlows =capitalFlowsFunction(n_years,f_notional)+interestFlowsFunction(f_notional,f_rate,n_years)+extracouponFunction(f_extracoupon,n_year1,n_years);
    end
  6. function mx_totalflows= totalflowsFunction2(mx_capitalFlows,
mx_interestFlows,mx_extracoupon)mx_totalflows=mx_capitalFlows + mx_interestFlows + mx_extracoupon;end5)function mx_discountfactors=discountfactorsFunction(mx_totalflows)n_quotes = length(mx_totalflows);mx_discountfactors= (1/mx_totalflows)*ones(n_quotes,1); 376)mx_irs = [-0.50 -0.48 -0.43 -0.38 -0.31 -0.24 -0.15 -0.09 -0.01 -0.05]'./100 38

Geometric Brownian Motion

Describes the random behavior of the asset price level S(t) over time. The GBM is specified as follows:

σS(t)dW(t)dS(t) = µS(t)dt + (Stochastic differential equation, SDE)

µtE(S ) = S et 0 σ2t –02 2µtVar(S ) = S e (e 1)t

Here W is a standard Brownian motion, a special diffusion process that is characterized by independent identically distributed (iid) increments that are normally distributed with zero mean and a standard deviation equals the square root of the time step.

µ represents the deterministic component

dt is the part of time that we are considering

The d terms indicate that

The equation is given in its continuous time version. The property of iid increments is very important and will be exploited in the calibration as well as in the simulation of the random behavior of asset prices.

Let's define the variables:

  1. Number of Simulation. It's scalar. How many paths we want to simulate.
  2. Time Horizon. It's scalar. Which is the time horizon of the analysis in terms of years.
  3. Dt. It's scalar. Which is the time step we want to use in terms of years.
  4. Mu. It's a scalar. The drift of the process. It represents the trend.
  5. Sigma. It's a scalar. The volatility of the process.
  6. Quote. It's scalar. The starting price of the stock.

n_simulation = 1000;

n_T = 10;

f_dt = 1;

f_mu = 0;

f_sigma = 10/100;

f_quote = 50;

SIMULATION OF THE PRICE PATHS

Let us use the function provided by Brigo D. et al (2007) A Stochastic Processes Toolkit for

Risk Management

Risk Management

A Stochastic Processes Toolkit for Risk Management

Damiano Brigo, Antonio Dalessandro, Matthias Neugebauer, Fares Triki

15 November 2007

Function: GBM_simulation

function S = GBM_simulation(n_simulation, T, dt, mu, sigma, S0)
    mean = (mu - 0.5 * sigma^2) * dt;
    S = S0 * ones(n_simulation, T + 1);
    BM = sigma * sqrt(dt) * normrnd(0, 1, n_simulation, T);
    S(:, 2:end) = S0 * exp(cumsum(mean + BM, 2));
end

S = GBM_simulation(n_simulation, n_T, f_dt, f_mu, f_sigma, f_quote);

Analyze the results

Which is the average and the volatility of the prices in the last period?

disp(mean(S(:, end)))
disp(std(S(:, end)))
disp(std(log(S(:, end))))

PLOT: Chart of the paths

Let us see the paths in a chart

figure;
plot(S')
title('Paths')
xlabel('Years')
ylabel('Price')
grid on

We see that there is a bigger volatility for the higher prices. It's not symmetric.

PLOT: Chart of the prices expectations

Let us see the average prices in each period

figure;
plot(mean(S));
title('Prices average');
'Years' '€' Let us see the volatility of the prices in each period
Dettagli
Publisher
A.A. 2020-2021
50 pagine
1 download
SSD Scienze economiche e statistiche SECS-P/09 Finanza aziendale

I contenuti di questa pagina costituiscono rielaborazioni personali del Publisher HelpEconomia di informazioni apprese con la frequenza delle lezioni di financial and actuarial sciences e studio autonomo di eventuali libri di riferimento in preparazione dell'esame finale o della tesi. Non devono intendersi come materiale ufficiale dell'università Università degli Studi Roma Tre o del prof Alessandra Carleo.