- 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?