Sie sind auf Seite 1von 122

CQF Final Project Topics:

Time Series. Interest Rates

January 2017 Cohort

Certificate in Quantitative Finance 1/123


1 Time Series Analysis and Backtesting

2 Forward LIBOR and Discounting (for IRS CVA Calculation)

3 Interest Rate Volatility and Derivatives

4 Interest Rates - Local Volatility

Certificate in Quantitative Finance 2/123


Time Series Analysis and
Backtesting

Certificate in Quantitative Finance 3/123


Introduction

We will use returns from six broad market indices to demonstrate


how to implement Vector Autoregression.
Japan, Germany, France, UK, US, Canada

You can extend the regression with exogenous variables, such as


rates, commodities, VIX, even derivatives but those have to be
returns data.

Certificate in Quantitative Finance 4/123


Relative Equity Indices

Certificate in Quantitative Finance 5/123


US Daily Index Returns

Certificate in Quantitative Finance 6/123


Linear Model

For these stationary returns, we can set up a system of endogenous


variables that depend only on their past (lagged) values.

y1,t = β1,0 + β11 y1,t−1 + β12 y2,t−1 + ... β1n yn,t−1 + ...t−2 ... + 1,t

y2,t = β2,0 + β21 y1,t−1 + β22 y2,t−1 + ... β2n yn,t−1 + ...t−2 ... + 2,t
... ...
yn,t = βn,0 + βn1 y1,t−1 + βnn y2,t−1 + ... βnn yn,t−1 + ...t−2 ... + n,t

Think about forecasting powers of this model-free set up.

Certificate in Quantitative Finance 7/123


Empirical Forecasting

Empirical observation: the vector autoregression is not good at


predicting daily returns.

S&P 500 FTSE 100 HSE N225


MSE 0.0001 0.0001 0.0001 0.0001
MAPE 1.0175 1.3973 2.5325 1.0111
Table: Forecasting Accuracy: Market Index Returns (next day)

MAPE results suggest a deviation O(100%) to O(200%) per cent.


Granted that daily returns for a broad market index are a very small,
close to negligible, quantity.

Certificate in Quantitative Finance 8/123


Forecasting Accuracy

R command accuracy() returns the common measures of forecasting


accuracy.

ME RMSE MAE MPE MAPE MASE


0.00120 1.0514 0.8059 -Inf Inf 0.79298

The mean error, root mean squared error, mean absolute error, mean
percentage error, mean absolute percentage error, and mean
absolute scaled error.

Certificate in Quantitative Finance 9/123


Forecasting with regression

The useful part of a forecast does not extend beyond 2-3 days.

EVECM [YT +i ] = EVAR [YT +i ] + [∆YT ]

Adding a small correction, if cointegrated relationship exists, only


produces a linear trend ∆YT = constant.

Certificate in Quantitative Finance 10/123


Beyond Econometrics

Econometric studies for stationary data of weekly or monthly


changes are a. forecasting, b. impulse response analysis, and c.
Granger causality analysis.

Correlation studies – see experiments with rank vs. linear


correlation in Credit Topic.

Often, before using Cholesky and decomposition a fix is required


by estimating the nearest correlation matrix.

Covariance matrix issues – collinearity is common and


prevents matrix inversion for portfolio allocation purposes.

Dimension reduction is often required for large covariance matrices as


they are noisy.

Certificate in Quantitative Finance 11/123


Performance Explorations

From: Quant Insights, Oct 2015, Portfolio and Risk Analytics with PyFolio,
Thomas Wiecki (Quantopian)

Certificate in Quantitative Finance 12/123


Vector Autoregression

It is a multivariate regression with past values.


VAR(p) is the simplest way of structural equation modelling.

It models a system of endogenous variables that depend only on their


past (lagged) values.

Yt = C + A1 Yt−1 + · · · + At−p Yt−p + t (1)

0
Yt = (y1,t , · · · , yn,t ) is a column vector Nvar × 1.
Ap is a n × n matrix of coefficients for lagged variables Yt−1 ... Yt−p
 p p

a11 · · · a1n
 . .. .. 
Ap = 
 .
. . 
. 
p p
an1 · · · ann

Certificate in Quantitative Finance 13/123


Vector Autoregression: Estimation

Although VAR(p) can be exceedingly large, it is a system of


seemingly unrelated regressions that can be estimated separately
(line by line) using ordinary least squares (OLS).

Matrix manipulation is available in many packages (Matlab, R,


Python) allowing to specify a concise form and estimate all lines of
Vector Autoregression in one go.

Certificate in Quantitative Finance 14/123


Dependent Matrix

First, we need to form the matrices as follows, with T = Nobs :

1 Dependent data matrix has observations for the first p lags


removed (here, observations are in rows from time p + 1 to most
recent observation at T )
 
y1,p+1 y1,p+2 · · · y1,T
 
 y2,p+1 y2,p+2 · · · y2,T 
Y = [yp+1 yp+2 · · · yT ] = 
 .. .. .. .. 

 . . . . 
yn,p+1 yn,p+2 · · · yn,T

h i
y1,t=1
   y1,...
  y1,p
 y1,p+1 y1,p+2 · · · y1,t=T

refers to all historic observations of the variable y1 .

Certificate in Quantitative Finance 15/123


3 Explanatory data matrix (assume p=3)
 
1 1 ··· 1
 
 y1,p y1,p+1 ··· y1,T −1 
 
 y2,p y2,p+1 ··· y2,T −1 
 
 .. .. .. .. 
 . . . . 
 
 
 yn=Nvar ,p yn,p+1 ··· yn,T −1 
   
1 1 ··· 1  
 
 y yp+1 ··· 
yT −1   ··· y1,T −2 
 p  y1,p−1 y1,p 
   
Z =y
 p−1
yp ··· yT −2  =  y2,p−1
 
y2,p ··· y2,T −2 

 .. .. .. ..   .. .. .. .. 
 . . . .    . . . .  
yn,1 yn,2 ··· yn,T −p y yn,p ··· yn,T −2 
 n=Nvar ,p−1 
 
 
 
 y1,1 y1,2 ··· y1,T −p 
 
 
 y2,1 y2,2 ··· y2,T −p 
 .. .. .. 
 .. 
 . . . . 
