pmorissette / ffn

ffn - a financial function library for Python
pmorissette.github.io/ffn
MIT License
2k stars 297 forks source link

Ulcer Index not according to definiton (miscalculation) #193

Closed huvar closed 1 year ago

huvar commented 1 year ago

According to definition the ulcer index is calculated as the root square of the mean of squared drawdowns. However in the code the calculation being done is different. The squared drawdowns are being summed and square root is being performed and only then it is being divided by the count.

return np.divide(np.sqrt(np.sum(np.power(dd, 2))), dd.count())

https://github.com/pmorissette/ffn/blob/16aefe6cf05227b135583f16cfdd757407b50205/ffn/core.py#L2425