Alternative for an increasing number of conditions in if-statements
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Portfolio Optimization and Asset Allocation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!