2
$\begingroup$

I have a daily US swaps data here for 2020 https://easyupload.io/yh4rnd . I have run PCA on standardized data and got PCA matrix (and basic statistics):

enter image description here

enter image description here

I also have such hypothetical portfolio that in this example is making +$195k.

enter image description here

Question: How do I attribute this P&L to each principal component, such that the total P&L number equals +$195k?

Working through suggestion by Dimitri:

Assuming we cannot fully reprice portfolio using a perturbed interest rate curve, so will go with DV01s. To calculate ci for each PCi I converted PCA on standardized data back to unstandardized and calculated weights below for each tenor x PC, then for each PCi I calculated Open and Close in % (eg PC1 opened at 1.94 and closed at 1.89) with c1 euqal to -5.58bp (I checked, each PCi is orthogonal). I then used the same weights to convert original risk from hypothetical book into PCi. I then multiply ciPCi x δ to get P&L. But it doesn't seem to match up, which step am I getting wrong?

enter image description here enter image description here

$\endgroup$
1
  • $\begingroup$ Hi Dimitri, I saw this question and answer, unfortunately no. I think the author posts similar answer to many PCA questions, but doesn't really answer exact question. But thanks for a repy! $\endgroup$
    – John
    Jan 22 at 20:51

3 Answers 3

2
$\begingroup$

Linear PnL is usually correctly estimated by the inner product of risks and market movements::

$$ Pnl = S \cdot \Delta r = S^T \Delta r$$

Where you apply a linear transformation to those risks to express it in some other mathematical basis (e.g. PCA respresentation), then you have some transformation matrix, $T$, and it is easier to show that the PnL is invariant if you perform the following:

$$ \underbrace{T S}_{\text{transformed risk}} \cdot \underbrace{T^{-T} \Delta r}_{\text{transformed changes}} = S^T T^T T^{-T} \Delta r = S^T \Delta r = Pnl$$

Therefore the market movements should be transformed using the inverse-transpose of the original transformation matrix.

Mathematically this is an expression of covariant and contravariant transformations, if you care to investigate further.

enter image description here

Note that you should be able to check your matrix calculations by supplying your portfolio risks such that they align with just on PC (e.g. the first) and ensure that the resulting PCA risks appear to show risk purely to this PC, as in:

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you a lot for a reply. Do you think you can arrive at the same answer with that dataset? $\endgroup$
    – John
    Jan 25 at 6:54
  • $\begingroup$ Yes there you go, it is a simply matrix multiplication, where you need to invert your PCA matrix to derive the risks, and you need to use it to derive the PCA changes. (note the inverse of an orthogonal matrix is its transpose) $\endgroup$
    – Attack68
    Jan 25 at 11:52
  • $\begingroup$ Attach68, thank you so much, that's exactly the direction I am looking for. However, the Δr, is derived from PCA levels that would correlated between each other. If you expand further and have Δr as R1-R2 and apply PCA matrix to R1, vectors will not be orthogonal. I assume this is because I applied PCA on standardized data.. what would be the solution for this? $\endgroup$
    – John
    Jan 25 at 22:29
1
$\begingroup$

Back in the day, I used to do precisely this on a cross-asset basis. The critical point being that the correlations of any of your PCs to any other PC will be zero, else you will have miscalculated your PCs in the first place.

This being a given, you can regress your P&L to any and every PC in isolation, safe in the knowledge that all the others are irrelevant, because they are completely uncorrelated ;-)

Excel's "=SLOPE(y-array,x-array)" will usually suffice. Sometimes, the intercept will create funnies. In which case, "=SUMPRODUCT(y-arrayx-array,x-arrayx-array)" (ie an intercept-less regression) usually works.

hope this helps, DEM