yn=Nvar ,1 yn,2 ··· yn,T −p
Certificate in Quantitative Finance 16/123
Coded in Matlab, the algorithm forms the matrix from the top,

ymat = y(nlag+1:end,:)’; % Forming dependent matrix Y

zmat = [ones(1,nobs-nlag)]; % Forming explanatory matrix Z


for i=1:nlag
zmat = [zmat; y(nlag-i+1:end-i,:)’];
end;

Certificate in Quantitative Finance 17/123


Residuals

4 Disturbance matrix (innovations, residuals)


 
e1,p+1 e1,p+2 ··· e1,T
h i  e2,p+1 e2,p+2 ···

e2,T 
 = p+1 p+2 · · · T =   .. .. .. 
 . ··· . . 
en,p+1 en,p+2 ··· en,T

Each row of residuals is for the observations of variables


y1 , y2 , ... , yn=Nvar respectively. The most recent observation is at
T.

5 Coefficient matrix includes the intercept C


h i
B = C A1 A2 · · · Ap

Certificate in Quantitative Finance 18/123


Calculating VAR(p) Estimates

Given our matrix specifications, VAR(p) system can be written as

Y = BZ + 

Calculate the multivariate OLS estimator for regression


coefficients matrix B as

B̂ = YZ 0 (ZZ 0 )−1

This estimator is consistent and asymptotically efficient.

Back out regression residuals

ˆ = Y − B̂Z

Certificate in Quantitative Finance 19/123


A bit of MLE

Consider the multivariate Normal Likelihood function and its log


T
Y  
2 2 −T /2 1 0
L = N(yt , xt , β, σ ) = (2πσ ) exp − 2 (y − X β) (y − X β)
t

 
T T 1 0
ln L = − ln(2π) − ln(σ 2 ) − (y − X β) (y − X β)
2 2 2σ 2

To maximise the Log-Likelihood by varying β


∂ ln L 1
= (Y − X β)0 X = 0
∂β σ2
β̂ = YX 0 (XX 0 )−1 .

This is how B̂ = YZ 0 (ZZ 0 )−1 result was obtained.

Certificate in Quantitative Finance 20/123


Residuals and Parameters Significance

1 Estimator of the residual covariance matrix with T ≡ Nobs


T
1X 0
Σ̂ = ˆt ˆt
T
t=1

2 Covariance matrix of regression coefficients


 
Cov Vec(B̂) = (ZZ 0 )−1 ⊗ Σ̂ = I −1

Vec denotes vectorization and ⊗ is the Kronecker product.

Standard errors of regression coefficients will be along the


diagonal. Useful to calculate t-statistic.

Certificate in Quantitative Finance 21/123


Example: VAR(1) Estimation

Certificate in Quantitative Finance 22/123


Example: Residual Covariance Matrix

As our market index data was standardised to start at 1, the


covariance matrix is the same as correlation matrix.

Certificate in Quantitative Finance 23/123


Optimal Lag Selection

Optimal Lag p is determined by the lowest values of AIC, BIC


statistics constructed using penalised likelihood.

Akaike Information Criterion


0
b + 2k
AIC = log |Σ|
T
Bayesian Information Criterion (also Schwarz Criterion)
0
b + k log(T )
SC = log |Σ|
T

k 0 = n × (n × p + 1) is the total number of coefficients in VAR(p).

Certificate in Quantitative Finance 24/123


Example: Optimal Lag Selection

Certificate in Quantitative Finance 25/123


Stability Condition

It requires for the eigenvalues of each relationship matrix Ap to be


inside the unit circle (< 1).

Eigenvalue Modulus < 1


-0.22 0.22
-0.17 0.17
-0.01-0.11i 0.11
-0.01+0.11i 0.11
0.04 0.04
-0.01 0.01
This VAR system satisfies stability condition |λI − A| = 0.

If p > 1, coefficient matrix for each lag Ap to be checked separately.

Certificate in Quantitative Finance 26/123


Cointegration Analysis and Estimation

Certificate in Quantitative Finance 27/123


Cointegrated System

0
A linear combination βCoint Yt = et must generate cointegrated
residual (spread) as below et ∼ I(0)

To obtain the spread, allocation is done in βCoint as weights.

There is a cancellation of a common stochastic process in each of yi,t

et = y1,t ± β2 y2,t ± · · · ± βn yn,t


β Coint = [1, ±β2 , ... , ±βn ]

Certificate in Quantitative Finance 28/123


Estimating Cointegration - Pairwise

Pairwise Estimation: select two candidate time series and apply


ADF test for stationarity to the joint residual. Use the estimated
residual to continue with the Engle-Granger procedure.

See CQF Lecture on Cointegration and Cointegration Case B with the


case study in R that re-implements ECM explicitly.

∆yt = φ∆xt − (1 − α)(yt−1 − βCoint xt−1 − µe ).

Certificate in Quantitative Finance 29/123


Engle-Granger Procedure

Step 1. Obtain the fitted residual and test for unit root.

e b t −a
bt = yt − bx b

Cointegrating vector β 0Coint = [1, −b]


b and equilibrium level
E[e a = µe .
bt ] = b

If the residual non-stationary then no long-run relationship exists and


regression is spurious.

Step 2. Plug the residual from Step 1 into the ECM equation and
estimate parameters φ, α
bt−1 .
∆yt = φ∆xt − (1 − α)e

It is required to confirm the significance for (1 − α) coefficient.

Certificate in Quantitative Finance 30/123


Multivariate Equilibrium Correction

For non-stationary variables, such as prices, Yt we specify


equilibrium correction equations

∆Yt = Π Yt−1 + Γ1 ∆Yt−1 + t


∆Yt = αβ 0 Yt−1 + Γ1 ∆Yt−1 + t
∆Yt = α(β 0 Yt−1 + µe ) + Γ1 ∆Yt−1 + t

The last case is a restricted constant (deterministic trend in ∆Yt ).

Beware! Multivariate ECM notation is different from Engle-Granger.

Certificate in Quantitative Finance 31/123


Multivariate Cointegration

To understand multivariate cointegration you need to know:

Principle of reduced rank of a matrix

Johansen trace and max eigenvalue tests

