Filter löschen
Filter löschen

Calculate running hold duration

2 Ansichten (letzte 30 Tage)
david crowley
david crowley am 8 Sep. 2021
Beantwortet: KSSV am 8 Sep. 2021
I have a table that lists the history of stock transaction (extract attached). I require assistance to find out how long I've held each stock for?
For example, I held AAP within the 12 stocks (fixed scalar) I held on 31/12/1999 and 7/1/2000. However it was not held in the portfolio of 14/1/2000. This would mean the hold period for this stock is two weeks (2 weeks). I require this calculation to go into a separate table.
Row 1 - '31-Dec-1999' 'AAP'
Row 13 - '07-Jan-2000' 'AAP'
Can someone please assist as to how i can go about implementing this?

Akzeptierte Antwort

KSSV
KSSV am 8 Sep. 2021
% T = readtable('example.xlsx') ;
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/732154/example.xlsx');
idx = strcmp(T.(2),{'''AAP'''}) ;
T(idx,:)
ans = 2×2 table
date code _________________ _________ {''31-Dec-1999''} {''AAP''} {''07-Jan-2000''} {''AAP''}

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by