pairs trading strategy problem
2 views (last 30 days)
Show older comments
good morning everyone
I'm developing a strategy of pairs trading. I found a part of a matlab on http://www.mathworks.com/matlabcentral/fileexchange/31060-cointegration-and-pairs-trading-with-econometrics-toolbox but I could not understand how it works
I don't understand how the final return is calculated in this part of the code.
r4 is the total return vector
'series' represents the prices of companies.
s(i:i+N-1, 2) = (res/reg1.RMSE > spread)- (res/reg1.RMSE < -spread); s(i:i+N-1, 1) = -reg1.coeff(2) .* s(i:i+N-1, 2);
r = sum([0 0; s(1:end-1, :) .* diff(series2) - abs(diff(s))*cost/2] ,2) title(['Final Return = ',num2str(sum(r4),3),'(',num2str(sum(r4)/mean(series2(1,:))*100,3),'%)'])
specifically I'd like to learn the reason of the division of sum(r4) to the mean.
(',num2str(sum(r4)/mean(series2(1,:))*100,3),'%)'])
thank you so much for your time and cooperation,
regards
0 Comments
Answers (0)
See Also
Categories
Find more on Transaction Cost Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!