Articles

Getting Started with AI in Trading: A Beginner

Review recent work of using Machine Learning in Finance.

Forex Market and Trading Approaches

The forex (FX) marketplace is one of the most popular monetary markets for buying and selling currencies because it is the largest financial marketplace inside the global in terms of trading volume [1].
Foreign exchange market refers to the market in which currencies from around the world are traded. It allows investors to buy or sell a currency of their choice [2].

The traditional trading methods can be further divided into the technical analysis and fundamental analysis [3]. Similarly, the modern trading methods can be further divided into algorithmic trading and machine learning (ML) approaches [3].

The traditional financial trading methods are often implemented manually by humans, while the modern methods are executed automatically by computers [3].

Algorithmic trading can be performed by either rule-based methods or ML-based approaches [3].

In recent years, financial trading has seen an increase in participation from automated trading agents. This growth has been driven by financial trading firms using automated strategies that they apply to all suitable markets [4].

Automated trading, which is also known as algorithmic trading, is a method of using a predesigned computer program to submit a large number of trading orders to an exchange [5].

One approach to automated trading is the rule-based algorithmic approaches, such as the technical analysis of the price time series aiming to detect plausible signals that entail certain market movements, thus triggering trading actions that will yield a profit if such movements occur. One step further is the machine learning techniques that automatically determine the patterns that lead to predictable market movement. Such techniques require the construction of supervised labels, from the price time series, which describe the direction of the future price movement [6].

A few authors differentiate the trading decisions (quantitative trading) from the particular trading execution (algorithmic trading) [7].

Quantitative trading strategies are designed to look for relationships between data about an underlying security and its future price and then to generate alpha on a trading desk [8].

Quantitative trading consists of strategies based on quantitative analysis which rely on mathematical computations and number-crunching to identify trading opportunities, in other words, it is a kind of investment management system designed to conduct transactions based on mathematical models and algorithmic technology [8].

For a long time, quantitative human traders have been getting “phased out” due to their inconsistent behavior and, consequently, performance [6].

As a new kind of investment analysis idea which combines modem mathematics and financial data, quantitative trading is playing an active and significant role in financial markets all over the world [8].

Algorithmic trading is a branch of quantitative investment, refers to the use of quantitative analysis method to execute actions automatically according to the algorithm model and achieve asset trading without manual intervention [9].

High-Frequency Trading

High-frequency trading refers to a type of algorithmic trade in financial instruments with a very high speed. To capture fleeting liquidity imbalances and pricing inefficiencies, HFT strategies are generally designed based on statistical arbitrage, liquidity provisions or liquidity detection. HFT strategies often present surprisingly concise and simple programming, which is usually developed based on linear reversion [5].

High-frequency trading is a method of intervention on the financial markets that guided by mathematical algorithms and HFT strategies have reached considerable volumes of commercial traffic and are responsible for most of the transaction traffic of some stock exchanges [10].

Machine Learning in Trading

Financial markets have a complex, uncertain, and dynamic nature, making them challenging for trading [3]. Algorithmic trading based on machine learning is a developing and promising field of research [3].

In recent years, using the ML as an intelligent agent has risen in popularity over the alternative of the traditional approaches in which a human being makes a decision [11].

The ML and DL have enhanced the performance in algorithmic trading. Firstly, they can extract complex patterns from data that are difficult for humans to accomplish. Secondly, emotion does not affect their performance, which is a disadvantage for humans [11].

In recent years, machine learning and deep learning algorithms have been widely applied to build prediction and classification models for the financial market [1]. The disadvantage of these algorithms is that they are not trained to model positions [1].

In rule-based algorithmic trading, computers trade in financial markets through predetermined rules specified by humans [3]. These rules can be defined based on the traditional trading methods, mathematical models, or human-made strategies [3]. On the other hand, in ML-based algorithmic trading, computers are trained on historical data to trade in markets without any direct human interventions [3].

ML-based algorithms can extract patterns, relationships, and knowledge from the historical data without the need for predetermined guidelines or strategies by domain experts, and ML-based algorithmic trading approaches can discover profitable insights unknown to humans [3].

Humans might make wrong trading decisions regarding their emotional and psychological factors and manual trading can be prone to human errors, while computers are not negatively affected by these factors in making the trading decisions and are more precise in executing trading decisions than humans [3].

