Medan Gabbay
Medan Gabbay

Leveraging Machine Learning for FX trading

Interest in Machine Learning is exploding and all businesses consider it as a prime future-reshaping initiative. FX e-trading provides a large amount of data which can be considered the required fuel of Machine Learning computing. Yet, as in all new hot trends, there is a large amount of misunderstanding and hype about what machine learning is and can do. Medan Gabbay, Chief Revenue Officer of Quod Financial investigates.

First Published: e-Forex Magazine 85 / Technology / March 2019

Machine Learning (ML) is a set of algorithms that extract information from raw data and represent some of it in some type of model. One of the most promising ML techniques is based on a type of algorithm called Neural Networks (NN). The idea behind Neural Networks is to mimic the brain neuronal system, with each neural unit being called a Node, and a Node being connected to other nodes via Connections, and the Connections organized via Layers. ML is the natural evolution in computer science to efficiently deal with massive (and exponentially growing) amounts of data.

A simple ML suitability test must check two criteria:

  1. Does the task deal with Complexity? Complexity refers to simple unit of operations, which interact in multiple ways and follow simple local rules. Difficult is then a set of operations which require a lot of interpretation because of lack of information / data but also sometimes (prior) knowledge to predict events. Finding one individual in 10,000 images is complex, but to know the person’s intent is hard(er). At this stage, ML is only suited to address Complexity and will not manage Difficulty.
  2. Does the task deal with non-changing patterns: ML is both a set of methods and technologies designed to implicitly recognize patterns within a data set (using a process known as Training). ML does not deal with unseen events and has no ability to adapt to new events. For instance, a driverless car will not be able to decide on a course of action when ‘a cyclist jump unexpectedly in front of the car’, if this event has never been seen before (or incorporated into the tree decision).
ML does not deal with unseen events and has no ability to adapt to new events.
ML does not deal with unseen events and has no ability to adapt to new events.

So how can FX trading benefit from Machine Learning?

Modern FX trading refers to two distinct activities;  (1) Trading refers to the investment decision, for instance, buying or selling an asset, and (2) Execution is the implementation of the trading decision to find liquidity at the lowest impact. This distinction is important; a successful Trading is the result of high quality predictions from short-term to longer-term. Consequently, Trading is far harder than an Execution. The longer the time frame, the higher the margin of prediction errors. Long-term investment predictions are impacted by complex exogenous factors, such as political changes, macro-economic divergence between two economic zones, or global economic trends, which don’t affect short-term models.

In contrast, Execution is far more deterministic in outcomes, than Trading, as exchange and regulations don’t change often. The patterns of execution, which are the base of ML methods, remain usually unchanged over time.

The trading (which here collectively means Trading and Execution) data patterns can be classified into 2 main categories:

  • Trending - times series trends: This is the data used to find trends which are mostly based on times-series trend analysis. Examples are the evolution of short term (i.e. few seconds to few minutes) Price changes, Spread, Hit ratio, or Fill ratios. The trend analysis is well suited for pattern recognition under a Machine Learning method. The usage of ML will be a large improvement over current practices. The major benefits are that ML will allow far larger number of trend analyses and the ability to recognize the trends much earlier than currently possible.
  • Predictive: In this case, the historical or modelled data is used to predict an outcome. The modelling can be what/if type of stress testing, but also uses models based on theoretical calculations. The usual statistical / probabilistic approaches are too labour intensive and therefore expensive. In addition, models seem to have increasingly diminishing life span (which is not a well understood phenomenon). ML here is the most interesting avenue for reducing cost, by the increased ability to create and/or modify a predictive model by creating feedback via training process into the models.

The above data and ML methods can be used to find signals, but more importantly be used to take short term decisions, which are more adapted to execution. One of our own research projects is based on Probabilistic (Bayesian) Machine Learning, which we believe is best suited to short term price / liquidity predictions - such as Price reversion predictions.

