AI in Trading: Algos, LLMs and Quantum Computing

AI in Trading: Algos, LLMs and Quantum Computing
TL;DR Summary: Advancing computational approaches to automating trading processes

While in theory it is possible to trade without any strategy, the trader might soon discover that this is not a sustainable approach. So traders employ a wide range of strategies when trading markets. An example would be a moving average crossover as a signal to enter or exit a market. This is applied through the noise with the idea that this strategy will offer some signals that work out and will provide sufficient distance from the entry point to make it worthwhile.

Traders may look at strategies and think is it possible to improve on these and feel less like making a guess. Some might try and add on more indicators, but find the increasing complexity does not do what they imagined it might. So traders may turn to robots, which can execute strategies, deal with drawdown from this approach, and hopefully end up with a gainful trade.

But robots are not robots in the traditional sense, they are computer programs that utilise infrastructure to apply a strategy 'robotically'. So the trader might want a robot that has this capacity to apply algorithms to trading strategies and execute trades but which also offers some elements of the human capacity to understand and apply discretion through the course of the trade.

AI is a field which seeks to emulate human reasoning, but doing it from a machine perspective. So can AI provide a path to a robotic trade that can also offer improved real-time understanding? Short answer, maybe, but this article explores this question in detail. The article is illustrated with images and infographics which seek to explore some of the topics raised. There is also a selection of CFD providers that offer tools related to algorithmic trading and AI, though AI is still in its early stages when applied to retail trading.

An algo is a computer program executing instructions specified in its algorithm

An algorithm is simply a set of instructions. A computer program encapsulates these instructions in a way that allows them to be executed. Trading strategies can be defined as rules, codified into programs and executed. There are reasons why a human trader might want to do this. But there are also drawbacks. However, does AI offer a way to combat some or all of these drawbacks?

The algorithm and the trader

Traders might come across the phrase algo trading and understand that it refers to an 'algorithm'. An algorithm is a set of instructions written in such a way that it executes some process. Self-directed traders tend to use algorithms in the way they trade. They might apply an MA crossover based on current market conditions, for example. So they will enter on a signal, manage the trade, and then exit on a signal. But human traders may not stick to these instructions, they may exercise discretion. Discretion is a word that sounds positive, but it may have different outcomes in trading.

A trader ideally exercises discretion when they believe that a strategy needs to be modified, based on their understanding of the market. For example, they may find that the volatility levels at the time the trade was made and projected have changed in such a way to change the basis of the original assumptions underlying their trading rules.

Herein is the problem, as the trader may find that they end up getting whipsawed by the market as they change rules, which might work out in the end. It is even possible for a trader to enter a spiral of trades tending toward randomness in a choppy market. So the trader might consider applying this strategy without exercising their discretion.

Algorithmic trading

Algorithms can be codified in programming languages. Languages offer a way to define instructions which can be then interpreted into machine code and executed on a digital computer. So some online trading platforms offer the capacity to create instances of these codified algorithms, integrated into the trading mechanisms for the platform via its connection with a broker or CFD provider.

A well-known example is Expert Advisors, or EAs which are offered via the MetaTrader platform (currently MT4 and its successor MT5). EAs can perform several tasks, but they are principally known in their capacity as online trading robots. These are trading strategies codified as algorithms that are executed on the terminal via its connection with the broker offering the trading platform (they may also be hosted via a VPS).

However the algorithms used are simple and lack what might be termed intelligence, in the sense of the capacity to be responsive to changing market conditions. They may be used precisely because they lack this capacity to respond, that is the trader may find that they do not trust their intelligence when applied to a chaotic, unpredictable market and want a robot to do the algorithmic trading for them.

Which is to say, the trader trusts the algorithm, but not themselves so look for a way to let the algorithm trade for them or simply cannot trade at the time or in the way the trading system requires. A trading robot is not Artificial Intelligence, however, it might be seen as an algorithmic step towards this, but missing the intelligence except as compiled into the algorithmic rules by those who created it.

Pluses and minuses of algorithmic trading

The potential pluses of algorithmic trading include that the trader can let the chosen strategy run. They do not need to decide to enter, manage, or exit a trade. These programs can also execute at frequencies that the human trader might find tiring or in some cases impossible. Thus the potential for being directly whipsawed does not apply. However, the problem and a potential minus is that the computer program will apply these instructions even when a human trader might not, perhaps for good reasons.