Choice of deterministic trends in Johansen tests

Johansen MLE Procedure estimates Π = αβ 0 and provides


inference about the number of cointegrating relationships r (rank
of cointegration).

Certificate in Quantitative Finance 32/123


Cointegration Rank

The matrix Π must have a reduced rank, otherwise the stationary


∆Yt will be ‘equal’ to non-stationary ΠYt−1 . It’s factorised as

Π = αβ 0

(n × n) = (n × r ) × (r × n)

r columns of β are cointegrating vectors, and n − r columns are


common stochastic trends (unit roots) of the system.

Next, we test for the rank of Π that determines the number of


cointegrating vectors.

Certificate in Quantitative Finance 33/123


Johansen Test for Cointegration Rank

Comparing Trace Statistic to its Critical Value, we reject r = 0 but


can’t reject r ≤ 1. That suggests only one cointegrated relationship.

Certificate in Quantitative Finance 34/123


Cointegrating Vector Estimators β 0Coint

Take the first column and standardise it.


h i
1 0.7178 −2.3231 −0.1802 4.0093 −1.5119 −17.2481

0
The allocations β̂Coint provide a mean-reverting spread.

Certificate in Quantitative Finance 35/123


Planners vs. Hedgers

‘The social planner’ approach, implicit in regression forecasting, is


dangerous with markets – what would you do if the next price step is
not according to a forecast?

If equilibrium condition changes µOld


e → µNewe , cointegrated models
give correction in the precisely opposite direction

∆Yt = µ0,τ + α [β 0 Yt−1 − µe ] + t,τ

Cointegration analysis helps to understand how the common


factor drives many prices. However, decoupling a set of
cointegrated prices into forecasting equations does not work.

Instead, one would devise a trade around the mean-reverting


spread.

Certificate in Quantitative Finance 36/123


Statistical Arbitrage with Cointegration

Certificate in Quantitative Finance 37/123


Statistical Arbitrage

Cointegrated prices generate a mean-reverting spread. It is possible


to enter systematic trades that generate P&L.

1 How to generate P&L? – Design a trade and evaluate


profitability.

2 How to evaluate P&L? – Drawdown control and backtesting.

For systematic trading, you will need specifics:

loadings β C give positions βC0 Pt ,

(optimised) bounds give entry/exit, and

speed of reversion gives idea of profitability over time.

Certificate in Quantitative Finance 38/123


Mean-Reverting Spread

Using a cointegrated relationship among Volatility Futures, we


obtained a mean-reverting spread θ  0.

The bounds are calculated by fitting to the OU process.

Certificate in Quantitative Finance 39/123


P&L from a spread trade

The P&L was achieved by trading around the spread et = βC0 Pt .


Positions were taken as

β1,C P1,t + β2,C P2,t + ... + βn,C Pn,t

Certificate in Quantitative Finance 40/123


Pairs Trading P&L

For the price levels P of two assets, stock S and market index M, we
have a cointegrated residual

et = PtS − βC PtM − µe E[et ] = 0

et is a mean-reverting time series with the mean µe .

The dollar MtM P&L ∆et = et − et−1 does not depend on the level µe

∆et = (PtS − βC PtM − µe ) − (Pt−1


S M
− βC Pt−1 − µe )
= (PtS − Pt−1
S
) − βC (PtM − Pt−1
M
)
= ∆PtS − βC ∆PtM

Certificate in Quantitative Finance 41/123


Pairs Trading P&L as Factor

∆et ∆P S − βC ∆PtM
= St M
= RtC
et−1 Pt−1 − βC Pt−1

The series of returns RtC is a technical presentation of the factor.

Corr[RtC , RtM ]

Experiment: Correlate returns from a strategy with another factor.

For example, returns from a pairs trading P&L vs. market index
returns. What impact does it make to have the strategy returns of
frequency higher than daily (1Min, 10Min)?

Certificate in Quantitative Finance 42/123


P&L vs Drawdowns

Certificate in Quantitative Finance 43/123


To set up an arbitrage trade, one requires the following items of
information:
0
1 Weights βCoint to obtain the spread as

β1,C P1,t + β2,C P2,t + ... + βn,C Pn,t

2 Speed of mean-reversion in the spread θ, which can be


converted into half life (expected position holding time) as

τe ∝ ln 2/θ

3 Entry and exit signals defined by σeq . Optimisation involved.

et crosses µe + σeq

Certificate in Quantitative Finance 44/123


Xt ⇠ N ✓ (✓ x0 ) e , 1 e . (3.2.13)
2

OU Process Figure 3.2 illustrates an example path with X0 = 0.7, ✓ = 0,  = 15 and = 2.

Ornstein−Uhlenbeck Process

1.0
0.5
Value

0.0
−0.5

E[Xt|X0]
−1.0

Xt
95%−Conf.

0 1 2 3 4 5

Time in Years

We consider theFigure 3.2: A typical sample path of an Ornstein-Uhlenbeck-process.


process because it generates mean-reversion.
The possibly simplest way in order to obtain a discretised version of the Ornstein-Uhlenbeck
process is to employ the so-called Euler scheme. In particular, the discrete process
2 dY = −θ(Y − µ ) dt + σ dXt
The proof can be found tin Øksendal (2007) ton page 26.
e (2)

θ is the speed of reversion


µe is equilibrium level
σ is the scatter of diffusion

Certificate in Quantitative Finance 45/123


Evaluating mean-reversion

OU SDE solution for et+τ has mean-reverting and autoregressive


terms


et+τ = 1 − e−θτ µe + e−θτ et + t,τ

Estimate a simple regression as follows:

et = C + Bet−1 + t,τ

ln B
e−θτ = B ⇒ θ=− (3)
τ

 C
1 − e−θτ µe = C ⇒ µe = (4)
1−B

Certificate in Quantitative Finance 46/123


Bounds of reversion

The scatter of the OU process relates to the total variance of


cointegrating residual et (where τ is data frequency)
r

σOU = Var [et,τ ] (5)
1 − e−2θτ

σOU is diffusion over small time scale (volatility coming from small ups
and downs of BM). But, we are interested in reversion from/to µe .

To plot trading bounds we use



σeq ≈ σOU / 2θ.

