필터 지우기
필터 지우기

Calculate running hold duration

조회 수: 2 (최근 30일)
david crowley
david crowley 2021년 9월 8일
답변: KSSV 2021년 9월 8일
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?

채택된 답변

KSSV
KSSV 2021년 9월 8일
% 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''}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by