$\endgroup$
5
  • $\begingroup$ Hi DEM, thanks a lot for a response. What do you mean regress P&L to PC? P&L is unknown, we have rates, risk, pca and stats, but I am unsure how to translate risk and rates to principal components so that P&L would add up. $\endgroup$
    – John
    Jan 23 at 9:13
  • $\begingroup$ Hi John. Sorry if I misunderstood your question. I thought you had P&Ls that you wished to attribute to style-factors (proxied by PCs). The beauty of PCA is that the PCs are, by definition, uncorrelated with each other, so their regression to anything of interest becomes trivial. There is zero multi-colinearity to worry about. That was the point I was trying (badly) to make. $\endgroup$
    – demully
    Jan 23 at 21:33
  • $\begingroup$ Oh I see, no that makes sense. But what about attributing the risks to principal components and then calculating P&L on them? Surely that's possible? $\endgroup$
    – John
    Jan 23 at 22:43
  • $\begingroup$ Yes you can, but it's horrible ;-) you you really want to go there??? $\endgroup$
    – demully
    Jan 24 at 0:56
  • $\begingroup$ Horrible indeed... but yes! Exactly where I am going, something what Attack68 mentioned, but keeping components uncorrelated. $\endgroup$
    – John
    Jan 25 at 22:30
0
$\begingroup$

You're right - I've looked, and there are many good tutorials on IR curve PCA out there, e.g. https://mockquant.blogspot.com/2010/12/principal-component-analysis-to-yield.html , https://plus.credit-suisse.com/r/kv66a7 , but I don't see anywhere a good explanation of atributing P&L to the IR curve changes in terms of PCs. Therefore I will outline it. Please ask if any details are unclear and suggest edits if you see errors.

We assume that:

You use the same instruments on day 0 and day 1 to bootstrap the interest rate curve. The interest rate curve is defined by the levels of the instruments.

You know the change for each instrument from day 0 to day 1.

You know the loadings (the weight of each instrument) of the $p$ principal components, denoted $PC_1\ldots PC_p$.

However I don't want to assume that the interest rates sensitivities are strictly linear, i.e. that the dv01's tell us the whole story of the IR risk. Rather, we want the methodology to work even for highly non-linear instruments. You should fully reprice the portfolio using a perturbed interest rate curve if you can. However if you cannot fully reprice, and must estimate the P&L from the dv01's, let $\delta$ denote the vector of dv01's (P&L from small changes in each instrument, interest rate deltas).

Let $Y_0$ denote the interest rate curve on day 0, $M_0$ the mark to market on day 0, and $Y_f$ denote the interest rate curve on day 1.

In order to explain the P&L, we want to explain the change in the interest rate curve levels from $Y_0$ to $Y_1$ in terms of the PC's - each $PC_i$ moved by some $c_i$ that we will find.

For $i=1$ to $p$ - start loop on the principal components

Solve for $c_i$, the change in the interest rates attributable to $PC_i$, that minimizes the distance between $Y_i \stackrel{\mathrm{def}}{=} Y_{i-1} + c_i PC_i$ and $Y_f$.

For better transparency, output $c_i$, and $c_i PC_i$ - the changes in the instruments explained by $PC_i$.

Estimate the P&L contribuion of each instrument by multiplying $\delta$ and $c_i PC_i$. Report these P&L estimates and their sum (the P&L from $PC_i$ move estimates from dv01's).

If you can fully reprice the profolio: let $M_i$ denote the mark to market using curve $Y_i$. Report $M_i - M_{i-1}$ as the more accurate P&L attributable to the $c_i$ change in $PC_i$.

For a more complete picture, if $i>1$, then let $y'_i$ denote $y_0 + c_i PC_i$ - the interest curve obtained by perturbing only $PC_i$ and no other PCs. Reprice the profolio: let $M'_i$ denote the mark to market using curve $Y'_i$. Report $M'_i - M_0$ as the P&L attributable to the $c_i$ change in $PC_i$ and no other PCs.

Otherwise if you don't want to fully reprice, then just use the P&L estimated from the dv01's.

Next $i$ - end loop on the principal components

Report residual P&L not explained by this methodology.

$\endgroup$
3
  • $\begingroup$ Thanks a lot for extensive reply Dmitri. I have a question: So Yi = Yi-1 + ciPCi is essentially our mark to market, and assuming we get ci (change in PCi), where do we use dv01 risks and where do we translate dv01 for each bucket into PC? I tried multiplying PC matrix with risk ladder, and using PC rates from unstandardized pca, but P&L wouldn't add up. $\endgroup$
    – John
    Jan 23 at 9:08
  • $\begingroup$ OK, I edited and added the P&L estimation from dv01's, please see if everything makes sense now $\endgroup$ Jan 23 at 13:18
  • $\begingroup$ Thanks Dimitri! I have edited the main question going with your solution, but couldn't get P&L to match, is there anything I am missing? $\endgroup$
    – John
    Jan 23 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.