So trading systems can exhibit drawdown from reverses against the traded direction and in some cases do so very rapidly. A human trader might have ended the trade before this happens, though drawdown is a reason why systems may be turned off during news releases. However, the robot is designed to play the market, in the sense that it can and will plow through this choppiness, whereas a human trader might not or might get whipsawed, if it is choppiness and not a kind of market change which would invalidate the trade.

So a trading system may need to be able to withstand steep losses, with the idea that the trades will key into a trading pattern which has been successful on average in the past and will be successful in the future. But it takes away from the trader the difficulty in doing this, for emotional and other reasons. So the idea is patterns will work sufficiently some of the time to make it worthwhile.

It should be noted that a trader can adjust an automated system, but doing so might lead to the same problems faced by self-directed trading. To some extent, automation means automation, however, sophisticated systems might have mechanisms for automated adjustment based on drawdown, for example by altering position sizes. Trading systems can still produce losses sometimes rapidly which the trader cannot cope with. So is there a way to make trading robots smarter and what would it mean to do so?

5 steps from formulating a strategy to its implementation as shown in this layer diagram

AI and trading systems

Artificial Intelligence (AI) is a field encompassing a wide range of disciplines including computer science and engineering which seeks to emulate human reasoning powers, or at least automate features of these processes as they are understood. AI allied with machine learning has made advances in seeing patterns and causal relations in large bodies of data. This is like the trading issue, in that algorithms are applied to sets of data the human would find difficult or impossible to analyse.

AI until recently has been behind the scenes, analysing vast data produced by internet processes. The core developments in AI have been based around machine learning and the capacity to power them with advanced hardware, especially in data centers. However Large Language Models (LLMs) have taken AI and machine learning into the public view. LLMs use machine learning to train an inference engine on vast data sets, which can interact with humans in a way that seems human-like.

AI is at heart a big data, resource-intensive operation. Trading algorithms as used in online trading robots are not, however in bulk they are, as large numbers of computing events are processed in data centers.

Data centers are also where AI happens. But AI has specific demands on hardware which can differ from those of trading robots. Trading robots can be seen as less computationally intensive compared with AI. But robots have a critical issue in terms of latency (the delay in the processes from making an order and having it executed), so the speed at which communication can happen at a data center is critical, including efficient routing algorithms and fibre optical cabling or microwave.

While latency is also important for AI, it is generally highly computationally intensive, so it needs specialised computational resources. However data centers can include different types of computing hardware and systems, accommodating different types of computing, at scale in both the AI training phase and the operational phase (which itself can involve further training).

But the key difference is that trading robot algorithms are generally simple, in fact they can be programmed by traders willing to learn the language (or use software which bypasses the need to code). However AI algorithms in implementation are not simple and can be extremely complex (for example LLMs can have billions of parameters and hundreds of layers taking weeks or more to train on specialized hardware).

A caveat is that while typical robots are not complex, some advanced robots linked into machine learning can be very complex, which is to say the requirements of AI ads resource intensive complexity. AI aims to emulate parts of human reasoning, so how do AI algorithms fit into the picture of automated trading?

AI and augmentation

AI is currently more like a set of techniques reliant on data centers. AI however has a goal, which is Artificial General Intelligence (AGI). As its name suggests, it is a computing system that has a generalised model capable of performing tasks to the equivalence or beyond when compared with a human. AGI is generally not seen as currently existing, though some may say that LLM (Large Language Models) AI Chatbots are a significant step towards this. AI is currently more like a kind of advanced automation but touches on areas that seem like human attributes, in terms of the capacity to process data and output responses in ways that can mimic intelligent or human-like responses.

Self-directed traders rely on their intelligence and experience but try and harmonize it with the tendency for the market not to be comprehensible, due to complexity and randomness and the fact that past trading patterns can be very hard to spot in their formation or sufficiently before their end (e.g taking a position in the prior direction of a trend but at its volatile end).