The method is similar to current ways to predict election outcomes. We start with a Belief, called a Prior. The predictions iteratively adjust themselves as new data (i.e. price, or in elections, new polls) becomes available and incorporated into the model. The method considers that the price is subjective (instead of pre-determined from the beginning, for instance based on a frequency of events, such as having a coin head/tail probability), with one initial Belief and updates on the predictions as new outcomes are available. The constant guessing and corrections towards better predictions is well suited to real-time predictions. As stated before these methods perform well in short term predictions - in this case, short term means minutes.

Another domain that we have investigated, and has given tangible results, is the optimization of algorithmic trading parameters. In the most advanced Execution Management Systems, the behaviour of an algorithm trading engine is managed via a large number of parameters. In Quods, there are over 100 parameters to manage a single trading algorithm. An example of a parameter is Level of Aggressivity. This is defined as the amount of liquidity that a trader wants to destroy during the execution. The aggressivity takes into account, for a given pair, the available liquidity but also the overall immediacy to complete the execution: it is a common practice to be less aggressive at the start of the execution and increase aggressivity towards the end.

The case for applying Machine Learning to the optimization of the algorithmic trading parameters is very strong and additional arguments include:

  • The trading algorithms provide a lot of data, including Best Execution and TCA, which can be enriched by different market data and benchmarks, all in real-time. It has to be noted that the data set is not as big as required by mainstream Machine Learning, but Reinforced Learning is the best method.
  • And, there is a good ability to train the Machine Learning algorithm. The training can utilize the existing algorithmic trading testing / back testing environments (which are part of the regulatory requirements for algorithmic trading). These environments provide a good way to replicate the behaviour of multiple agents and the venues, and a replay mechanism.

In Quod Financials case, we have decided in our first trials to use a Reinforced Learning technique called Contextual Bandits. In Contextual Bandits, the following process is followed:

  1. The algorithm observes a context: the features extracted from market data and order input properties,
  2. It then makes a decision: what parameters are best (choosing one action from a number of alternative actions)
  3. And finally observes an outcome of the decision.

The outcome defines a reward. The objective of the training is therefore to minimize/maximize the average reward, which is for example, to minimize slippage (impact of the execution) of the algo order.

Contextual Bandit logic

This technique allows with sparse data, and outcomes which are reached after a long series of actions - like a game of chess, where you will not know until you win, lose or draw, to address a complex decision in algorithmic trading. The Contextual Bandits algorithms are evolving rapidly, for instance the notion of average expected outcome (usually called Regret) allows it to recalibrate the outcomes.

All the above examples are the first foray into a very big shift in the computing paradigm. The paradigm is moving essentially from an explicit (procedural) to implicit (and data-driven) programming. This major change will in fact influence, in the next few years, how FX trading and execution systems are architected.
Quod promotes a new architecture which will mimic how cognitive systems work. It is based on the set of Unconscious processes (fast, low energy in processing and inflexible) and a few Conscious processes (slow, high energy and flexible). This new architecture will then be constructed around:

  • A set of price and liquidity Predictive Agents, which are designed to predict the outcome of the execution. The prediction deals simultaneously with the price optimisation for timing / impact, and liquidity optimisation for the selection of venues and levels of liquidity.
  • A set of Execution Agents which are the execution methods used, including the algorithmic trading / Smart order routing capabilities,
  • A calculation and data presentation set of Data Agents, which work in a feedback loop. They aim to quickly update the predictive models, as new data points become available. To be clear, a “dirty” but fast and frequently updated prediction, is far better than a superior but slower model.

These three components are the ‘unconscious’ part of the system.
The whole supervised and managed by Actors, which can / will be human users, or other machines in conjunction with human actors, taking Meta-decisions on the path of execution.

Machine Learning is in its infancy, with a lot of innovation yet to be delivered (or even imagined) in financial markets. As with all new technologies, there is a cost to the learning curve and bringing the organisation to this new reality.

FX trading will be hugely impacted with such a prime focus on execution, this makes it a very good candidate for such an initiative. The direct benefits are a higher level of automation, but also performing tasks/processes that are out of reach, such as reviewing on a frequent basis the execution performance and making data-driven decisions to improve the performance.

Even if the technology is not mature, we believe that you need to allow an iterative mode based on a Trial and Error approach to create the necessary know-how. In any profound change, there are losers and winners. But cost of doing nothing is the greatest risk.