for potential entry/exit signals µe ± σeq .

Certificate in Quantitative Finance 47/123


Model Risk

There are formal statistical tests and procedures to estimate


cointegraiton (eg, Engle-Granger, Johansen). But, the
presupposition is that you take those tools and uncover some
existential equilibrium.

The reality is that you are constructing and imposing such


relationship as much as you are testing for it.

Take Cointegration Case B among spot rates. We tested for


cointegration between short end and long end, recent data and
data collected over the long-term.

Certificate in Quantitative Finance 48/123


All project designs (whether learning-level or in-depth) should include
backtesting of a strategy. Stat arb strategy is realised by using
cointegrating coefficients β C as allocations w .

That creates a long-short portfolio that generates a mean-reverting


spread (cointegrated residual) et .

The portfolio also explicates a factor.

Certificate in Quantitative Finance 49/123


Backtesting

Certificate in Quantitative Finance 50/123


Python Ecosystem

https://github.com/quantopian/pyfolio

From: Quant Insights, Oct 2015, Portfolio and Risk Analytics with PyFolio,
Thomas Wiecki (Quantopian)

Certificate in Quantitative Finance 51/123


Preview

1 We will look at how to relate P&L to the market and factors (to
understand what drives it, what you make money on).

2 Then, we will talk about evaluating P&L (through Drawdown


Control).

3 You can look for suitable models for algorithmic order flow and
liquidity impact. [Optional]

Please refer to the Algotrading Elective and QI Quantopian talk for


illustrations and cases.

Certificate in Quantitative Finance 52/123


Alpha and Beta

Beta is the strategy’s market exposure, for which you should not pay
much as it is easy to gain by buying an ETF or index futures contract.

Alpha is the excess return after subtracting return due to market


movements.

RtS = α + βRtM + t

E[RtS − βRtM ] = α

RtM = Rt − rf is the time series of returns representing the market


factor.

Certificate in Quantitative Finance 53/123


Risk-Reward Ratios

Information Ratio (IR) focuses on risk-adjusted abnormal return, the


risk-adjusted alpha!

α
σ()

(But this does not tell us how much dollar alpha is there. It can be
eaten by transaction costs.)

E(Rt − rf )
Sharpe Ratio must be familiar . It measures return per unit
σ(Rt − rf )
of risk.

Certificate in Quantitative Finance 54/123


Factors

Evaluating performance against factors is the central part of the


backtesting.

We saw the separation of alpha and beta in regression wrt one


market factor
RtS = α + βRtM + t

We see that a factor is a time series of changes, similar to the series


of asset returns.

Certificate in Quantitative Finance 55/123


Named Factors

Long-short High Minus Low (HML) or value factor: buy top 30%
of companies with the high book-to-market value and sell the
bottom 30% (expensive stocks).

Small Minus Big (SMB) factor shorts large cap stocks, so β SMB
measures the tilt towards small stocks.

Up Minus Down (UMD) or momentum factor would leverage on


stocks that are going up. The recent month’s returns are
excluded from calculation to avoid a spurious signal.

Certificate in Quantitative Finance 56/123


Factors Backtesting

So how do we check against those factors?

We can set up a regression!

RtS = α + β M RtM + β HML RtHML + t

where RtHML is return series from the long-short HML factor.

We can add factors to this regression.

We can have rolling estimates of these betas for each day/week.

Certificate in Quantitative Finance 57/123


Factors Backtesting (Advanced)

Scale returns to have the same volatility as the benchmark (put


on the same plot for correct comparison).

Rolling Sharpe Ratio, 12M data (changes not desirable).

Rolling market factor beta 6M, 12M data ( β > 1 and changes
are not desirable).

Rolling betas wrt to HML, SMB, UMD (value factor, small


business factor, and momentum factor).

Certificate in Quantitative Finance 58/123


From: Quant Insights, Oct 2015, Portfolio and Risk Analytics with PyFolio,
Thomas Wiecki (Quantopian)

Certificate in Quantitative Finance 59/123


Drawdowns

The drawdown is the cumulative percentage loss, given the loss in


the initial timestep.

Let’s define the highest past peak performance as High Water Mark
(HWM)

HWMt − Pt
DDt =
HWMt
where Pt is the cumulative return (or portfolio value Πt ).

It makes sense to evaluate a maximum drawdown over past period


maxt≤T DDt .

Certificate in Quantitative Finance 60/123


From: Quant Insights, Oct 2015, Portfolio and Risk Analytics with PyFolio,
Thomas Wiecki (Quantopian)

Certificate in Quantitative Finance 61/123


Drawdown Control

The strategy must be able to survive without running into a close-out.

It makes sense to pre-define Maximum Acceptable Drawdown


(MADD) and trace

VaRt ≤ MADD − DDt

where VaRt is today’s VaR and DDt is current drawdown.

Certificate in Quantitative Finance 62/123


Backtesting Risk and Liquidity - Summary

1 Does cumulative P&L behave as expected (eg, for a


cointegration trade)? Is P&L coming from a few or lot of
trades/time period? What are the SR/Maximum Drawdown?
Behaviour of risk measures (volatility/VaR)? Concentration in
assets and attribution?

2 Impact of transaction costs (plot the expected P&L value (alpha)


vs. number of transactions). Is there any P&L from the spread
left after bid-ask spread? What is an impact of transaction costs
(aka slippage assumption)? That would depend on turnover.

Certificate in Quantitative Finance 63/123


From: Quant Insights, Oct 2015, Portfolio and Risk Analytics with PyFolio,
Thomas Wiecki (Quantopian)

Certificate in Quantitative Finance 64/123


Algorithmic Flow

3 Optionally, introduce liquidity and algorithmic flow considerations


(a model of order flow). How would you be entering and
accumulating the position? What impact your transactions will
make on the market order book?

4 Related issue is the possible leverage to be applied to strategy.


While the maximum leverage is 1/Margin, the more adequate
solution for leverage to take is a maximally leveraged
market-neutral gain or alpha-to-margin ratio
α
AM = .
Margin

Certificate in Quantitative Finance 65/123


Developing a Trading Business

You can find the full suite of libraries for data prep, modelling,
analytical/backtesting reports generation and testing.