But the tantalising possibility is to use AI to apply some or all of these human capacities allied with the speed and responsiveness of AI robots. It might be thought that this may be impossible, it may be for example that the emotional element which can make or break trades is essential to the operation of intelligence (however emotional reasoning in AI is a research topic). But even if so, there are ways to use the capacity of machine learning, one of the central drivers of AI, to spot patterns in market data in a way that humans cannot. This is like augmentation, rather than replacement because for now, the human has the GI of AGI, not the machine.

AI can be trained on past data and could then be used to trade into the market using the interconnections and patterns it has seen to find trades. We have noted that simplicity in algorithms is important. AI algorithms are anything but simple in implementation but may be conceptually relatively straightforward in their description. So how this does affect their capacity to analyse the market in real time?

AI and real-time analysis

AI systems are trained using machine learning and are then applied to problems or tasks. However, they may not be able to make causal inferences from some data which they are given. This is a core reason why AGI does not exist, as there is no generalised AI model for intelligence. At considerable though scaled expense these models can emulate some features of human intelligence and can do things humans cannot do, like analyse large data sets.

However to some extent the more an AI is like a human in terms of its intelligent inferences, the less it is like a machine in terms of analysing complex data (including in accuracy). This is seen in LLMs, which can produce human-like responses based on generalised predictive training on the Internet, but can be inaccurate in terms of the response given. This may be at least partly a problem of computing resources, and the fact that they are pre-trained on data and have to make inferences based on this training.

The training itself produces complex networks of connections that are sufficiently generalised such that they seem like they are making intelligent responses. However, it can be seen that applying this to the markets could be problematic as humans themselves can find the market beyond comprehension in real time. From more static perspectives, humans may still find the market difficult to understand, but there is a wide range of techniques that can be applied to make inferences based for example on the chart, or fundamental data. AI can do this as well, but not necessarily any better than a human.

But the idea of using AI, is that it might spot patterns and regularities missed by the human, in a similar way that it can spot patterns in data sets the human would find hard to find. There are current limitations to real-time training and updates to AI, but they are used in more static ways such as portfolio creation, and less static ways such as applying machine learning to adjust robots (at considerable computational expense). But can these limitations be overcome ?

This infographic illustrates core features of quantum computing: qbits, entanglement, parallelism and quantum gates with vibrant imagery

Quantum computing

Quantum computing is a field that is still in its relatively early days. Quantum computers may be able to perform parallel computations offering dramatic speed-ups compared with classical computation. Computation is more than hardware, and quantum computing offers the potential to use improved algorithms to tackle computational problems, with the tantalising suggestion of a use case in real-time financial markets adaptation.

This is still the future, but it may be possible to firstly speed up AI reasoning systems and increase their accuracy and secondly to crunch financial data at high speeds. What may result is not a human reasoning system at all, but a kind of machine intelligence that does more things that humans cannot do. But it may be that scaling up data centers with more powerful computational capacity might go some way to solving these problems without quantum computing, as might ways to integrate AI with market data.

But there is also another way of looking at this. The human brain is extremely powerful compared with computing devices. It may be that a good trader can see patterns, even if they are not fully aware of this, with trading intuition. But the problem is that human can lose confidence and can break their capacity to trade well and then look for robots.

So maybe this capacity is already here, just in a biological advanced computing system and one way forward is to leverage AI to help the trader have clarity and confidence about their abilities. Some trading is, of course, out of the reach of human traders, for example, High-Frequency Trading (HFT) and here advanced AI systems could be seen playing a crucial role in dealing with extremely complex sets of data updating very rapidly. Which is to say, expanding the reach of current systems using AI in HFT.

5 steps in the LLM process cycle as shown in this linear diagram

Sidenote focus - using LLMs for trading

Major LLMs typically but not necessarily use the GPT algorithm. GPT stands for Generative Pre-Trained Transformer. As this name suggests, it is pre-trained, resulting in an inference engine with a huge knowledge base. A GPT is not a database in a traditional sense. It is trained on datasets and represents this data in complex structures. A GPT uses algorithms and its training data to predict what to output next, resulting in responsive, human-like text output. It is not specifically designed to plug into the market and predict trades, the underlying model is relatively static compared with the market. A GPT is seen as a big advance because it can work effectively at the human speed of textual interaction, but markets are much faster and much less predictable and don't text.

