As algorithmic trading becomes increasingly popular, the next question would be, how are risks that are associated with algorithmic trading monitored and controlled? By co-locating the servers with market servers at an exchange or “dark pool” data center, algorithmic traders increase the speed they can get to access the markets. Regardless, I would like to discuss certain types of common risks associated with algorithmic trading and the potential measures to mitigate those risks within algorithmic trading.
Let’s widen the scope and look at two key risks that are commonly related to algorithmic trading and the reasons why it is so important to build strategy that focuses on controlling the risk of trading algorithmically:
But individually we consider risk management is driven primarily by ‘loss aversion’ and our goal is to maximize long-term portfolio profitability by taking as low risk as possible. In consideration of this goal, we could focus on some details such as limiting the drawdown and sourcing/finding the best leverage. Probably surprising to most, I will continue to use the sentiment algorithm as an example to build up the risk management strategy. From previous articles, I have built the trading strategy to forecast the stock prices using trend following strategy and sentiment analysis. It just stops by finding the qualified instruments. Next, we need to find out more questions such as the weight for each instrument in our portfolio(if it is applicable), when will we enter and exit the position and see if we should borrow money to invest.
Before I start, the first thing we should consider is how much of our total capital we are willing to put at risk(the amount of trading capital) which will be used to multiply the volatility target percentage for your portfolio. Then you need to decide the potential target %, if your volatility target is relatively high you may need to check your account value frequently and adjust it on daily basis.
The most common way to limit the drawdown is to find an effective stop loss. The common usage is to use the stop loss to exit an existing position whenever its unrealized P&L drops below a threshold. Bear in mind that it is important to set a proper stop loss criteria since if it is too high(means there is only a small space for the stock price to move) you probably will end up losing the profitable opportunity in the end by selling the instruments earlier. Also, if stops are set very tight then you’ll have short holding periods and high turnover.
If you are using mean reversion strategies, setting up stop loss probably will lower your portfolio’s performance. As we know, the mean reversion strategy would suggest us to BUY since we should expect the prices to rise eventually. Stop loss would have the opposite reaction, if stock prices keep dropping we are supposed to exit the positions based on the stop loss we set up. Then we probably will miss the opportunity for them to go up again, unless a mean-reverting price series undergos a regime change and becomes a trend following price series for an extended period of time. A stop loss will be effective in preventing catastrophic losses. Thus, a stop loss would be very helpful if we are using the momentum models.
Another most common way is to set up the right amount of leverage for your portfolio(you can define it as the size of your portfolio divided by your trading capital) in order to maximize the future long-term equity or portfolio growth rate. Here is one popular rule: Kelly criterion/formula to help us quantify the leverage to suit this goal.
Kelly criterion says: f should equal the expected excess return of the strategy divided by the expected variance(s) of the excess return (m-r), or
f = (m-r)/s2
(The excess return being the return m minus the risk-free rate r.)
But in reality, Kelly’s optimal leverage calculated from the historical data would never be accurate and it is very dangerous if you overestimate leverage. The half-Kelly leverage is preferred in this case. If you are curious about the benefits of Kelly criterion.
Kelly criterion requires you to sell into a loss (assuming you have a long-only portfolio here) and buys into a profit — something that requires steely discipline to achieve.
However, for traders who care more about the Sharpe ratio, not growth rate, because they want to be sure to redeem their shares at any time then, Kelly criterion is not for such investors. If you adopt the Kelly criterion, there may be long periods of drawdown, highly volatile returns, low Sharpe ratio, and so forth. The only thing that Kelly guarantees (to an exponentially high degree of certainty), is that you will maximize the growth potential of your strategy in the long run, and you will not be bankrupt in the interim because of the inevitable short-term market fluctuations.
The prerequisite for Kelly formula is that the returns follow a normal distribution. However, this Gaussian assumption is rarely true in reality. We probably should consider substituting another analytic form for the returns distribution to take into account the fat tails. We can use the Pearson system which will take the input: mean, standard deviation, skewness, and kurtosis of the empirical distribution of returns into account. In order to avoid data-snooping bias, we could use Pearson system for Monte Carlo sampling/simulation. The advantage of using simulated returns is that they have much better statistical significance — which are akin to the value-at-risk(VaR) methodology(that I will explain later) used by major banks and hedge funds to determine the likelihood that they will lose a certain amount of money over a certain period of time. But this method has its own weaknesses, the simulated maximum drawdown may be so rare that it possibly won’t happen in practice/reality; as for simulated returns would inevitably miss some vital serial correlations that may be shown in the historical returns and that may persist into the future.
As for the changes that I made for my algo is as below:
Moreover, here are some small tips to lower your strategy’s risk. First, you should avoid risky period once you detected by using possible leading indicators of risk such as VIX, TED spread or HYG, which means you should not avoid trading or setting leverage close to 0 during times of increased volatility such as central bank announcements or significant macroeconomic numbers. But you should also be careful of data-snooping bias( caused by having too many free parameters that are fitted to random ethereal market patterns in the past to make historical performance look good and in order to avoid this risk we should test the model on out-of-sample data and reject a model that doesn’t pass the out-of-sample test; make the model as simple as possible means with as few parameters as possible) when we try to decide whether an indicator is useful. Furthermore, the large change in order flow in the market is negative if the asset in question is risky — order flow is a short-term indicator of future price change.
Also, we should always keep in mind that to update the prices and stock information in order to limit the leverage and loss as you expected. However when opening new positions you should use the most up-to-date estimate of volatility to work out your initial trade size.
Besides, I would also like to introduce the most common way to estimate the risk of loss to an algorithmic trading strategy or portfolio of strategies which is known as VaR(Value at Risk). VaR provides an estimate, under a given degree of confidence, of the size of a loss from a portfolio over a given time period and it is measured by three variables: the amount of potential loss, the probability of that amount of loss, and the time frame.(to put this concept simple, it is designed to simply answer: what is the worst expected amount of loss, given a specific probability level,(i.e. 95%) over a certain period of time?
The following graph shows the statistical mechanism for VaR test. It illustrates a normally distributed portfolio returns with a mean of 0 percent, where VaR is the loss corresponding to 95th percentile of the distribution of portfolio returns:
Let’s assume for a portfolio, the daily volatility of the portfolio is σ and daily expected return is
and the risk level of α:
P is the value of the portfolio,
is the inverse normal probability distribution.
Every time we use the statistic basic principle to estimate we need to understand the underlying assumptions behind the concept. As for the standard calculation of VaR we assume:
Basically, the VaR is a straightforward way to calculate risk for an individual asset, algo strategies, trading portfolio, hedge funds or even bank prop desks; we can adjust the testing time frame for multiple trading strategies; we can also adjust the values of VaR associated with different forms of risks. However, as I mentioned (at the beginning of the statistical assumptions for the VaR), the use of VaR is not without its flaws. It does not take into account the probability of the loss for extreme events happening on the far ends of the tails on the normal distribution curve; and it is based on historical data which may ignore the future market regime shifts into account.
I have live-trading this new algorithm for last few days to test its feasibility. It turns out working very well so far.
I will explain more about the application of different risk management measures and how to check your account on a daily basis and what adjustment should we take to keep the risk under control in my next articles.
I hope this article would help and hope you enjoy the content. Feel free to leave your ideas or comments here. Thank you!