R codes to produce trading strategy using Principal Component Analysis (PCA). In addition to traditional PCA approach we will also explore Constrained Principal Component Analysis (CPCA) where we add a non-negativity constrains to the usuals PCA scores.