However, there are many more static elements to trading. Assuming there are no restrictions built into the model on this kind of output, a GPT can produce lists of markets. It can tell you about markets. It cannot analyse a chart, as the capacity to recognize this kind of data is limited. A GPT can tell you about technical analysis and fundamental analysis and can provide feedback.

So there is scope to use LLMs as a kind of adjunct to trading. It might be said that LLMs work best in general when used as a responsive assistant, rather than trying to replace the human.

Prompts are the way the trader interacts with the LLM, but they may also upload some kinds of data to analyse. A prompt is important as it guides the predictive response of the LLM. The trader may find that multiple prompts may be necessary in some situations to narrow down a question. So an LLM can be seen as potentially a way to automate some parts of the trading experience and a way to use some automation without having to use robots, that is as a potential aide for self-directed traders.

A big caveat with LLMs is that they can produce inaccurate output, so the trader needs to check any information themselves, and still need to do their own analysis and research. Please note that the regulatory situation regarding LLMs is evolving and this may impact their use for trading in the trader's region.

7 potential applications of LLMs in trading as shown in this graph image

Bringing it all together - Python algos?

Python is one of the major languages used in AI programming. Other languages are used as well, including C++. Python has a whole host of libraries based around machine learning, and what is termed deep learning. Deep learning is a name for the type of machine learning used in LLMs, as it reflects the use of complex interconnectivity in neural nets, the engine behind LLMs.

Python is a computer programming language, thus to use it, the trader would need to learn it, and also learn about the different ways to use libraries, and to connect with external programs. There are various repositories of Python libraries, but one of the major ones is PyPi (the Python Package Index).

Python has libraries dedicated to finance and trading, and these can provide a basis for creating a script that mirrors the kind of functionality seen in EAs, for example, i.e. signals generated by a technical indicator based on chart movement. However, it could also be possible to then plug into a library that can optimise these signals, based on machine learning algorithms. So this could be a way to generate trading signals, optimised by machine learning, that can then be applied in an algo.

However, to use a Python algo, the trader would need to connect with the broker's API. So, this is much more complex than simply using an EA on MetaTrader, cBot on cTrader, and so on, and would require knowledge of Python and machine learning. But, this is potentially a way to utilise machine learning to polish signals (the basis of algo trading), or even spot signals a human might not recognise.

Brief summary

Algorithms provide a way to codify trading strategies developed by traders. Self-directed traders can apply algorithmic rules themselves but may exercise discretion as they do so. However, to overcome issues with self-directed trading, particularly at higher frequencies, traders may wish to codify these rules into online trading robots. Online trading robots have limitations as they are generally simple.

However AI offers a way to augment these algorithms via computationally expensive back-ends. But AI has limitations which may be at least partly to do with the computational power available to them. One possible future increase in computational capacity might come from quantum computing or other advanced computing platforms. However human traders possess advantages from an evolved, intelligent brain which may still be fundamentally difficult for AI systems to emulate, though AI may have at least an assistive role in the trading process.

Routes for AI in trading encompassing data centers, algos, LLMs and quantum computing as shown in this infographic

CFD Brokers & AI

CFD brokers (and brokers in general) are regulated thus they are not necessarily the place to see the latest in AI. This said some have offered tools based on AI. CFD brokers do cater to larger volume traders and these brokers may offer access to their API. This means that the trader may be able to plug in an AI system of some kind into the broker feed. However, it might be expected that at some stage tools based on AI such as LLMs, may make an appearance.

Trade on a demo account

No matter what computational power they are using, the trader can test out strategies or systems without risk on a demo account, with no risk to real money. The trader may either sign up for a demo initially, create one as part of the sign-up process, or after creating a live account, depending on the sign-up process.

Robots can normally be downloaded (for a fee), built, or modified. They may also be backtested on past market data, however past performance is not indicative of future results.

Robots can generally be run on a demo account, and this is a good way to get to grips with what they are like, without risking real money. When moving to a live account, the trader may wish to try out robots with small trade sizes, to try and reduce risk. A selection of 10 CFD brokers offering automated trading along with their robot trading platforms, is provided below.

Pepperstone Platforms & Robots

  • Minimum deposit: $200
  • Automated trading platforms: MT4, MT5, cTrader, TradingView

