Asset Performance Metrics Calculations
This is the comparison of two assets over approximately a year. It comes from an actual trade. I thought IHAK (cybersecurity ETF) will outperform the benchmark index (NASDAQ) based on my non-qauntitative industry analysis. This is the basic performance metrics during the actual trading period.
As always, import the libraries:
from yahoo_fin.stock_info import get_data
import pandas as pd
import numpy as np
import scipy.stats
Get data:
start_date = "10/12/2020"
end_date = "14/11/2021"
IHAK = get_data('IHAK', start_date, end_date, index_as_date = True, interval = "1d")
QQQ = get_data('QQQ', start_date, end_date, index_as_date = True, interval = "1d")
Calculate metrics:
IHAK['IHAK_return'] = IHAK['adjclose'].pct_change()
QQQ['QQQ_return'] = QQQ['adjclose'].pct_change()
IHAK_mean = IHAK['IHAK_return'].mean()*252
QQQ_mean = QQQ['QQQ_return'].mean()*2552
IHAK_std = IHAK['IHAK_return'].std()*np.sqrt(252)
QQQ_std = QQQ['QQQ_return'].std()*np.sqrt(252)
IHAK_neg_std = IHAK['IHAK_return'][IHAK['IHAK_return']<0].std()*np.sqrt(252)
QQQ_neg_std = QQQ['QQQ_return'][QQQ['QQQ_return']<0].std()*np.sqrt(252)
IHAK_sharp = IHAK_mean/IHAK_std
QQQ_sharp = QQQ_mean/QQQ_std
IHAK_sortino = IHAK_mean/IHAK_neg_std
QQQ_sortino = QQQ_mean/QQQ_neg_std
IHAK_cumprod = (IHAK['IHAK_return'] + 1).cumprod()
IHAK_peak = IHAK_cumprod.expanding(min_periods=1).max()
IHAK_dd = (IHAK_cumprod/IHAK_peak)-1
IHAK_max_dd = IHAK_dd.min()
QQQ_cumprod = (QQQ['QQQ_return'] + 1).cumprod()
QQQ_peak = QQQ_cumprod.expanding(min_periods=1).max()
QQQ_dd = (QQQ_cumprod/QQQ_peak)-1
QQQ_max_dd = QQQ_dd.min()
corr = scipy.stats.pearsonr(IHAK['IHAK_return'].dropna(), QQQ['QQQ_return'].dropna())
ihak_beta = IHAK_std / QQQ_std * corr[0]
This is the result metrics:
IHAK QQQ
Return Avg 0.33 2.94
Return Std 0.21 0.18
Sharpe 1.57 16.10
Sortino 2.45 21.50
Beta: 0.83
Note that although beta is 0.8, the standard deviation of etf is higher than the index.
Check beta calculations article for more detais on beta.