Multiply and group values dependent on condition

The final step of my analysis is to multiply the returns and the expected returns for each earnings date.
The output should be something like this:
Ticker: EarningsDate: Returns: Expected Returns:
APPL 31-Jan-2017 (-0.0026*-0.0023*-0.0610) (-0.0064*-0.0016*0.0032)
APPL 02-May-2017 etc etc.
Can anybody give me some hint how to achieve this?

1 件のコメント

Walter Roberson
Walter Roberson 2022 年 11 月 11 日
You flagged the question as inappropriate for MATLAB Answers. Could you expand on why you now believe that your question is not a valid question about MATLAB ?

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2022 年 11 月 2 日
編集済み: Image Analyst 2022 年 11 月 2 日

0 投票

If t is your table, did you try
out = t.Return .* t.ExpectedReturn % Multiply columns together
and then using groupsummary, splitapply, or grpstats on out.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

3 件のコメント

MT_22
MT_22 2022 年 11 月 2 日
Thanks for your answer.
I'm trying to multiply the returns in this way:
E.g. for Earnings Date 31-January-2017:
Return(30-Jan-2017)*Return(31-Jan-2017)*Return(01-Feb-2017) [the same for the expected return column]
then multiply the next three returns for the next earnings date and so on.
I do not have a code so far, because I'm stil figuring out how I can achieve this.
Image Analyst
Image Analyst 2022 年 11 月 3 日
OK, fine, but I can't run an image. I need code and data. It looks like you overlooked part of my response, so again:
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Image Analyst
Image Analyst 2022 年 11 月 3 日
Sorry, heading out for the day but this works
T = readtable("data_question.txt")
out = T.Return .* T.ExpectedReturn % Multiply columns together
then just use the other functions I told you.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeFinancial Toolbox についてさらに検索

質問済み:

2022 年 11 月 2 日

コメント済み:

2022 年 11 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by