Financial Machine Learning: Strategy Risk - Probability of Strategy Failure
The parameters that can be determined in an investment strategy are the profit/loss thresholds $${[\pi_-, \pi_+]}$$ and the bet frequency, while the accuracy $${p}$$ of whether the strategy should invest is influenced by the market and becomes a random variable $${E[p]}$$. If we define $${p_{\theta^\ast}}$$ as the value of $${p}$$ that falls below the target annualized Sharpe ratio $${\theta^\ast}$$, then $${p_{\theta^\ast}=\max\{p | \theta \le \theta^\ast\}}$$.
Let $${\theta^\ast=0}$$ and use the asymmetric payout formula from the previous article.
Since $${n}$$ drops out of the formula when $${\theta=0}$$, if $${\pi_-=-0.01, \pi_+=0.015}$$, then $${p_{\theta^\ast=0}=2/3}$$ regardless of the bet frequency. This is a strategy that requires a fairly high accuracy rate, and if $${p<p_{\theta^\ast=0}}$$, the Sharpe ratio becomes negative and the investment fails. Therefore, this way of setting the upper and lower limits can be said to be a high-risk strategy.
We express the probability of this strategy failing as $${P[p \le p_{\theta^\ast=0}]}$$.
$${P[p \le p_{\theta^\ast=0}]}$$ can be calculated using the following algorithm.
Calculate the expected value of losses and the expected value of profits from the time series of bet results $${{\{\pi_t\},t=1,\cdots, T}}$$.
$${\pi_-=E[\{\pi_t| \pi_t \lt 0 \},t=1,\cdots, T]}$$
$${\pi_+=E[\{\pi_t| \pi_t \gt 0 \},t=1,\cdots, T]}$$
This can also be obtained by fitting a mixture distribution consisting of two Gaussian distributions.
Convert the annual frequency from $${t=1}$$ to $${t=T}$$ to an annual basis as $${n=T/y}$$.
Determine the distribution of $${p}$$ using bootstrapping.
Let $${k}$$ be the number of years to evaluate the strategy,
For iterations $${i=1,\cdots, I}$$, resample $${nk}$$ samples with replacement from $${{\{\pi_t\},t=1,\cdots, T}}$$ and let them be $${{\{\pi_j^{(i)}\},j=1,\cdots, \lfloor nk \rfloor}}$$.
Let the accuracy from a certain $${i}$$ be $${p_i=\displaystyle{\frac{1}{\lfloor nk \rfloor} \parallel \{\pi_j^{i}| \pi_j^{i} > 0 \},j=1,\cdots,\lfloor nk \rfloor \parallel }}$$.
Apply Kernel Density Estimation (KDE) to this $${{\{p_i\}i=1,\cdots I}}$$ to obtain the probability density function (PDF) of $${p}$$ as an approximation $${f[p]}$$.
When $${k}$$ is sufficiently large, the probability density function $${f[p]}$$ can be approximated by a normal distribution
$${\mathcal{N}[\bar{p},\bar{p}(1-\bar{p})]}$$ with mean $${{\displaystyle{\bar{p}=E[p]=\frac{1}{T}\parallel \{\pi_t^{i}| \pi_t^{i} > 0 ,t=1,\cdots,T \} \parallel }}}$$ and variance $${{\bar{p}(1-\bar{p})}}$$.
Here, using $${p_{\theta^\ast}}$$ from the threshold Sharpe ratio $${\theta^\ast}$$, it is calculated as $${P[p < p_{\theta^\ast}]=\displaystyle{\int^{p_{\theta^\ast}}_{-\infty} f[p]dp }}$$.
The implementation of this algorithm is given in Snippet 15.5.
def mixGaussians(mu1, mu2, sigma1, sigma2, prob1, nObs):
ret1 = np.random.normal(mu1, sigma1, size=int(nObs * prob1))
ret2 = np.random.normal(mu2, sigma2, size=nObs - ret1.shape[0])
ret = np.append(ret1, ret2, axis=0)
np.random.shuffle(ret)
return ret
def probFailure(ret, freq, tSR):
import scipy.stats as ss
rPos, rNeg = ret[ret > 0].mean(), ret[ret <= 0].mean()
p = ret[ret > 0].shape[0] / float(ret.shape[0])
thresP = binHR([rNeg, rPos], freq, tSR)
risk = ss.norm.cdf(thresP, p, p * (1 - p)) # approximation to bootstrap
return risk
mu1, mu2, sigma1, sigma2, prob1, nObs=0.05, -.1, .05, .1, .75, 2600
tSR,freq=2., 260
ret=mixGaussians(mu1,mu2,sigma1,sigma2,prob1,nObs)
probF=probFailure(ret,freq,tSR)
probFmixGaussians adds two Gaussian distributions to create test data.
In general, a strategy where $${P[p<p_{\theta^\ast}] > 0.05}$$ is considered too risky and is not adopted because there is a possibility of failure over a long investment period, even when investing in low-volatility securities.