From: For Python Quants, Nov 2015, Building an Energy Trading Business
from Scratch, Teodora Baeva (BTG Pactual)

Certificate in Quantitative Finance 66/123


Before we conclude, the words of wisdom from Fischer Black:

“In the real world of research, conventional tests of


[statistical] significance seem almost worthless.”

“It is better to estimate a model than to test it. Best of all,


though, is to explore a model.”

Certificate in Quantitative Finance 67/123


The large part of model risk for time series analysis (statistical tests)
is formalised as the multiple testing problem. Here are the
guidelines from the American Statistical Society,

“Running multiple tests on the same data set at the same


stage of an analysis increases the chance of obtaining at
least one invalid result.”

“Selecting one ‘significant’ result from a multiplicity of


parallel tests poses a grave risk of an incorrect
conclusion.”

Certificate in Quantitative Finance 68/123


1 Time Series Analysis and Backtesting

2 Forward LIBOR and Discounting (for IRS CVA Calculation)

3 Interest Rate Volatility and Derivatives

4 Interest Rates - Local Volatility

Certificate in Quantitative Finance 69/123


Forward LIBOR, Discounting Factors (OIS)
inputs for CVA Calculation

Please do not distribute these notes.

Richard Diamond r.diamond@cqf.com

Certificate in Quantitative Finance 70/123


Yield Curves

To infer interest rate expectations, Bank of England builds a variety of


forward curves:

Bank Liability Curve (BLC) from LIBOR-linked instruments.


Government Liability Curve (GLC) from Gilts, the industry
equivalent is swap-based curve.
General Collateral two-week repo curve.
SONIA and recently OIS, historic rates obtained by geometric
averaging of O/N rates.

Each forward curve implies its own Z (0; Ti+1 ) and L(t; Ti , Ti+1 ).

Certificate in Quantitative Finance 71/123


Forward Curves (Pound Sterling BLC)

After the BOE historic data (2000), BLC curve given by swaps on
6M LIBOR, carrying a credit risk O(25bps) vs. SONIA – the spread.

Certificate in Quantitative Finance 72/123


OIS Spread over LIBOR (LOIS)

As we saw, evaluating the spreads is not the new idea.

3M LIBOR − 3M OIS

LIBOR indicates money-market rates for actual loans between


banks for up to 18M.

OIS targets the Federal Funds Rate, an average over the period.
The rate reflects uncollaterised borrowing overnight.

The spread for LIBOR fixings vs. OIS prices reveals the short-term
credit risk in the financial system.

Certificate in Quantitative Finance 73/123


LOIS Spreads

LOIS spread as an average across tenors. Forward OIS curve is


implied.

Li,6M − 6M to OIS spread ∀i

Certificate in Quantitative Finance 74/123


Instantaneous Curve and Forward LIBOR

Zero coupon bond price is obtained by integration over the


instantaneous curve (a row in HJM output),
Z Ti+1 !
Z (0, Ti+1 ) = exp − f̄ (t, τ )dτ
0

This DF matches the expectation of Forward LIBOR.

A link between inst. forward rate f̄ (t, τ ) and discrete Forward LIBOR
" Z Ti+1 ! #
1
L(t; Ti , Ti+1 ) = exp f̄ (t, τ )dτ − 1
Ti+1 − Ti Ti

 
L = m e f̄ /m − 1
1
where m = 6M = 2 is compounding frequency per year.

Certificate in Quantitative Finance 75/123


Forward LIBOR (static curve)

Certificate in Quantitative Finance 76/123


For CVA Calculation:
The deliverables of CVA IRS calculation are (a) MtM simulations of
exposure or forward rates, (b) Expected Exposure EE, and (c)
Potential Future Exposure PFE from the positive side of distribution.

Here is an example of exposure analytics (CVA) that encompasses


both EE and multiple PFE. From: Fernando R. Liorente, CQF Delegate
Certificate in Quantitative Finance 77/123
For CVA Calculation (Cont):
For a vanilla IRS you will need the input of 6M LIBOR L(T , T + 6M)
(these are Forward LIBOR rates).

[D1.] From the forward curve TODAY, it is possible to infer one


statistic set of 7→ L(T , T + 6M) – explore “Yield Curve v3.xlsm”.

The approach is not ideal. Long-term LIBOR rates incorporate


the increasing credit risk of unsecured borrowing.

You will not be able to vary L(T , T + 6M).

The use of one and the same set of DF with multiple simulated
curves is not consistent.

Certificate in Quantitative Finance 78/123


For CVA Calculation (Cont):
[D2.] HJM/LMM output (simulated inst./discrete forward rates) gives
more flexibility in building the Exposure Profile:

Simulations deliver a sample of the same-period rates, from which


the median and 97.5, 99th percentile rates can be picked for the PFE.

MtM values are (discounted) swap cashflows form the initial


curve 7→ [0, 5Y ] of Forward LIBORs,

then the curve 7→ [0, 4.5] simulated at t = 0.5,

then 7→ [0, 4] simulated at t = 1.

Certificate in Quantitative Finance 79/123


For CVA Calculation (Cont):
[D2. Cont.] HJM output is in rows: at each re-set point use the
shorter curve. Please see the updated Caplet tab in HJM MC v3.xls

While Fwd LIBOR are taken off the curve, the range of curve movements
generated by the HJM potentially allows using tenor column τ = 0.5 only.

Credit risk on the swap payment is maximum 6M.

For LMM output, the front section of the curve expires, discrete
Forward LIBOR are readily available across the diagonal.

Certificate in Quantitative Finance 80/123


OIS Discounting

Using one static set of DF from an OIS curve today with re-simulated
Forward LIBOR curves is inconsistent.

However, you may do so for this study project.

Certificate in Quantitative Finance 81/123


Recap of methods
If you have no OIS data: take a swap curve (discrete Forward LIBOR)
and strip the implied OIS curve:

Li,6M − 6M to OIS spread ∀i

Within the current market practice, implying the OIS DF by using the
constant spread is another inconsistency.

Empirically the spreads tend to exhibit a ‘humped’ shape –


spreads for each tenor together form a basis curve.

OIS today Implied OIS Stochastic Basis


(no spread) (constant spread)
static DF re-simulated curves re-simulated curves
and spreads

