Conversation
Improved verbose and documented Edit docs
|
why wouldn't you pass a time series of I'm trying to understand what you're getting at here. It seems to me a more common case would be series that start later than the longest series, e.g. ETF's that weren't listed yet, or symbols that are created by a spin-off of a subsidiary or division, or new series of a futures contract. |
|
Thank you very much for your comments. The use case here is as follows: You have a portfolio of a few hundred stocks and you wish to calculate the daily portfolio return for a year or two. You can easily lose 10-20% of the securities to corp actions over this period, on random days. The portfolio is either equal weighted, or rebalanced to a vector of fixed weights on a monthly basis. Therefore you don't have an I completely agree regarding your second comment about adding securities as they become available for trading at later dates. I've also written a prototype of a function that does that and hope to share soon. Thank you. |
Hello, hoping to contribute this new function which wraps Return.portfolio().
Return.portfolio.withdrops() handles cases when the assets have variable-length histories. For example, a security in the portfolio could have a shorter history than others due to M&A or delisting. Currently, Return.portfolio warns and assigns a zero return to such securities with missing returns. This may not always be ideal. This function forces a rebalance when security returns become unavailable, excluding such securities. It splices together spans with all available assets in each period, using Return.portfolio() to calculate returns in each span of complete assets. It returns a complete portfolio return, with all available assets at any time. Welcome any suggestions to improve it.