Beruflich Dokumente
Kultur Dokumente
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
The mean error, root mean squared error, mean absolute error, mean
percentage error, mean absolute percentage error, and mean
absolute scaled error.
The useful part of a forecast does not extend beyond 2-3 days.
From: Quant Insights, Oct 2015, Portfolio and Risk Analytics with PyFolio,
Thomas Wiecki (Quantopian)
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
h i
y1,t=1
y1,...
y1,p
y1,p+1 y1,p+2 · · · y1,t=T
Y = BZ +
B̂ = YZ 0 (ZZ 0 )−1
ˆ = Y − B̂Z
0
A linear combination βCoint Yt = et must generate cointegrated
residual (spread) as below et ∼ I(0)
Step 1. Obtain the fitted residual and test for unit root.
e b t −a
bt = yt − bx b
Step 2. Plug the residual from Step 1 into the ECM equation and
estimate parameters φ, α
bt−1 .
∆yt = φ∆xt − (1 − α)e
Π = αβ 0
(n × n) = (n × r ) × (r × n)
0
The allocations β̂Coint provide a mean-reverting spread.
For the price levels P of two assets, stock S and market index M, we
have a cointegrated residual
The dollar MtM P&L ∆et = et − et−1 does not depend on the level µe
∆et ∆P S − βC ∆PtM
= St M
= RtC
et−1 Pt−1 − βC Pt−1
Corr[RtC , RtM ]
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)?
τe ∝ ln 2/θ
et crosses µe + σeq
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
et+τ = 1 − e−θτ µe + e−θτ et + t,τ
et = C + Bet−1 + t,τ
ln B
e−θτ = B ⇒ θ=− (3)
τ
C
1 − e−θτ µe = C ⇒ µe = (4)
1−B
σ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 .
https://github.com/quantopian/pyfolio
From: Quant Insights, Oct 2015, Portfolio and Risk Analytics with PyFolio,
Thomas Wiecki (Quantopian)
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).
3 You can look for suitable models for algorithmic order flow and
liquidity impact. [Optional]
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.
RtS = α + βRtM + t
E[RtS − βRtM ] = α
α
σ()
(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.
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.
Rolling market factor beta 6M, 12M data ( β > 1 and changes
are not desirable).
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 ).
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)
Each forward curve implies its own Z (0; Ti+1 ) and L(t; Ti , Ti+1 ).
After the BOE historic data (2000), BLC curve given by swaps on
6M LIBOR, carrying a credit risk O(25bps) vs. SONIA – the spread.
3M LIBOR − 3M OIS
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.
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.
The use of one and the same set of DF with multiple simulated
curves is not consistent.
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.
For LMM output, the front section of the curve expires, discrete
Forward LIBOR are readily available across the diagonal.
Using one static set of DF from an OIS curve today with re-simulated
Forward LIBOR curves is inconsistent.
Within the current market practice, implying the OIS DF by using the
constant spread is another inconsistency.
We use rate differences, analysed with the PCA to calibrate the HJM
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.
L − (L − K )+ = min(L, K )
max(L, K )
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
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.
τ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 ].
σ 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.
1 First, we need ATM strikes for the caplets, which are equal to the
forward-starting swap rates
cpl(T3M , T6M ).
etc.
With the Black formula, even though you use the same constant
volatility σ cap (t, T3M , T6M ) = σ cap (t, T6M ) = σ cap (t, T1Y )
Σcpl ⇒ Σinst
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.
Z Ti−1
1
σ inst (τ )2 dτ = 4ac 2
d[e 2c(t−Ti−1 )
] + ...
t 4c 3
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 simplest parametric fit for correlations with β ≈ 0.1 has merits for
longer tenors
works for situations that are different from the stylised empirical
observations.
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.
The LIBOR Market Model was designed to operate with forward rates
and denotes them as fi , where
fi = F (t; ti , ti+1 )
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.
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) .
The SDE is defined under the Spot LIBOR Measure Qm(t) , known as
the rolling forward risk-neutral world.
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.
f̄ (t + dt, τ ) = f̄ (t, τ ) + d f̄
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.
K 2 σ 2 (T , K ) ∂ 2 C ∂C ∂C
= + µ(T ) K −C
2 ∂K 2 ∂T ∂K
h + i
C = Espot LT ,(T +τ ) (T ) − K |t
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.
This is a special caplet formula, pricing is done under the rolling spot
LIBOR measure.
2
ln(F (T )/K ) ± 0.5σimp (T − t)
d1,2 = p
σimp (T − t)
"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+τ ) .
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 + τ )
dLt,(t+τ ) (t) Q
= µt,(t+τ ) (t) dt + σt,(t+τ ) (t) dXt,(t+τ ) (t)
Lt+τ (t)