If some returns series supplied to calc_inv_vol_weights() are equal to zero, then inverse-volatility will be infinite.
I suggest to remove assets with zero volatility from the portfolio rather than returning a list of zeros (sum of all weights will be also infinite -> individual weights of good assets are equal to zero).
I think the last variant is better: user might expect series of the same structure as the initial dataframe with returns, so dropna() is not good. Also it is consistent with the following situation: if we pass a series of NaN then this weight will be equal to NaN
If some returns series supplied to
calc_inv_vol_weights()
are equal to zero, then inverse-volatility will be infinite.I suggest to remove assets with zero volatility from the portfolio rather than returning a list of zeros (sum of all weights will be also infinite -> individual weights of good assets are equal to zero).
There're three options:
dropna()
here)fillna(0)
here)NaN
for themI think the last variant is better: user might expect series of the same structure as the initial dataframe with returns, so
dropna()
is not good. Also it is consistent with the following situation: if we pass a series ofNaN
then this weight will be equal toNaN