Uploaded by rahulvpai81864

CapitalAndRiskManagement

advertisement
See discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/325323999
CAPITAL AND RISK MANAGEMENT FOR AUTOMATED TRADING SYSTEMS
Conference Paper · May 2018
CITATIONS
READS
19
5,809
1 author:
Cristian Mihail Păuna
53 PUBLICATIONS 145 CITATIONS
SEE PROFILE
All content following this page was uploaded by Cristian Mihail Păuna on 23 May 2018.
The user has requested enhancement of the downloaded file.
Proceedings of the IE 2018 International Conference
www.conferenceie.ase.ro
CAPITAL AND RISK MANAGEMENT FOR
AUTOMATED TRADING SYSTEMS.
Cristian Păuna
Economic Informatics Doctoral School - Academy of Economic Studies
cristian.pauna@ie.ase.ro
Abstract. The most important part in the design and implementation process of automated
trading systems in any financial investment company is the capital and risk management
solution. Starting from the principle that the trading system must run fully automated, the
design process gets several particular aspects. The global stop loss is a special approach for
the risk management strategy that will ensures a positive expectancy in algorithmic trading.
A case study based on an already optimized trading algorithm will be used to reveal how
important the risk level optimization is, in order to improve the efficiency of the trading
software. The main optimal criteria are as usual the profit maximization together with the
minimization of the allocated risk, but these two requirements are not enough in this case.
This paper will reveal an additional optimization criterion and the main directions to build a
reliable solution for an automated capital and risk management procedure.
Keywords: automated trading software (ATS), business intelligence systems (BIS), capital
and risk management (CRM), algorithmic trading (AT), high frequency trading (HFT).
JEL classification: M15, O16, G23
1. Introduction
One of the basic concepts in financial trading is the stop loss. In the common practice, in
order to avoid large losses, traders set a limit price to close the trade when the market is going
in the wrong direction. In the context of a price volatility higher and higher every day in the
financial markets, "Stops Hurt" [1]. The study demonstrates that trading without a stop loss
makes the same return like the trading with a 50% stop loss and the efficiency for 1% or 3%
stop loss is three times lower in the stock market. This idea can be confirmed in any volatile
financial market. There are several studies demonstrating that “initial stops degrade long-term
portfolio performance” [2]. In addition, the measure of the stop loss is depending on the
volatility level, “stop losses may be tighter in low-volatility conditions and looser in highvolatility ones” [3]. In the same time, not using a stop loss is definitely not a good idea. In
any volatile trading environment a large loss certainly must to be stopped. There are some
derived questions. How to use the stop loss to ensure a good return and to avoid large losses?
How to place a stop loss to avoid the accidental losses produced by a strong volatile price
movement that is not affecting the main trend? How to remain in the trade when the market is
not stable? How to use a small stop loss to obtain a higher return? And how can be
implemented a stop loss method in AT and HTF in all of these conditions?
This paper tries to answer to all these questions. It will be presented the global stop loss
concept and how this method can be applied for ATS. This article will present why the
classic stop loss cannot be used in AT and especially in HTF and how the global stop loss
method can be applied to build an automated risk management procedure. In this paper is also
included a case study of an already optimized ATS to reveal how important the risk level
optimization is, in order to obtain a good trading efficiency. On the end it will be presented a
mathematical model that can be applied to design an automated capital management
procedure and a code example for this important part of the ATS implemented in a BIS.
Proceedings of the IE 2018 International Conference
www.conferenceie.ase.ro
2. Stop losses and automated trading systems
In AT, especially in HFT a small stop loss cannot be used. A trade with a very small profit
target cannot use a stop loss with the risk to reward ratio higher even than 1:1. It is obvious
that a trade with a target of one pip cannot have a stop loss of one pip. In the same idea, a
trade with a target of ten pips cannot use a stop loss of ten pips. In a case like this the
probability for a losing trade is 50% or even higher in a trading environment with a variable
spread. A different approach must to be used for ATS, especially for the HFT systems where
the purpose is to make a large number of very small trades.
2.1 The classical stop loss
"A pip is typically the smallest increment that any currency pair can move in either direction,
up or down" [4]. In the stock market the definition is the same. The risk to reward ratio
(RRR) is the ratio between the risked pips have been set by the stop loss and the profit target
pips have been set to earn in that trade. Of course the RRR is exactly the ratio between the
money risked and the money made if the price reaches the profit target. Usual the classical
traders are focused on those trading strategies with the RRR higher than one. The general
idea is if we have an equal number of losing and winning trades, a RRR higher than one will
assure a positive edge for the profit. The trading strategy rules will set the stop loss point
depending on the historical market behavior and they set a profit target using a RRR that
must remain higher than one. The basic logic is very good, but the market wants anytime to
go to that target point before to drop to the stop loss? This is a key question and the answer is
obvious: no, there is no guaranty about that. Now come into action the back tests. Each
strategy is tested based on the historical data price movements to check if the algorithm has a
positive profit edge. Surprising, for a RRR higher that one, most of the trading strategies have
no positive expectations, or a very low one, but for values of RRR lower than one many
trading strategies gives a very good return after the optimization process. Keeping the losing
positions and waiting the movement of the large trend it proves to be profitable in a longer
period of time. The reality in AT is that there are too small number of winning trading
strategies with RRR higher than one that can be fully automated. The unpredicted price
volatility in the financial markets pushes the traders to use a higher stop loss without to
ensure a higher target. In this way the classical stop loss method is not working any more for
ATS, a new rule being more and more familiar in trading in the last decade: "Throw out the
notion of only following risk to reward ratios of 2:1 because they are not always realistic" [5].
The explanation comes from the conclusion "what is mathematically optimal is
psychologically impossible" [6], sometimes the best trade can happen only on paper. Another
realistic approach is presented in [6] with the general conclusion that a small target is better
than a larger one, even the RRR is less than one. Much more small winning trades than losing
trades will accumulate an important profit. When the trading strategy is well done optimized,
a very small number of wrong trades will permit an important profit edge when it is counted
in a longer period of time, as we will see further.
2.2 Global stop loss
The global stop loss (GSL) means there is no stop loss set for each trade, it is a general stop
loss set for all trades opened by the trading software, regardless of the number of the open
trades, regardless of the direction of the trade or any other particularity. When all open trades
reached a specified negative amount (which is usually a percentage of the trading capital), the
stop loss is considered to be touched and all that trades are closed or hedged to protect large
losses. Using GSL is a key factor for the positive expectation in AT.
Proceedings of the IE 2018 International Conference
www.conferenceie.ase.ro
For example, for an ATS that is opening many trades with a small profit target, the GSL can
be set at 1% of the capital. In this case the risk will be much higher than the profit made in
every trade. To ensure the profit edge, the CRM procedure will assure that trading volume
which will generate a large number of winning trades and a very small number of losing
trades. Once the risk level has been set, the trade volume is the subject of the optimization
process based on the historical price movement or vice versa. Once the trade volume is
imposed, the risk level can result from the optimization process. A case when a classical stop
loss is used in the typical way in AT is the case of automated investments systems (AIS).
Starting from the idea that "Winning trades should stay winners" [7], moving the stop loss to
the break event is a normal practice in the AIS. The optimization process is adapted for this
case to establish the moment when the classical stop loss is used, but until that moment, the
same approach of a GSL is usual implemented also in AIS. The most important fact remains
the right setup of the risk level and trading volume for each trading strategy to ensure a
significantly higher number of winning trades. In this process the maximization of the profit
will be made together with the minimization of the involved risk, keeping the condition that
the entire risk to be lower than the GSL. When the trading volume is imposed, the GSL level
is the optimization variable with huge impact in the trading efficiency, as we will see below.
3. Global stop loss optimization
Each trading strategy has several parameters that must to be optimized in order to obtain the
best efficiency. Depending on the mathematical model used, each parameter is the subject of
an optimization and machine learning process, based on the historical price data. This process
is not the subject of this paper. Our main objective here is to reveal the importance of the
GSL level and the impact of this parameter for the trading algorithm efficiency in an ATS.
3.1 Comparative global stop loss levels
Using an ATS (TheDaxTrader presented in [8]) already optimized to trade the Frankfurt
Stock Exchange Index (Deutscher Aktienindex - DAX) with its stock components described
in details in [9], we present the next quantitative analyze. The steps involved in this study are
the usual steps in the optimization activity for any ATS based on the historical price data:
A. using the historical stock market price data for DAX between 01.06.2015 and 31.12.2017,
B. using TheDaxTrader algorithm wrote in MQL4 [10],
C. using several trading strategies with functional parameters already optimized,
D. the RRR was varied between 1:5 and 1:50 keeping all other parameters the same,
E. the trading results was recorded for the entire 30 months period of the back tests
F. and the results of the optimization process are presented and explained hereinafter.
The back test optimization of the ATS was made using MT4 Strategy Tester [11] with the
most precise method based on every tick price available in the historical data. The results are
concluded in the "table 1". First two GSL levels can conduct to the conclusion that the
trading strategies used do not have a profit edge. This is a very common situation for a lot of
trading algorithms that have no sense for a low level of the stop loss in a volatile market. Any
inexperienced developer can cancel the research in this case, especially if they are looking
only for strategies with RRR higher than 1:1. Starting with the level of 1:15 for the RRR, the
algorithm starts to show us the potential. As much as the stop loss is higher, the profit is
higher, the number of the losing trades is smaller, and more losing trades are transformed in
winning trades only waiting the market reversal and not closing the trade by the stop loss.
This fact is practically the reality of any stock market, after a fall the market will come back
in a certain period of time. In addition the principle according "it pays to hold position
overnight" [9] is tested and confirmed by the better efficiency obtained using a higher GSL.
Proceedings of the IE 2018 International Conference
www.conferenceie.ase.ro
Table 1. The influence of the global stop loss in the trading efficiency of TheDaxTrader algorithm
RRR
1:5
1:10
1:15
1:20
1:25
1:30
1:35
1:40
1:45
1:50
Winning trades
980
903
892
881
869
867
869
859
859
858
Losing trades
234
89
33
16
13
9
7
5
1
0
Profit ratio
-2.17%
1.98%
9.97%
13.71%
14.07%
14.41%
15.15%
16.01%
18.89%
19.89%
Longest trade
106 hours
110 hours
143 hours
193 hours
209 hours
213 hours
216 hours
228 hours
383 hours
525 hours
Figure 1. Trading efficiency of TheDaxTrader depending on the global stop loss level
A wrong idea deriving from the “table 1” is to use an even higher stop loss to ensure a better
efficiency. Why not to use an even lower RRR than 1:50 for this case? The answer is because
using a larger stop loss, the longest trade period is much higher. The key is to find that level
of GSL to obtain trades shorter than a month. Here comes the third optimization criterion, the
longest time trade period (LTT). A good trading algorithm with the LTT longer than a month
will be a bad case. The allocated capital will be blocked for too long period of time and a lot
of trading opportunities will be lost in that interval and the trading efficiency will decrease.
This third optimization criterion (LTT) changes significantly the design process. In the ATS
usually are kept those strategies with LTT lower than one month. Some good strategies that
will generate longer trades will be excluded from the ATS and will be included in the AIS
based only on the LTT. This factor makes the difference between trading and investment, two
Proceedings of the IE 2018 International Conference
www.conferenceie.ase.ro
different subjects of AT for many financial investment companies. The results in the case
study are made using a trading algorithm with all parameters already optimized to maximize
the profit, to minimize the capital exposure and to minimize the period of the longest trade.
For this study, the only one parameter that has been varied is GSL level. The factors that can
influence the price movement were already included in the optimization process for each
parameter of the trading strategy and for this reason this factors are not treated of this paper.
3.2 Capital management
In the case study presented above, for a RRR equal with 1:45, the algorithm makes 859
profitable trades and only one losing trade. A proper stop loss level will ensure a number of
profitable trades significantly higher than the losses. In this way the GSL ensure a positive
expectancy together with a good optimization for the functional parameters. In the study the
maximum exposure capital was 1%. The algorithm generated 19.89% profit for the best case
in the period of 30 months. This efficiency can be considered a good return, considering a
losing trade of 1% of the capital. Even in the case with more consecutive loss trades, like in
cases with RRR between 1:15 and 1:40, the algorithm has a positive expectancy in a time.
Several quantitative risk methods are presented in [12] and can be used and adapted for the
ATS. To automate the CRM, a connection between the risk level and the traded volume is
needed. This paper will propose a simple method, a model based on the maximal drawdown
(MDD). This is the larger negative price difference between the trade open price and the
lower price during the trade. This price behavior cannot be predicted but it can be measured
testing each trading strategy with the historical price data on a significant interval (30 to 100
months). The MDD is practically the maximum capital lost by that algorithm in a specified
period of time. Knowing the MDD and the available capital (C), the volume (V) for each
open trade can be calculated using the maximal risk level (R) allocated for that trade:
V = C * R / MDD
(1)
The equation (1) will permit to limit the losses to the MDD level in the case when the market
will fall higher than the worst scenario passed in the period of back test. A higher period on
the back test will generate a better optimal solution. The advantages for the presented model
are related with the simplicity of this formula. A very stable CRM procedure can be made. In
addition the information included in the MDD contains the historical behavior or the price.
The other positive fact is that a new market behavior will change only one parameter and this
makes possible a very fast machine learning process to be designed in order to find the new
functional parameter set. A code example for the capital and risk management procedure is:
double MaximalDrawDown=400, RiskLevel=1;
double TradingVolume(){if(MaximalDrawDown<=0) return(0); if(RiskLevel <=0) return(0);
return(AccountBalance()*RiskLevel /100/MaximalDrawDown);}
In the code sequence above, the AccountBalance() is an already defined function of the MT4
trading platform which returns anytime the current capital balance of the trading account. For
that cases when the market makes an unusual movement, when the loss is higher than MDD,
starting from the principle that "losses are a part of trading" [13], the risk R will be accepted
as a loss and all negative trades will be closed. The profit edge is assured by that trading
algorithm optimization solution together with the GSL level solution. Before to conclude, a
very important mention is: presenting the example above, this paper does not affirm that any
trading strategy will work with a 1:50 RRR to trade DAX or other financial markets. For the
trading strategies included in TheDaxTrader algorithm used as an example, which are sixty
Proceedings of the IE 2018 International Conference
www.conferenceie.ase.ro
very special entry trading strategies, the utilization of a large GSL is proper and gives good
and positive profit expectancy. The trading strategies used, the optimization methods applied,
the optimal criteria and how the worst cases are filtered using proper data mining methods
and how the market conditions influence the trading parameters are subjects for later papers.
5. Conclusions
Small stop loss cannot be used with very good returns in AT and HTF. With the proper
optimization, GSL is a reliable solution for ATS even if the RRR is very low. A significant
number of winning trades with a very small number of losing trades will give a positive edge.
The optimization of the functional parameters of the ATS is made to maximize the profit, to
minimize the capital exposure and to reduce the period of the longest trade, in order to
improve the efficiency of the capital usage. The RCM can be automated based on the MDD,
parameter found using the back tests with the historical price data for each financial market.
A longer historical price period will ensure a higher MDD precision. The trade volume is
limited by the GSL. In an unpredicted case when the stop loss level is touched, the loss will
be accepted. Due to the small risk involved, the loss will be recovered in the next period
using trading strategies that make more winning trades than losing trades. After each loss
trade, a real-time machine learning process can generate a new and better set of functional
parameters to increase the algorithm efficiency. ATS and AIS are separated parts of the BIS.
References
[1] L. Connors, C. Alvarez, "Short term trading strategies that work", TradingMarkets
Publishing Group, 2009, ISBN 978-0-9819239-0-1, pp. 31-35.
[2] B. Venstone, “Do initial stop-losses stop losses?”, Bond Business School, Bond
University, 2008, Available: http://epublications.bond.edu.au/infotech_pubs/83, pp. 1.
[3] I. Aldridge, “High-frequency trading: a practical guide to algorithmic strategies and
trading systems”, Wiley, 2013, ISBN 978-1-118-34350-0, pp. 230.
[4] J. M. Bland, J. M. Meisler, M. D. Archer, "Forex essentials in 15 trades", John Wiley &
Sons, Inc., 2009, ISBN 978-0-470-29263-1, pp. 12.
[5] K. Lien, "The little book of Currency trading - how to make big profits in the world of
Forex", John Wiley & Sons, Inc., 2011, ISBN 978-0-470-77035-1, pp. 104.
[6] K. Lien, B. Schlossberg, "High probability trading setups for the currency market",
[online] 2006, Available: https://investopia.com [January 2, 2018], pp. 15-16.
[7] M. Etzkorn, "Guide to conquering the markets", M Gordon Publishing Group, 2000,
ISBN 1-893756-06-8, pp. 146.
[8] TheDaxTrader - Internet: https://pauna.biz/thedaxtrader [March 20, 2018].
[9] Wikipedia - DAX - Internet: https://en.wikipedia.org/wiki/DAX [February 8, 2018].
[10] Meta Quotes Language 4 – Internet: https://www.metatrader4.com/en/automatedtrading/mql4-programming [March 20, 2018].
[11] Meta Trader 4 Strategy Tester – Internet: https://www.metatrader4.com/en/automatedtrading/strategy-tester [March 20, 2018].
[12] A. J. McNeil, R. Frey, P. Embrechts, “Quantitative Risk Management – Concepts,
Techniques and Tools”, Princeton University Press, 2015, ISBN 978-0-691-16627-8
[13] S. Ward, "High performance trading", Harriman House, 2009, ISBN 978-1-905641-611, pp. 137.
View publication stats
Download