Algorithmic Financial Trading Using Optimization in the Julia Programming Language
Date
Authors
Journal Title
Journal ISSN
Volume Title
Publisher
Saudi Digital Library
Abstract
The advancements that adaptive control can offer to financial stocks can flourish the wealth of bankers, companies, and individuals. Meanwhile, the Julia programming language has immense capabilities that have not been utilized, yet, in financial trading. The objective of this project is to optimize algorithmic financial trading for maximum monetary return by adopting a model-free method with real-time feedback using the Julia programming language. The developed algorithm uses reinforcement learning (RL) to create a trading environment that optimizes financial trading. In the methodology of this study, the stocks of the past five years for the DJIA index from July, 2016 to July, 2021 were used by training on the first 3.5 years and cross-validating on the last year and a half. This is a substantial period for the study as the first trimester of year 2020 experienced a market drop due to the COVID-19 pandemic; a financial occurrence that has not been witnessed since 1987. The work was initiated by optimizing the neural network infrastructure for financial stock prediction. This was followed by developing the RL trading environment for financial stock trading. The environment was optimized using a derivative-free method in terms of the neural network architecture, the hyperparameters, the training period, and the trading frequency. By using the DJIA index as a benchmark during the same period of training and validation, the maximum return acquired using the DDPG algorithm for RL training was an increase of 62.99% in the portfolio value of the validation data, while the benchmark had a mere 20.40% increase. Moreover, by applying algorithmic trading, the aforementioned market crash effect was reduced by 71.26% resulting in risk aversion and maximum profit. It was concluded that the optimal setting was to use a two-layer simple deep neural network with 30 neurons per layer, training for one previous year, and trading daily. Following that setting, the resulting optimized algorithmic trading strategy delivered significant increase in the portfolio value.