<jupyter_start><jupyter_text>Downside<jupyter_code>import pandas as pd
import risk_tools as rt

%load_ext autoreload
%autoreload 2
%matplotlib inline

hfi = rt.get_hfi_returns()<jupyter_output><empty_output><jupyter_text>Semideviation<jupyter_code>hfi.std(ddof=0)
hfi[hfi<0].std(ddof=0)
rt.semideviation(hfi)<jupyter_output><empty_output><jupyter_text>VaR or CVaRValue at Risk- Historic VaR- Parametric VaR - Gaussian- Modified Cornish-Fisher VaR<jupyter_code>import numpy as np

np.percentile(hfi, 5,axis=0)
rt.var_historic(hfi, 5)
from scipy.stats import norm
z = norm.ppf(.05)
z
rt.var_gaussian(hfi)
var_list = [rt.var_gaussian(hfi), rt.var_gaussian(hfi, modified=True), rt.var_historic(hfi)]
comparison = pd.concat(var_list, axis=1)
comparison.columns = ['Gaussian', 'Cornish-Fisher', 'Historic']

# comparison.head()

comparison.plot.bar(title='Hedge Fund Indices: VaR')<jupyter_output><empty_output><jupyter_text>Beyond VaR aka CVaR<jupyter_code>cvar = rt.cvar_historic(hfi)
cvar.head()

cvar.plot.bar(title='Hedge Fund Indices: CVaR')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13165266106442577, 'fraction_numerical': 0.009337068160597572, 'mean_word_length': 8.486725663716815, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '430931', 'license': 'Apache-2.0', 'n_tokens_mistral': 465, 'n_tokens_neox': 441, 'n_words': 71, 'path': 'risk/lab-6.1.ipynb', 'repo_name': 'deyantodorov/python', 'size': '1071'}