I looked onto different questions and answers about application of PCA on this site and found this interesting article :
http://systematicedge.wordpress.com/2013/06/02/principal-component-analysis-in-portfolio-management/
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 :
This is what i usually get for MIN variance :
This is what i usually get for MAX variance :
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