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:

- algorithmic trading may face a significant amount of risk intraday and without robust controls — internal controls cannot keep pace and market complexity not to mention technology failures etc — without the adequate amount of controls the losses can accumulate and spread rapidly;
- systemic risk may be amplified — caused by sizable impact on the financial market through direct errors or the reactions of other algorithms to the errors — it requires investment firms be able to automatically block or cancel orders where they risk compromising the firm’s own risk management thresholds.

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.

- Besides helping you to avoid bankruptcy, the Kelly criterion has been proved that if Gaussian assumption is a good approximation, then the Kelly leverage f will generate the highest compounded growth rate of equity.
- It is important to be aware that the Kelly Criterion requires a continuous rebalancing of capital allocation in order to remain valid.

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.

- But for all the cases, we assume that the future probability distribution of returns is as same as in the past.
- No matter how the optimal leverage is determined, the one central theme is that the leverage should be kept constant. This is necessary to optimize the growth rate whether or not we have the maximum drawdown constraint. Keeping a constant leverage may sound rather mundane, but can be counterintuitive when put into action

As for the changes that I made for my algo is as below:

- I separate my testing period into two parts. One for in-sample adjusting and one for out-of-sample testing. Every adjustment that I did is within the time frame 09/01/2012–03/08/2015 and the final backtest.
- I also include more equities into my portfolio to meet the diversification needs. I extend my BULL and BEAR basket and add 20 equities into each of them.
- As I explained before in my article, my study and the pattern identifying process are serving for the purpose to maximize the confidence of my forecast. In order to keep the forecast as accurate as possible, it is better to make sure that the instruments included in the portfolio have low correlation or you can also build up your weighting system based on their correlation coefficient. I will leave this part for the following articles.
- I set up my goal for risk-adjusted returns(volatility standardized returns) is the minimum level of movement proved by impact score. As we know the definition of impact score is the
**probability that the stock price will change by more than 1% (given by close — open / open) on the next trading day.**The higher the impact score the higher the possibility that the minimum daily movement of stock prices should be at least 1%. If the expected adjusted returns I estimate are 25% per day, so the expected volatility should be at least 4%. Assume we have the original investment is $1,000,000 and this is also our trading capital, then we should be ready for the movement around 4% * $1,000,000 = $40000 of your investment per day. Or you can set up your percentage volatility targte accordingly and find out the cash volatility target. Keep a key on this fluctuation of your portfolio and update the volatility on daily or weekly basis once you detect the abnormal situation. - As I did before, I will still assign the weight to each instrument I am trading based on their back-testing returns performance.
- As for the speed of my trading, in terms of the trading costs, we should set up a relatively secure rebalance frequency. Here I set the rebalancing frequency to be at the beginning of each month. Even though the returns usually go up when the frequency is high, the trading cost will be high too means we will sacrifice our returns for the costs. As for the backtesting returns that we got is just an approximation which has very high possibility to be inaccurate. The cost is more likely to be true. We should consider this fact and keep our trading frequency within a certain range. Relatively, the more expensive instrument tend to perform somewhat better even with high cost but the prerequisite is that the trading turnover has to be controlled around 15 times which means the rebalancing frequency is better to be around once a month.

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:

**Standard Market Conditions**: no extreme event or regime shifts or ‘tail risk’(it does not take into account the probability of the loss for extreme evets happening on the far ends of the tails and it is difficult to estimate the magnitude of the loss beyond the certain VaR level);**Volatilities and Correlations**: VaR requires the volatilities of the assets under consideration based on historical data which are subject continual changes;**Normality of Returns**: assume the returns of the asset or portfolio are normally distributed, even though it is very unrealistic for most assets.

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!

**Reference:**

- https://www.quantstart.com/articles/Money-Management-via-the-Kelly-Criterion
- https://www.quantstart.com/articles/Value-at-Risk-VaR-for-Algorithmic-Trading-Risk-Management-Part-I
- http://www.investopedia.com/terms/l/leverage.asp
- http://www.investopedia.com/terms/s/stop-lossorder.asp?layout=infini&v=4C&adtest=4C
- https://www.ma.utexas.edu/users/mks/statmistakes/datasnooping.html
- http://epchan.blogspot.com/2006/10/how-much-leverage-should-you-use.html
- http://www.investopedia.com/terms/v/var.asp
- http://www.investopedia.com/articles/07/montecarlo.asp
- https://www.ishares.com/us/products/239565/ishares-iboxx-high-yield-corporate-bond-etf
- http://www.investopedia.com/terms/t/tedspread.asp?layout=infini&v=4C&adtest=4C