필터 지우기
필터 지우기

Alternative for an increasing number of conditions in if-statements

조회 수: 3 (최근 30일)
BdS
BdS 2019년 3월 20일
Dear all,
My issue:
  • I have got a date vector with portfolio rebalancing dates. As the time goes by, the vector length increases as one rebalances. The rebalance frequency is unknown.
  • There is also a time table with rankings for each member in the portfolio for a certain period (daily rankings).
For each day I need the rankings from the time table mentioned above in order to compute the daily returns to another matrix (nDates,nAssets). However, the rankings stay unchanged from rebalance date to rebalance date.
I can use a if statement like this:
If ReturnDate>= first rebalance date OR < second rebalance date
do operation which consists of getting the rankings
elseif ReturnDate>= second rebalance Date OR > third rebalance date
do operation which consists of getting other rankings
The code continues… However, as the number of rebalance dates increases the elseif statements increases and the code as well. It gets inefficient and by each rebalance date I need to change the code.
Is there any other alternative instead of increasing the number of conditions?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by