I looked onto different questions and answers about application of PCA on this site and found this interesting article :


It shows that after application of the PCA it is possible to get Eigen Portfolio that is permanently growing like almost straight line going up. I am using AlgLib to apply PCA to the list of currency timeseries and looking at the charts i am almost sure that it is applied correctly at least because it correctly identifies the currency pair that adds the most variance to the portfolio.

Unfortunately, neither eigenportfolio in my case look like the one displayed on this screenshot (PC4) :

What i need is : enter image description here

This is what i usually get for MIN variance :

enter image description here

This is what i usually get for MAX variance :

enter image description here

Question : how can i get the chart that would look like the one marked as PC4 on the screenshot above?

Update # 1 :

There are a lot of code and it is not well-formed so i will display only meaningful calculations with the following terms :

  • Prices = Returns
  • iOrder = K = number of assets, currency pairs
  • iDepth = N = number of observations, prices for each currency pair
  • Period = Time Frame e.g. 1 Day = in this example it means that 1 observation = 1 daily price
  • iSeries = Matrix K x N = source matrix that contains data synchronized by time
  • iCharts = Matrix K x N = matrix that contains correctly scaled returns e.g. log(returns)
  • Synthetics = plot that mimics open position on portfolio

1) Synchronize(iPrices, Period, iOrder, iDepth) - synchronize assets by date and time

2) GetEquityMatrix(iSeries, iCharts, iOrder, iDepth) - measure every currency in USD (i can use Log(Prices) here instead)

3) CAlglib::PCABuildBasis(iCharts, iDepth, iOrder, result, iEigenValues, iEigenVectors) - actual calculation of eigen values and eigen vectors

4) Synthetics[N] = Sum(iCharts[0...K][N] x iEigenVectors[0...K][IndexOfVectorWithNeededVariance e.g. 0]) - calculation of N-th value on the chart

  • 3
    $\begingroup$ 1) There is some dangerous approximations on the article you linked. 2) They lead to approximations from you: no there is no garanteed portfolio wich is almost increasing. 3) Your plot is not available anymore, but it look like you ploted the weigth of an asset inside the PCA. You should add your code if you want us to point out what is wrong. $\endgroup$ Jul 13, 2014 at 17:02
  • $\begingroup$ @lmorin : i've updated my question, these are not only weights but weigths multiplied by N-th observation $\endgroup$
    – Anonymous
    Jul 13, 2014 at 17:37
  • $\begingroup$ @Imorin what are the approximations in the article? $\endgroup$
    – Richi Wa
    Jul 14, 2014 at 8:40
  • $\begingroup$ Just looking quickly... try getting all of your variables denominated in USD. So for example usdchf should be chfusd. $\endgroup$
    – SpeedBoots
    Jul 14, 2014 at 12:10
  • $\begingroup$ I'm pretty sure that all they do is convert returns back to levels. $\endgroup$
    – John
    Jul 14, 2014 at 13:25

1 Answer 1


Trying to answer:

  • in the blog post that you mention the author looks at three equity funds and one REIT fund. One could say that these markets are different to FX markets (for various reasons but let's start with the question whether there is a risk premium in FX markets).

  • what he does is the usual PCA analysis on the data. You find various questions in this forum and more links there. Look e.g. here: Calculating Variance Explained from PCA Loadings.

  • when you have understood the math (you can't go on without understanding the math) then you see that PCA is an analysis tool for what has happened. Apparently there is a principle portfolio that looks like an upward sloping trend. Just recall that the eigenvalue attached to PC 4 is rather small compared to the eigenvalues of 1-3. Thus if in-sample small changes could change the picture in-sample (!). Out-of-sample things can go totally different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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