Certificate in Quantitative Finance 82/123


OIS Discounting
Implied OIS means subtracting the spread from the Forward
LIBOR to obtain the parallel implied OIS curve and DFs from it.

OIS-LIBOR spread makes the curves compatible in terms of the


credit risk, but that is used in reverse to imply the OIS curve from
each simulated Forward LIBOR curve.

LIBOR + OIS. Simulating Forward OIS k Forward LIBOR

LMM for LIBOR vs. HJM for Forward OIS configuration


(equivalence of the models – a question)
HJM vs. HJM would be consistent even less usable.

Certificate in Quantitative Finance 83/123


Stochastic Spread(s) with HJM Model
Stochastic spread. OIS-LIBOR spread is customarily between
discrete-time variables. Fwd-Fwd spread gives better estimation.

We use rate differences, analysed with the PCA to calibrate the HJM

∆f = ft+1 − ft separate for each tenor (column)

fFwd,t − fFwdOIS,t is also spread ∆fs

then proceed with PCA on covariance of ∆fsi , ∆fsj where i, j are tenors.

HJM SDE allow evolving dfsj a stochastic spread for each tenor j, and
will be sensitive to volatility input: high volatility during a credit crunch.

Certificate in Quantitative Finance 84/123


Multiple curve pricing
Castagna et al., 2015 on links between basis and credit risk, for
instance, spot credit spread

1 (LGD + r (0, τ )τ ) PD(0, τ )


s(0, τ ) =
τ 1 − PD(0, τ )

where PD(0, τ ) = 1 − PrSurv = 1 − PCDS (0, T ), also notice


RT
r (τ )τ = 0 f̄ (τ )dτ by integration over an HJM-simulated curve f̄ (t, τ ).

Forward credit spread s(t, t + τ ) calculation relies on PD(t, t + τ )


easily bootstrapped from CDS.

Certificate in Quantitative Finance 85/123


Multiple curve pricing

The consistent multiple curve pricing is desired.

Such pricing takes into account information from a. tenor swaps


(might be traded independently) and b. OIS-LIBOR basis implied by
the differences in funding from 3M and 6M LIBOR.

It is not required that you implement these results in CVA calculation


as they are not yet part of the market practice.

Certificate in Quantitative Finance 86/123


Summary for CVA calculation
There is no one correct way to obtain inputs for your CVA
calculation on a vanilla IRS or derivatives pricing in general.

Whether to use OIS or not (means with collateral): depends on


whether reliable spreads are available (3M, 6M to OIS spreads)
or can be simulated stochastically.

The practical model gives flexibility in Fwd LIBOR simulation,


combined with Implied OIS or stochastic basis.

The alternative not detailed in these slides but worth noting is


simulation of r (t) by a one-factor model, while making volatility
σ → σ(t) and fitting it to market data (caps, swaptions).

Certificate in Quantitative Finance 87/123


Caplet Volatility and LMM
Calibration

Certificate in Quantitative Finance 88/123


Caplet

A caplet is an interest rate option that pays a cashflow based on the


value of LIBOR at a re-set time Ti .

The cashflow is paid for the period τ = [Ti , Ti+1 ] in arrears.

DFOIS (0, Ti+1 ) × max(L(Ti , Ti+1 ) − K , 0) × τ × N (6)

L(Ti , Ti+1 ) is the forward LIBOR. Assume L(Ti , Ti+1 ) = fi


τ is year fraction that converts an annualised rate
N is the notional that can be scaled as N = 1

Certificate in Quantitative Finance 89/123


Payoff and parity

Buying a caplet gives protection from an increase in LIBOR rate:

L − (L − K )+ = min(L, K )

Alternatively for a floorlet:

max(L, K )

Put-call parity for caplet and floorlet becomes:

Buying a caplet and selling a floorlet with the same strike gives a
payoff equal to a FRA contract. Consider

(L − K )+ − (K − L)+ = (L − K ) always

where FRA fixed rate is equal to the strike, so (f − K ).

Certificate in Quantitative Finance 90/123


Pricing Skew

Plotting caplets/floorlets in bps for a range of strikes gives ‘a skew’.

The skew is due to a simple fact: the more an option is in the money
the larger cashflow it delivers. The relationship is almost linear.

Richer volatility surfaces are possible.

Certificate in Quantitative Finance 91/123


You can revisit the caplet pricing example in the HJM Model.

Black (1976) formula is used to quote implied volatility σicap .

τi
Cap = Z (0, Ti ) [fi N(d1 ) − K N(d2 )]
1 + fi τi
ln(fi /K ) ± 0.5σ 2 T
d1,2 = √
σ T
where fi = F (t, Ti , Ti+1 ) becomes set at the caplet expiry Ti and paid
over [Ti , Ti+1 ].

Certificate in Quantitative Finance 92/123


Volatility Stripping and Fitting

Certificate in Quantitative Finance 93/123


Volatility

To calibrate the LIBOR model = To strip caplet volatility

We will consider stripping caplet volatility from market-quoted caps.


This has elements of bootstrapping time-dependent volatility

σ BS (Ti−1 , Ti ) or σi (t)

For the forward curve, caplets are in sequence with 3M reset. Each
caplet is on Forward LIBOR L(0, Ti−3M , Ti ), in Gatarek notation.

Caps are traded in 1Y , 2Y , 3Y , ... increments.

Certificate in Quantitative Finance 94/123


Market Cap Quotes

From: LIBOR Market Model in Practice by Gatarek, et al. (2006).

Certificate in Quantitative Finance 95/123


Calibrating LMM on caplets

Caplet volatility stripping is nuanced. We are going to cover the inputs


and principles.

1 First, we need ATM strikes for the caplets, which are equal to the
forward-starting swap rates

S(t, Ti , Ti+1 ) or S(Ti ; T0∗ , T3M



) gives K

obtained directly from the forward curve today.

Please see Yield Curve.xlsm on how to calculate ZCB prices


implied by the forward curve.

Certificate in Quantitative Finance 96/123


Calibrating LMM on caplets (Cont.)

We use the assumption of flat volatility and extrapolation.

2 Prepare interpolated market volatilities


