<jupyter_start><jupyter_text>Skewness$$ S(R) = \frac{E[  (R-E(R))^3  ]}{\sigma_R^3} $$<jupyter_code>erk.skewness(hfi).sort_values()
scipy.stats.skew(hfi)
normal_rets = np.random.normal(0, 0.15, size=(263, 1))
erk.skewness(normal_rets)<jupyter_output><empty_output><jupyter_text>Kurtosis$$ S(R) = \frac{E[  (R-E(R))^4  ]}{\sigma_R^4} $$<jupyter_code>erk.kurtosis(normal_rets)
erk.kurtosis(hfi)
scipy.stats.kurtosis(normal_rets) # Returns EXCESS kurtosis (minus 3)

# applying the Jarque-Berra normality test
print(erk.is_normal(normal_rets))
hfi.aggregate(erk.is_normal)    # apply the function to every column and presents the results<jupyter_output>True<jupyter_text>Semi-deviation<jupyter_code>hfi[hfi<0].std(ddof=0)<jupyter_output><empty_output><jupyter_text>VaR and CVaRValue at Risk and Conditional Value at Risk- Historic VaR- Parametric VaR (Gaussian)- Modified Cornish-Fisher VaR<jupyter_code>erk.var_historic(hfi)
erk.var_gaussian(hfi)
erk.var_gaussian(hfi, True)

var_list = [erk.var_gaussian(hfi), erk.var_gaussian(hfi, modified=True), erk.var_historic(hfi)]
comparison = pd.concat(var_list, axis=1)
comparison.columns = ['Gaussian', 'Cornish-Fisher', 'Historic']
comparison.plot.bar(title='Hedge Fund Indices: VaR');<jupyter_output><empty_output><jupyter_text>Beyond VaR: CVaR<jupyter_code>erk.cvar_historic(hfi)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15214180206794684, 'fraction_numerical': 0.011816838995568686, 'mean_word_length': 8.818840579710145, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '525045', 'license': 'MIT', 'n_tokens_mistral': 589, 'n_tokens_neox': 561, 'n_words': 80, 'path': 'deviations_normality.ipynb', 'repo_name': 'dcardonav/finance_python', 'size': '1354'}