Effacer les filtres
Effacer les filtres

How to compute excess returns for several companies and dates?

1 vue (au cours des 30 derniers jours)
Ana
Ana le 25 Avr 2014
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)!

Réponses (1)

Andrei Bobrov
Andrei Bobrov le 25 Avr 2014
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)];

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by