ffn icon indicating copy to clipboard operation
ffn copied to clipboard

Bug: Yearly Kurtosis

Open AnthonyFJGarner opened this issue 5 years ago • 2 comments

Using 849 data points and 1188 calendar days between start and end, an error is thrown in the calculation of yearly kurtosis. A runtime warning is given as shown below. Adding a day of data solves that problem. For some reason a divide by zero error is caused. No doubt I will find the source of the error but I thought I would report it nonetheless.

start: datetime.date = '2001-10-02' end: datetime.date = '2005-01-02' 1188 days 849 data points \lib\site-packages\ffn\core.py:2056: RuntimeWarning: divide by zero encountered in true_divide res = np.divide(er.mean(), std)

start: datetime.date = '2001-10-02' end: datetime.date = '2005-01-03' 1189 days 850 data points No error occurs

AnthonyFJGarner avatar Sep 08 '19 09:09 AnthonyFJGarner

function calc_sortino_ratio may encounter situations that all given returns are positive, makes the std = 0 and thus the divide by zero error.

    negative_returns = np.minimum(returns[1:], 0.)
    std = np.std(negative_returns, ddof=1)
    res = np.divide(er.mean(), std)

yitelee avatar Dec 08 '20 08:12 yitelee

Any update?

keepcosmos avatar Nov 22 '22 11:11 keepcosmos