Rank: 25958 based on 0 downloads (last 30 days) and 0 files submitted
Personal Profile:
Professional Interests:
trading

 

Watch this Author's files

 

Comments and Ratings by V
Updated File Comments Rating
01 Apr 2009 Classical Pairs Trading Using MatLab Performs the classical pairs trading strategy with user defined parameters Author: Marcelo Perlin

edited your "pairs.m" file. noticed that when you use the least-squares sum method, the matrix you get is symmetric. therefore, I calculated the lower triangular only, 'nan' on diagonals, and copied over the transpose cell pair. When I set ut very low, this speedup really shows:

for i=1:n2
    for j=1:(i-1)
        Qdist(i,j)=sum((x(:,i)-x(:,j)).^2);
        Qdist(j,i)=Qdist(i,j);
    end
    Qdist(i,i)=nan;
end

last note: i don't think you use pairs(:,2)=m'; anywhere in the parent scripts, maybe you could eliminate it.

Contact us at files@mathworks.com