フィルターのクリア

How to compute excess returns for several companies and dates?

1 回表示 (過去 30 日間)
Ana
Ana 2014 年 4 月 25 日
回答済み: Andrei Bobrov 2014 年 4 月 25 日
Hello,
I have the set of data below (For about 6000 companies and not only 3, and daily data until 2004).
What I need to do is, for each company at a time, set a new column - say column D - with Returns (col.C) minus the risk free rate (col.G) for the correspondent dates.
So for example, for company B it would be B8-G2, B9-G3 and so on. For company C it would be B14-G2 and etc.
Is there a simple way to do this? For example search, while the company code is the same, matching dates between column B and F and set a new array with the subtracted values?
Thank you so much in advance (I'm new to matlab)!

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2014 年 4 月 25 日
ABC = {'A','B','C'}';
DATES = num2cell((19630101:100:19630601)');
ii = fullfact([3 6]);
Df = [ABC(ii(:,1)),DATES(ii(:,2))];
p = [1 2 1 0 1 1 ]'*.01;
[~,i0] = ismember(cell2mat(Df(:,2)), cell2mat(DATES));
pc = num2cell(p);
out = [Df,pc(i0)];

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by