okama.Portfolio.kstest
- Portfolio.kstest(distr='norm')
Perform one sample Kolmogorov-Smirnov test on portfolio returns and evaluate goodness of fit for a given distribution.
The one-sample Kolmogorov-Smirnov test compares the rate of return time series against a given distribution.
- Parameters:
- distr{‘norm’, ‘lognorm’}, default ‘norm’
The name of a distribution to fit. ‘norm’ - for normal distribution. ‘lognorm’ - for lognormal distribution.
- Returns:
- dict
Kolmogorov-Smirnov test statistics and p-value.
Notes
Like in Jarque-Bera test returns statistic (first row) and p-value (second row). Null hypotesis (two distributions are similar) is not rejected when p-value is high enough. 5% threshold can be used.
Examples
>>> pf = ok.Portfolio(['GLD.US']) >>> pf.kstest(distr='lognorm') {'statistic': 0.05001344986084533, 'p-value': 0.6799422889377373}
>>> pf.kstest(distr='norm') {'statistic': 0.09528000069992831, 'p-value': 0.047761781235967415}
Kolmogorov-Smirnov test shows that GLD rate of return time series fits lognormal distribution better than normal one.