trading rule return how do we calculate it??
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi,
I am running trading rules and wonder how to calculate the return. I have read in the papers but still confusing. They multiply the return by the indicator we get from the rules which are -1,1 or zero. In this case we do not take the holding period into the account.
what I was doing is after getting the buy/sell signals, get the holding period by changing the values of zeros after 1 to 1 till -1 where changes the zeros to -1 till 1 and so on so for. I was looking to the indicator only to indicate the days of buy and sell but I did not multiply them. so I only rely on the return series for the stock to calculate the return.
for example if I have return as follow:
0.2, 3.2, -0.2, -.0785 and signals as follow:
1 0 -1 0 I change them to holding period as follow:
1 1 -1 -1 and the return will be the sum of the return series above: 0.2+3.2-0.2-0.785 but as I understood from the papers is as follow:
multply the return series by the signals as follow:
1* 0.2 + 0*3.2 +(-1-0.2)+ 0*0.785
how do we calculate the return please please please????
thanks
댓글 수: 2
Image Analyst
2013년 12월 27일
I don't understand the English for "changing the values of zeros after 1 to 1 till -1 where changes the zeros to -1 till 1 and so on so for." Can you explain that better. Your one example is confusing. So if you have a 0 after a 1, then you change the 0 into a 1. I got that, and that's why [1 0] turned into [1 1] (the first two elements). But I don't know what the rest of the sentence means "till -1 where changes the zeros to -1 till 1 and so on so for." That's where I'm really confused.
답변 (2개)
Image Analyst
2013년 12월 28일
Can you do this:
returnSeries = [0.14 0.64 -0.24 -0.125 0.12 0.3 0.1 0.1458 -0.15 1.24]
signals = [0 1 0 0 0 -1 0 0 1 0 0 0 0 -1 0 0 0 0 1]
index = 1
signalsOut = signals; % Initialize.
while index < length(signals)
if signals(index) == 1 || signals(index) == -1
% It's 1 or -1, so continue that number until we hit the next 1 or -1
valueToPropagate = signals(index); % a 1 or -1
index = index+1;
while signals(index) == 0
signalsOut(index) = valueToPropagate;
index = index+1;
end
else
% No match
index = index + 1;
end
end
signalsOut % Print to command window
product = returnSeries .* signalsOut
The only problem is that the return series example you gave doesn't have the same number of elements as your signal.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Financial Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!