cap
σ cap
( cap
( ((t,
((T3M
( ), σ (t, T6M ), σ cap (t, T9M ), σMkt (t, T12M ), σ cap (t, T18M ), ....

Initial flat volatility gives


cap cap
σ cap (t, T3M , T6M ) = σMkt (t, T6M ) = σMkt (t, T1Y )

use Black formula to obtain cashflow

cpl(T3M , T6M ).

Certificate in Quantitative Finance 97/123


Volatility Stripping

Instead of bootstrapping via variance, keep using cashflows


T
X
capT = cpli
i

cpl(T6M , T9M ) = capMkt (t, T9M ) − cpl(T3M , T6M ) − 



cpl(t,
T 3M )

cpl(T9M , T12M ) = capMkt (t, T1Y )−cpl(T6M , T9M )−cpl(T3M , T6M )−
cpl(t,
T 3M )

etc.

Use the Black formula to convert back

cpl(Ti−1 , Ti ) ⇔ σ cap (Ti−1 , Ti ).

Certificate in Quantitative Finance 98/123


Volatility Stripping (Cont.)

With the Black formula, even though you use the same constant
volatility σ cap (t, T3M , T6M ) = σ cap (t, T6M ) = σ cap (t, T1Y )

cpl(T3M , T6M ) 6= cpl(T6M , T9M ).

Because Forward LIBOR L(Ti , Ti+1 ) = fi and Forward Swap Rates


(caplet strikes) S(t, Ti , Ti+1 ) = K will be different for each 3M
consecutive period .

Also, even if implied volatility σ is the same (annualised)

cpl(T3M , T6M ) < cap(t, T6M )


cpl(T3M , T6M )  cap(t, T1Y ).

Certificate in Quantitative Finance 99/123


Market Cap Quotes
The result is caplet volatility on a given day (Gatarek, et al., 2006)

The solution is consistent with the bootstrapping we did for local


time-dependent volatility (as actual) from implied volatility (CQF UV Lecture).

Certificate in Quantitative Finance 100/123


Instantaneous Volatility

With volatility stripping, we moved from 12M to 3M increment.

But, the caplet implied volatility is still an average (via integration)


over the actual, instantaneous volatility, on time to maturity.
s
Z Ti−1
cap 1
σ (t, Ti−1 , Ti ) = σ inst (τ )2 dτ
Ti−1 − t t

Therefore, we have two different covariance matrices with an


algorithm to match them

Σcpl ⇒ Σinst

The fitting done next applies to instantaneous volatility.

Certificate in Quantitative Finance 101/123


Volatility Fitting

We would like the term structure of volatility to be time-homogeneous,


h i
σ inst (t) = φi (a + b(Ti−1 − t)) × e−c(Ti−1 −t) + d × 1{t<Ti−1 }

a, b, c, d are the same for all tenors! One set of numbers. This is
regardless your optimization method.

What varies for each tenor is 0.9 < φi < 1.1 to make for near-perfect
fit, such that
 2
inst inst
argmin σEst − σFit

inst
The fitted σFit agrees with the stripped one with only a minimal
squared error.

Certificate in Quantitative Finance 102/123


Parametrised Instantaneous Volatility

Z Ti−1
1  
σ inst (τ )2 dτ = 4ac 2
d[e 2c(t−Ti−1 )
] + ...
t 4c 3

The so called FRA/FRA covariance matrix for instantaneous volatility,


our Σinst , also has a, b, c, d-parametrised, closed-form solution

Z
1  
ρij σi (τ ) σj (τ ) dτ = e−β|ti −tj | φi φj 4ac 2
d[e c(t−Ti )
+ e 2c(t−Tj )
] + ...
4c 3

The complete parametric solutions to be found in CQF Lecture on the


LMM and Peter Jaekel’s textbook.

Certificate in Quantitative Finance 103/123


Parametric Correlation

The simplest parametric fit for correlations with β ≈ 0.1 has merits for
longer tenors

ρij = e−β(ti −tj )

The two-factor parametric form of Schoenmakers and Coffey (2003):


 
|i − j|
ρij = exp − [− ln β1 + β2 ...]
m−1

works for situations that are different from the stylised empirical
observations.

Certificate in Quantitative Finance 104/123


Empirical Correlation

First, changes (in forward rates) at the neighbouring tenors tend to


correlate stronger

Corr[∆fi−1 , ∆fi ] > Corr[∆fi−3 , ∆fi ]

Second, correlation is higher towards the long end of the curve.

Corr[∆fi−1 , ∆fi ] < Corr[∆fj−1 , ∆fj ] for j  i

At the short end the rates tend to behave more independently from
one another. This is due to being most sensitive to the principal
component/primary risk factor of rising the level in the risk-free rate
and the entire curve. Further, for 3M, 6M and 1Y tenors there is own
dynamics because of how specific market instruments are traded.

Certificate in Quantitative Finance 105/123


LIBOR Market Model SDE

Certificate in Quantitative Finance 106/123


LMM Notation

The LIBOR Market Model was designed to operate with forward rates
and denotes them as fi , where

fi = F (t; ti , ti+1 )

The forward rate re-sets at time ti and matures at time ti+1 .

Discount factor is represented in the LIBOR model as

1
Z (t; Ti+1 ) ≡
1 + τi fi
This is discount factor over the forward period τi = ti+1 − ti ! We need
‘one step back’ in LMM SDE.

Certificate in Quantitative Finance 107/123


LMM Result

Using a discretely rebalanced money market account as Numeraire,


the forward rate fi follows the log-normal process

i
X
dfi τj fj m(t)
= σi σj ρij dt + σi dWiQ (7)
fi 1 + τj fj
j=m(t)

m(t) is an index for the next re-set time. This means that m(t) is
the smallest integer such that t ∗ ≤ tm(t) .

Preview: terms come from

dfj dfk = fj fk σj σk ρjk dt

in an SDE for dZi .

Certificate in Quantitative Finance 108/123


Rolling-forward risk-neutral world

The SDE is defined under the Spot LIBOR Measure Qm(t) , known as
the rolling forward risk-neutral world.

We just keep discounting the drift.

If you would like to see how LMM SDE is derived starting from an
SDE for dZi and using the Ito lemma, please review CQF Alumni
Lecture on LMM by Tim Mills.

You might like to add your version of LMM derivation in the


mathematical opening of the report.

Certificate in Quantitative Finance 109/123


LMM SDE discretised (single-factor)

The SDE (7) is for the log-normal dynamics of fi given by the


instantaneous FRAs. It is solved into a discretised version as follows:

Xi
τj fj (tk ) σj (tj−k−1 )ρij
fi (tk+1 ) = fi (tk ) exp σi (ti−k −1 )
1 + τj fj (tk )
j=k+1
 
1 2 √
− σi (ti−k −1 ) τk + σi (ti−k−1 )φi τk (8)
2

where fj (tk ) = fj and σj (tk ) = σj (t) for tk < t < tk+1 .

Notation tj−k −1 means we refer to the previous time step k − 1.

Certificate in Quantitative Finance 110/123


SDE Simulation

HJM is a Normal (Gaussian) model as we simulated

f̄ (t + dt, τ ) = f̄ (t, τ ) + d f̄

d f̄ are Normally distributed and the curve in row is evolved in


continuous time at fixed tenors.

LMM is a Log-Normal model

f (t + dt) = f (t) exp (df )

The curve evolved in discrete tenor chunks, arranged in column.

Certificate in Quantitative Finance 111/123


Forward LIBOR

We select the simulated curve result from the diagonal.

Column simulation reveals the logic of bringing all rates under the
same measure (tenor). LN (t) is a martingale under the terminal
measure.

LMM model output with credit to Numerical Methods book and CCP
Elective by Dr Alonso Pena.

Certificate in Quantitative Finance 112/123


1 Time Series Analysis and Backtesting

2 Forward LIBOR and Discounting (for IRS CVA Calculation)

3 Interest Rate Volatility and Derivatives

4 Interest Rates - Local Volatility

Certificate in Quantitative Finance 113/123


Local Volatility in Interest Rates

Certificate in Quantitative Finance 114/123


Introduction

The problem of local volatility in interest rates is that the underlying,


eg L6M (t), changes!

We need to evaluate the derivative ∂V /∂T for options of the same


asset.

Certificate in Quantitative Finance 115/123


Forward PDE

 
K 2 σ 2 (T , K ) ∂ 2 C ∂C ∂C
= + µ(T ) K −C
2 ∂K 2 ∂T ∂K

This is very Dupire-like!

h + i
C = Espot LT ,(T +τ ) (T ) − K |t

Certificate in Quantitative Finance 116/123


Local Volatility Stripping
It follows from Dupire-type Forward PDE that local volatility is,
v
u 
1 u ∂C ∂C
+ µ(T ) K ∂K −C
σ(T , K ) = t2 ∂T
∂2C
K
∂K 2

v
u ∂σimp σimp ∂σimp
u 2 + + 2K µ(T )
σ(T , K ) = u
t 
∂T
2
T ∂K
 2
1 Ky ∂σimp ∂ 2 σimp K 2 σimp T ∂σimp ∂σimp
σimp T 1+ σimp ∂K + K2 ∂K 2
− 4 ∂K +K ∂K
(9)
and this is the local volatility stripping formula to use.

Remember to interpolate over σimp , and evaluating derivatives


∂σimp /∂T will be possible.

Certificate in Quantitative Finance 117/123


Caplet re-pricing

This is a special caplet formula, pricing is done under the rolling spot
LIBOR measure.

C(T , T + τ , K ) = τ Z (t, t + τ ) [ F (T )N(d1 ) − KN(d2 ) ] (10)

2
ln(F (T )/K ) ± 0.5σimp (T − t)
d1,2 = p
σimp (T − t)

Also y = ln(F (T )/K ).

Certificate in Quantitative Finance 118/123


Caplet Formula Inputs

The secret sauce that makes rolling measure working,

"Z #
T
F (T ) = Lt,(t+τ ) exp µs,(s+τ ) ds
t

Z T  
Z (t, T + τ ) LT (T +τ ) (t)
µs,(s+τ ) ds = ln (11)
t Z (t, t + τ ) Lt,(t+τ ) (t)

All inputs are known from the today’s curve. You can bootstrap the
drift of the spot process µt,(t+τ ) .

Certificate in Quantitative Finance 119/123


Change of Measure - Radon-Nikodym Theorem
Normal caplet, priced under the forward measure in which forward
 
rate is martingale Efwd LT ,(T +τ ) (T )|t = LT ,(T +τ ) (t) = L6M (t).

h + i
C(T , T + τ , K ) = τ Z (t, T + τ ) Efwd LT ,(T +τ ) (T ) − K |t

 
Z (T , T + τ ) Z (t, t + τ )
Efwd [Payoff] = Espot  Payoff
Z (t, T + τ ) Z (T , T + τ )
| {z }

Z (t, t + τ ) spot
= E [Payoff]
Z (t, T + τ )

C(T , T + τ , K ) = τ Z (t, t + τ ) Espot [Payoff] .

Certificate in Quantitative Finance 120/123


Fixed Tenor Rolling LIBOR

Let’s introduce a GBM-like SDE for a fixed tenor τ LIBOR. The


difference is that the interest rate is NOT an asset.

dLt,(t+τ ) (t) Q
= µt,(t+τ ) (t) dt + σt,(t+τ ) (t) dXt,(t+τ ) (t)
Lt+τ (t)

This is pricing under the spot measure. Z (t, t + τ ) is a local


numeraire, which obviously changes at each t.

Lt,(t+τ ) (t) Lt,6M (t) L6M (t) (12)

Certificate in Quantitative Finance 121/123


LVM Step-by-step

1 Obtain the quoted caps from market data or HJM simulation –


must be cashflows. Compute cap prices (in volatility terms) by
special pricing fomulae for the spot process.
Those formulae require the drift µ[T ] computable and fully known
from today’s curve analytically.
Result is an implied volatility of the rolling LIBOR σimp (T , K ).
2
Interpolation to 3M granularity using linear variance σimp T.

2 European swaptions also have fully analytical pricing formula to


obtain σimp (T , K ).

3 Implied volatility of rolling LIBOR to be converted into local


volatility using the solution for a Dupire-type forward PDE.

Certificate in Quantitative Finance 122/123

Das könnte Ihnen auch gefallen