Ga-Mssr: Genetic Algorithm Maximizing Sharpe and Sterling Ratio Method For Robotrading
Ga-Mssr: Genetic Algorithm Maximizing Sharpe and Sterling Ratio Method For Robotrading
Abstract— Foreign exchange is the largest financial market in Memory (LSTM) is the state-of-art sequence learning network
the world, and it is also one of the most volatile markets. Technical to forecast the stock price [2], and it could also be used to
analysis plays an important role in the forex market and trading identify some common patterns in traded stocks as proposed by
algorithms are designed utilizing machine learning techniques. Fischer et al. [3]. Multi-task recurrent neural networks were used
Most literature used historical price information and technical for stock price forecasting [4] which had better performance
indicators for training. However, the noisy nature of the market than LSTM on selected datasets. Selvin et al. [5] compared
affects the consistency and profitability of the algorithms. To Convolutional Neural Networks (CNN) and LSTM
address this problem, we designed trading rule features that are architectures for predicting the stock price. Zeng and Khushi
derived from technical indicators and trading rules. The
combined wavelet denoising and Attention-based RNN-
parameters of technical indicators are optimized to maximize
trading performance. We also proposed a novel cost function that
ARIMA Model to predict USDJPY prices [6]. Bao et al. [7] used
computes the risk-adjusted return, Sharpe and Sterling Ratio stacked autoencoder to extract high-level features of the price
(SSR), in an effort to reduce the variance and the magnitude of pattern for next day close price prediction. Gao [8] used LSTM
drawdowns. An automatic robotic trading (RoboTrading) and hourly stock prices to predict the trend. Support Vector
strategy is designed with the proposed Genetic Algorithm Regressor is another common approach used for stock price
Maximizing Sharpe and Sterling Ratio model (GA-MSSR) model. prediction [9]. A combination of statistical models and deep
The experiment was conducted on intraday data of 6 major learning models was proved to perform well on short term trend
currency pairs from 2018 to 2019. The results consistently showed forecasting [10]. Zhang et al. [11] implemented a novel network,
significant positive returns and the performance of the trading State Frequency Memory (SFM) to capture the multi-frequency
system is superior using the optimized rule-based features. The trading patterns by utilizing Fourier Transform. However,
highest return obtained was 320% annually using 5-minute simply predicting the next day price is not enough to consistently
AUDUSD currency pair. Besides, the proposed model achieves the make profits unless the prediction is accurate enough when
best performance on risk factors, including maximum drawdowns predicting multiple timesteps. To the best of our knowledge, a
and variance in return, comparing to benchmark models. The model with such adequate predictive power in the foreign
code can be accessed at https://github.com/zzzac/rule-based-forex- exchange market has not been found.
trading-system
CNN was also commonly used for classification tasks to
Keywords—feature engineering, technical analysis, genetic identify the historical patterns on the chart and classify the trend.
algorithm, machine learning Tsai [12] classified the market into uptrend, sideways and
downtrend and used CNN to classify the trend direction. The
I. INTRODUCTION accuracy they achieved was not ideal possibly because of the
Foreign exchange, abbreviated as forex, is the largest lack of training data. Kusuma et al. [13] claimed they achieved
financial market in the world with over $5 trillion dollars 90% bi-directional accuracy using CNN with candlestick charts
transactions each day and it runs continuously from Monday to on a small dataset. Sezer et al. [14] combined 15 technical
Friday, 24 hours a day. Forex is the most liquid financial market indicators in 15 timesteps into 2-D images and used CNN for
where little transaction fees are applied depending on brokers. classification. The model outperformed LSTM, MLP over a
The role of technical analysis had long been regarded as more long period. The classification problem approach presents more
than important in the field of foreign exchange [1]. It is widely value comparing to time series prediction problem since it would
believed that the pattern of price movement would repeat itself. give signals when the trend changes. Nevertheless, the high
Many algorithms are based on technical indicators with volatility nature of the forex market sets a high barrier for
carefully selected parameters according to professional machine learning models to outperform professional traders. A
experience. complete trading system needs to consider both prediction and
risk management to maximize performance.
Many papers focused on the time series prediction problem.
Under the growing influence of artificial intelligence, deep There are a few attempts to design an intelligent trading
learning techniques were used to predict future price movements system that focus on strategies that optimize the overall trading
with carefully designed neural networks. Long Short-Term performance. The applicability and efficiency of genetic
algorithm in portfolio optimization was illustrated by Sefiane, et ratio measures the risk-adjusted return that attempt to address
al. [15]. Mendes et al. [16] proposed a trading system using the deficiency of the original ratios. We also propose a
genetic algorithm and technical indicators to maximize the RoboTrading system, the Genetic Algorithm Maximizing SSR
Stirling ratio but the performance on testing data struggle to (GA-MSSR) model to build a trading strategy with trading rule
make profits. Ozturk et al. [17] used heuristic based trading rules features.
together with genetic algorithm which showed genetic algorithm
could be used to select the best trading rules. Evans et al. [18]
introduced decision making model using artificial neural
networks and genetic algorithms and achieved 23.3%
annualized net return. Maknickienė et al. [19] used LSTM-based
neural networks with genetic algorithm as learning algorithm
which resulted in significant increase of the reliability of
prediction. Pawel et al. [20] developed decision trees using
evolutionary algorithms and technical indicators to identify buy
or sell signals. Rodrigo et al. [21] showed that genetic algorithm
could also be used to optimize the parameters in technical
indicators used for SVR+GHSOM model based trading system
and the results outperformed the market. Bernardo et al. [22]
categorized the market into three different types and used a
hybrid system with SVM and genetic algorithm to classify the
trend. The claimed annualized return is 83% with high leverage.
Genetic algorithm is an example of an evolutionary computation
method, which is capable of finding the near-global optimal
solution of a non-linear non-convex function without getting Fig. 1. Overview of the workflow
trapped in local minima[23]. Petropoulos et al. [24] proposed
using correlations between currency pairs as additional trading
II. PROPOSED METHODOLOGY
signals which were aggregated using the genetic algorithm and
constrained optimization methods. The results showed claimed A. Overview of process
17% annualized return with low leverage. The overall workflow of the forex trading system proposed
Technical indicators could reveal underlying information in this paper is demonstrated in Fig. 2. The trading system starts
regarding the historical price movements. Hence, it is widely with historical data feed and generates technical indicators using
used for algorithm trading. However, given there are thousands historical open, high, low and close prices. Feature engineering
of indicators do not always work since it is publicly available to using trading rules are computed and the parameters for the rule-
everyone. The study attempts to design feature engineering based features optimized using a cost function that computes the
process using trading rules, which are combinations of technical risk-adjusted return. The new features are fed to the genetic
indicators. The features utilize crossover rules to models the algorithm module to compute the weighting of the features that
relationship between technical indicators. The parameters for maximize the overall risk-adjusted return using the designed
the technical indicators are selected using optimization methods cost function.
with a focus on trading performance. B. Technical indicators
It is noted that many of the research papers only included Technical indicators are defined to represent the higher-level
annualized returns in their results. However, in any financial interpretation of past price movements. Each technical indicator
market, risk management is the crucial factor to successful and is computed from the open, high, low and close prices with user-
consistent returns. According to Capital Market Line (CML) defined parameters. Three types of technical indicators are
theory, the excess return and the standard deviation of the return introduced.
should be proportional as in Fig. 1 and the slope of the curve is
also called the Sharpe ratio. Ideally, the best strategy is the one 1) Trend indicators
with the highest Sharpe ratio because it will have the highest a) Moving average
expected return at a given risk level. Given the high volatility of b) Exponential moving average
forex market, the unexpected drawdown should also be
c) Double exponential moving average
considered. Some papers focused on the risk-adjusted returns
using the Sharpe ratio or the Sterling ratio. Sharpe ratio d) Triple exponential moving average
penalizes negative returns less when the average return is e) Vortex indicators
generally low, and it would also penalize occasional high 2) Momentum indicators
returns. Sterling ratio penalizes the maximum drawdown which
a) Relative strength index
could be experienced when market changes suddenly and
unexpectedly, which is very common in forex market. b) Stochastic oscillators
3) Volatility indicators
Due to the above deficiency of the performance measure, we
propose a novel ratio which is essentially a combination of a) Bollinger bands
modified Sharpe Ratio and Stirling Ratio (SSR). The proposed b) Ichimoku indicators
c) Keltner channel
D. Sharpe and Stirling ratio (SSR) Algorithm 1 Grid search parameter optimization
For optimisation of the trading rule parameters, the scoring START
algorithm and assumptions need to be stated. The metric used to
compare the performance of each trading rule when applied to Setup trading rule functions
the training dataset. Without taking transaction costs into Initialize parameter list for each rule
consideration, the currency pair is assumed to be purchased or
sold at the close price of the latest candle. The overall return For each rule do
could be calculated as in (5) (6).
For each parameter in parameter list do
= × ( / ) (5)
Compute the SS ratio over data with parameter
TABLE I. PERFORMANCE OF 6 MAJOR CURRENCY PAIRS ON 2019 5-MINUTE DATA WITH NO LEVERAGE
REFERENCES
[1] M. P. Taylor and H. Allen, "The use of technical analysis in the
foreign exchange market," Journal of international Money and
Finance, vol. 11, no. 3, pp. 304-314, 1992.
[2] M. Roondiwala, H. Patel, and S. Varma, "Predicting stock prices
using LSTM," International Journal of Science and Research
(IJSR), vol. 6, no. 4, pp. 1754-1756, 2017.
[3] T. Fischer and C. Krauss, "Deep learning with long short-term
memory networks for financial market predictions," European
Journal of Operational Research, vol. 270, no. 2, pp. 654-669,
2018.
[4] C. Li, D. Song, and D. Tao, "Multi-task recurrent neural networks
Fig. 8. Testing results accumulated return over time (2019) for all pairs tested and higher-order Markov random fields for stock price movement
with 1:20 leverage. prediction: Multi-task RNN and higer-order MRFs for stock price
classification," in Proceedings of the 25th ACM SIGKDD
International Conference on Knowledge Discovery & Data Mining, [19] N. Maknickienė and A. Maknickas, "Application of neural network
2019, pp. 1141-1151. for forecasting of exchange rates and forex trading," in The 7th
[5] S. Selvin, R. Vinayakumar, E. Gopalakrishnan, V. K. Menon, and international scientific conference" Business and Management,
K. Soman, "Stock price prediction using LSTM, RNN and CNN- 2012, pp. 10-11.
sliding window model," in 2017 international conference on [20] P. B. Myszkowski and A. Bicz, "Evolutionary algorithm in forex
advances in computing, communications and informatics (icacci), trade strategy generation," in Proceedings of the International
2017: IEEE, pp. 1643-1647. Multiconference on Computer Science and Information Technology,
[6] Z. Zeng and M. Khushi, "Wavelet Denoising and Attention-based 2010: IEEE, pp. 81-88.
RNN-ARIMA Model to Predict Forex Price," in 2020 International [21] R. F. de Brito and A. L. Oliveira, "Comparative study of FOREX
Joint Conference on Neural Networks (IJCNN), 19-24 July 2020. trading systems built with SVR+ GHSOM and genetic algorithms
[7] W. Bao, J. Yue, and Y. Rao, "A deep learning framework for optimization of technical indicators," in 2012 IEEE 24th
financial time series using stacked autoencoders and long-short term international conference on tools with artificial intelligence, 2012,
memory," PloS one, vol. 12, no. 7, 2017. vol. 1: IEEE, pp. 351-358.
[8] Q. Gao, "Stock market forecasting using recurrent neural network," [22] B. J. de Almeida, R. F. Neves, and N. Horta, "Combining Support
University of Missouri--Columbia, 2016. Vector Machine with Genetic Algorithms to optimize investments
[9] B. M. Henrique, V. A. Sobreiro, and H. Kimura, "Stock price in Forex markets with high leverage," Applied Soft Computing, vol.
prediction using support vector regression on daily and up to the 64, pp. 596-613, 2018.
minute prices," The Journal of finance and data science, vol. 4, no. [23] D. Pradeepkumar and V. Ravi, "Soft computing hybrids for FOREX
3, pp. 183-201, 2018. rate prediction: A comprehensive review," Computers &
[10] H. Weerathunga and A. Silva, "DRNN-ARIMA Approach to Short- Operations Research, vol. 99, pp. 262-284, 2018.
term Trend Forecasting in Forex Market," in 2018 18th [24] A. Petropoulos, S. P. Chatzis, V. Siakoulis, and N. Vlachogiannakis,
International Conference on Advances in ICT for Emerging Regions "A stacked generalization system for automated FOREX portfolio
(ICTer), 2018: IEEE, pp. 287-293. trading," Expert Syst. Appl., vol. 90, no. C, pp. 290-302, 2017, doi:
[11] L. Zhang, C. Aggarwal, and G.-J. Qi, "Stock price prediction via 10.1016/j.eswa.2017.08.011.
discovering multi-frequency trading patterns," in Proceedings of the [25] T. L. Meng and M. Khushi, "Reinforcement Learning in Financial
23rd ACM SIGKDD international conference on knowledge Markets," Data, vol. 4, no. 3, 2019.
discovery and data mining, 2017, pp. 2141-2149.
[12] Y.-C. Tsai, J.-H. Chen, and J.-J. Wang, "Predict forex trend via
convolutional neural networks," Journal of Intelligent Systems,
2018.
[13] R. M. I. Kusuma, T.-T. Ho, W.-C. Kao, Y.-Y. Ou, and K.-L. Hua,
"Using Deep Learning Neural Networks and Candlestick Chart
Representation to Predict Stock Market," arXiv preprint
arXiv:1903.12258, 2019.
[14] O. B. Sezer and A. M. Ozbayoglu, "Algorithmic financial trading
with deep convolutional neural networks: Time series to image
conversion approach," Applied Soft Computing, vol. 70, pp. 525-
538, 2018.
[15] S. Sefiane and M. Benbouziane, "Portfolio selection using genetic
algorithm," 2012.
[16] L. Mendes, P. Godinho, and J. Dias, "A Forex trading system based
on a genetic algorithm," Journal of Heuristics, vol. 18, no. 4, pp.
627-656, 2012.
[17] M. Ozturk, I. H. Toroslu, and G. Fidan, "Heuristic based trading
system on Forex data using technical indicator rules," Applied Soft
Computing, vol. 43, pp. 170-186, 2016.
[18] C. Evans, K. Pappas, and F. Xhafa, "Utilizing artificial neural
networks and genetic algorithms to build an algo-trading model for
intra-day foreign exchange speculation," Mathematical and
Computer Modelling, vol. 58, no. 5-6, pp. 1249-1266, 2013.