フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

% Change Calc looks wrong

1 回表示 (過去 30 日間)
P_Alpha
P_Alpha 2015 年 10 月 16 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hey everyone, I am trying to calculate the returns of stock prices, and my output from Matlab looks wrong when compared to excel. I have a 196x2 double named "TickeradjClose" where col 1 is dates, with the most recent date at the top, and column two is closing prices. My formula for calculating the return, as a decimal, is below (Sorry, it is sloppy as I am new to Matlab).
Tickerreturns=(((TickeradjClose(1:end-1,2)))-((TickeradjClose(2:end,2))))./TickeradjClose(2:end,2);
Please let me know what I am doing wrong. I have been asking some very basic questions recently, but hopefully I can pick this up as quickly as I picked up SQL and VBA so that I can begin to answer questions for others :)
Best!

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 16 日
Your calculation is algebraically equivalent to
Tickerreturns = TickerAdjClose(1:end-1,2)./TickerAdjClose(2:end,2) - 1;
Is that what you want?
Let us take the simple case of two values, which might be called Open and Close, then your calculation is (Open-Close)/Close which is Open/Close - 1 . Are you sure that is the order you want? For example alternatives would include (Close-Open)/Close and (Close-Open)/Open and (Open-Close)/Open .
Suppose something was 5 at day 1 and 10 at day 2. Then your current formula would be (5-10)/10 which would be -1/2 . Does that make sense to you? Wouldn't it make more sense to calculate (10-5)/5 = 2 ?

この質問は閉じられています。

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by