Pepperstone offers a wide range of trading platforms all of which allow the creation, download and use of online trading robots. MT4 and MT5 offer EAs, cTrader provides cBots and TradingView has Pine Script robots. Each of these platforms uses a different robot language: MQL4 for MT4, MQL5 for MT5, C# for cTrader, and Pine Script for TradingView. Pepperstone offers low latency, and rapid order processing and can provide Forex spreads from 0, plus a commission charge.

Deriv Robots & Synthetics

  • Minimum deposit: $5
  • Automated trading platforms: MT5, cTrader

Deriv offers automated trading with robots on MT5 and cTrader. Deriv has a low minimum deposit of $5. As well as CFDs based on real markets, Deriv also offers Synthetic Indices CFDs which may be traded 24/7. Traders can trade CFDs on real markets and Synthetics on both MT5 and cTrader, however, MT5 has a much wider selection of Synthetics.

AvaTrade Robots & Self-Directed

  • Minimum deposit: $100
  • Automated trading platforms: MT4, MT5

AvaTrade offers both automated trading platforms and a user-friendly platform for those who plan and execute their trades. So the trader can use EA robots on both MT4 and MT5 and try self-directed trading on a Web Trader.

ThinkMarkets MT4 & MT5 EAs

  • Minimum deposit: None
  • Automated trading platforms: MT4, MT5, ThinkTrader

ThinkMarkets provides its ThinkZero account for those who want Forex spreads from 0, plus a commission charge. Forex traders may want to keep spreads as low as possible especially if they are making repeated trades, however, the commission charge also needs to be factored in. ThinkMarkets utilised Equinix data centers for low latency rapid order processing, which robots typically demand. The trader may rent a VPS as well. The ThinkZero has a minimum deposit of $500, however, there is a Standard account which has no minimum deposit requirement. Robots may be run on this account as well, on MT4 and MT5.

BlackBull ECN Forex Trading

  • Minimum deposit: None
  • Automated trading platforms: MT4, MT5, cTrader, TradingView

BlackBull is a broker with a focus on automated trading, offering the capacity to robot trade on MT4, MT5, cTrader, and TradingView. BlackBull also has a focus on low latency rapid order processing for those who use robots. BlackBull does not have a minimum deposit requirement for its ECN Standard account.

Dukascopy JForex & MetaTrader

  • Minimum deposit: $1000
  • Automated trading platforms: MT4, MT5, JForex

Dukascopy offers access to its SWFX ECN, allowing a wide range of trading styles and particularly supporting automated traders. Dukascopy offers the JForex platform, which provides a stable ECN trading environment for running robots. However Dukascopy also provides MT4 and MT5, but with fewer markets on these platforms. Thus the trader may trade markets such as Forex with robots based on JForex scripts or as MT4 and MT5 EAs.

XM MetaTrader Forex Broker

  • Minimum deposit: $5
  • Automated trading platforms: MT4, MT5

XM offers automated trading on MT4 and MT5. XM provides accounts covering lower volume to higher volume trading. It has a Cent type account (called its Ultra Low Micro account) with very low trade sizes as well as accounts for higher volume traders. XM has a low minimum deposit of $5.

Vantage ECN Robots Trading

  • Minimum deposit: $50
  • Automated trading platforms: MT4, MT5

Vantage Markets offers a range of ECN trading account supporting automated trading, starting from a minimum deposit of $50. The RAW ECN account offers Forex spreads from 0 pips, plus a commission charge. Traders may use EAs on MT4 and MT5 as well as self-directed trading, however there is also a user friendly platform for those who execute their trades, namely ProTrader.

IC Markets Low Latency

  • Minimum deposit: $200
  • Automated trading platforms: MT4, MT5, cTrader, TradingView

IC Markets has a focus on rapid order processing, offering low latency conditions for those who use robots and trade at high frequency. IC Markets can provide Forex spreads from 0, plus commission.

Plus500 Self-Directed Trading

  • Minimum deposit: $100
  • Trading platform: Plus500 CFD Platform

Plus500 does not offer automated trading. It does however provide a user-friendly, arguably intuitive platform designed for the trader who plans and executes their trades. Both fundamental and technical analysis tools (important for self-directed traders) are integrated into the platform. There is also a wide range of data about what other Plus500 traders are doing, on aggregate via the +Insights tool.