Computers are very fast in executing trading decisions and are far more capable than human minds of processing a tremendous amount of information in real time, monitor the markets permanently, do not get tired or sleep, and have immediate reactions when unexpected events occur [3].

Learning in trading systems is not merely limited to generating trading signals and predicting future price. The optimization of order execution is another important research field and especially vital for HFT strategies. As for machine learning, reinforcement learning and supervised learning methods were proposed [5].

The machine learning approach for algorithmic trading can be further divided into the supervised learning approach and the reinforcement learning approach [9].

Supervised Learning vs Reinforcement Learning

The supervised learning method has attempted to predict the stock price or price trend of the next time point [9].

Price prediction aims to build a model that can precisely predict future prices, whereas algorithmic trading is not limited to the price prediction and attempts to participate in the financial market (e.g. choosing a position and the number of trading shares) to maximize profit [11].

It is claimed that a more precise prediction does not necessarily result in a higher profit. In other words, a trader’s overall loss due to incorrect actions may be greater than the gain due to correct ones [11].

Nevertheless, the predicted price or trends of supervised learning method cannot be directly mapped to the trading action. Therefore, after predicting the price, prior knowledge of the financial field is required to choose trading actions, and the accuracy of prediction will affect the decision-making process, resulting in second error propagation [9].

In addition, prediction-based supervised methods do not take into account environmental factors such as transaction cost (TC) and cannot solve the temporal credit assignment problem, resulting in poor performance in algorithmic trading with delayed returns [9].

Supervised agents are trained using handcrafted labels, which require an arbitrary profit margin compared to commission and other costs. However, the actual profit is not always directly related to the handcrafted labels, since other parameters such as market volatility and agent confidence can affect profit or loss [4].

Financial data are noisy, and this may be why supervised learning methods have not been very successful in the past [12].

Although supervised ML methods have shown potential in predicting markets such as Forex, their prediction accuracy might not be sufficient for real-world algorithmic trading due to the noisy, volatile, and uncertain nature of financial time series [3].

Noise-free labels are difficult to construct since the extreme and unpredictable nature of financial markets does not allow a single hard threshold to determine whether a price movement is significant [6].

There are two main reasons why supervised ML and DL are unsuitable for algorithmic trading. First, supervised learning is improper for problems with long-term and delayed rewards, such as trading. Second, labeling critically affects performance. Reinforcement learning (RL), which does not require labels and instead optimizes a reward function, is more appropriate [11].

Reinforcement Learning and Deep Reinforcement Learning

ML algorithms such as deep reinforcement learning (DRL) can autonomously make optimal decisions in complex environments [3].

The need for supervised labels can be alleviated by RL. In RL, an agent interacts with the environment and receives rewards or punishments. In financial trading, the agent decides on trading actions and is rewarded or penalized based on performance [6].

With DRL, trading profits and market costs can be integrated directly into the reward function using simulated trading environments, removing the need for handcrafted labels and allowing the agent to optimize position selection [4].

In this way, DRL agents directly optimize task-related metrics, such as profit, in simulated trading environments [4].

Using direct price forecasts or handcrafted labels for supervised learning is considered suboptimal for trading, while RL is more likely to yield better results by directly optimizing performance [4].

Optimizing deep RL agents is notoriously difficult and unstable, especially in noisy financial environments, which can hinder trading performance [4].

Value-based RL methods are limited by discrete state and action spaces and are sensitive to small changes in value estimation. Since trading is a continuous state problem, policy-based RL methods are generally more stable and suitable [9].

RL agents often outperform benchmark strategies, demonstrating the potential advantage of RL-based trading over rule-based approaches [3].

References

  1. Chau et al., 2022

2. Jamali et al., 2023

3. Shavandi & Khedmati, 2022

4. Tsantekidis et al., 2021

5. Huang et al., 2019

6. Tsantekidis et al., 2021

7. Sazu, 2022

8. Li et al., 2016

9. Lei et al., 2020

10. Rundo, 2019

11. Majidi et al., 2022

12. Huotari et al., 2020

13. Zarkias et al., 2019

14. Korczak & Hernes, 2017

15. Ponomarev et al., 2019

16. Mnih et al., 2016