I have a question about pairs trading
이전 댓글 표시
Good Morning I watched the pairs trading webminar. I would like to ask if anyone can give me some information about the operation of certain parts of the code.
Is regression implemented in this part?
% The strategy:
% 1 Compute residuals over next N days
res = series2 (i: i + N-1, 1) ...
- (Reg1.coeff (1) + reg1.coeff (2). * Series2 (i: i + N-1, 2));
-------------------------------------------------- -----------------------------------
I am also not clear about this part:
% 2 If the residuals are large and positive, then the first series
% Is Likely to decline vs. the second series. Short the first
% Series by a scaled number of shares and long the second series by
1% share. If the residuals are large and negative, do the
% Opposite.
indicated (i: i + N-1) = res / reg1.RMSE;
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);
end
end
Thank you for your concern and time. Best regards, Caserta
댓글 수: 5
Bruno Pop-Stefanov
2014년 10월 8일
When computing the residuals, regression statistics (struct reg1) are computed by doing the cointegration regression with the egcitest function. So, yes, regression is used and computed at line 49 of pairs.m.
As for the second part, this is explained by the comment. s is the output trading signal returned by the pairs function. The signal will be short one series and long the other (or do the opposite) based on which residuals are the largest.
alessandro caserta
2014년 10월 9일
Bruno Pop-Stefanov
2014년 10월 10일
Alessandro,
I am not familiar with the code and my background is not in economics or finance but here is what I understand about the code:
1) If cointegration is inferred, reg1 contains regression statistics that can model the series. Line 56 of pairs.m computes the residuals of the regression: we take the difference between the first series and the cointegrated second series.
2) RMSE is the root mean squared error. On this line the residuals are normalized by the standard deviation so that we can compare the residuals to the spread.
3) This is the opposite signal of lines 66-67.
Sorry I cannot help you more. You might want to post a message on the File Exchange submission and ask the author directly. He will know his code more than I do.
alessandro caserta
2014년 10월 11일
alessandro caserta
2014년 10월 16일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Transaction Cost Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!