Key technologies:
Front end: React or Flutter.
Back end: (online) relational database, especially for time-series data.
Machine learning: deep learning, anomaly detection, model tuning and performance tracking (such as MLFlow), LLM, and agent orchestration framework (such as LangChain/LangGraph).
The source code is here (for front end).
Background
The main idea is to use machine learning to achieve better return in automated trading. There are a wide range of machine learning methods we can potentially use: from the classic decision trees, deep learning, to LLM and agents. These can be applied in several ways such as using LLM for sentiment analysis and deep learning for anomaly detection. We always want users to steer the process to for example to include domain knowledge that model does not have and/or monitor and adjust the model when the performance inevitably deteriorates.
Progress
Data Collection
For data we used Alpaca that provides free real-time data and limited historical data. There may be better options that we are not aware of. Besides price data, Alpaca also provides both historical and real-time news, which are needed for the sentiment analysis (discussed below). It is also possible to scrape online discussions such as those on Reddit.
LLM for sentiment analysis
News sentiment can be used as an input to the trading model, together with other data such as pricing and volume. We tried LLM sentiment analyse, as it is much better than traditional NLP (Natural Language Processing) techniques. The inspiration came from paper Expected Returns and Large Language Models, which compared the impact of different LLM sentiment analysis, which has much better return than the baseline S&P500 buy-and-hold (see the figure below). The best performing model (chatGPT) has a 10^7 (10 million) times return on the investment fro the period between 2004 and 2018 (the return of the base is about 10 times). Of course this is not quite achievable in practice.

In our experiment the news sentiment is either done with LLM API (such as chatGPT API) or a local LLM locally such as FinGPT (open-source alternative to BloombergGPT) or Llama by Meta. We did a fairly comprehensive comparison of different local LLM and results are in this report (related repositories: repo1 and repo2). Now that LLM API is much cheaper, it is usually better to use that for sentiment analysis, as it is easies to use and performance is usually better than local models (difficult to run very large LLM locally and many are not open source). Prompt engineering techniques such as few-shot learning and chain-of-thought are still applicable here.
Trading models
The task of the trading model is to take input such as new sentiment and price change and then decide whether to buy or sell and how much. The simpler version considers only one asset (such as one stock or one coin), and more complex one would create a portfolio with a mix of different assets. We have tried a few different types of approaches, mostly reinforcement learning and anomaly detection.
Reinforcement Learning (RL)
The idea is to use investment return as the reward and train a RL model to decides when to buy/sell/hold. The results were not very good and can lose money as well. More details can be found in these reports: report1, report2, and report3. It is not clear where the issue: it can be the training data (not enough) or the setup of the training/model (such as hyperparameter tuning). This could be an area for future projects.
Anomaly Detection
The idea is to target the phenomenon that sometimes the price of a stock or coin could change significantly within a short time. This is usually caused by some significant news, such as Elon Musk twitter about DOGE or ‘Roaring Kitty’ posted about GameStop (the so called ‘meme stocks’). We treat these as ‘anomaly’ in a (price) time series. Actually, this is quite often, as there are always a few stocks have very big price change everyday (and probably more so for crypto coins). For instance, these are the ‘top gainer’ in the UK stock market on 21 Nov 2025

The big price changes usually happen within a short period (like 30 minutes) and the idea is to detect such ‘anomaly’ as early as possible (like 5 minutes into the anomaly) and catch the rest of the rise. Below is the price change of stock ‘AAI.AQ’ (the top gainer in the list above), and the orange rectangle is a period of sudden price rise (there is another one at the end). There is about 75% price increase in that period (about 1 hour); even just catch half of that (37.5%) will be an extraordinary return on the investment for one day.

Once detected, the tactic is to put all the fund into that stock or coin, and then get out when the signal disappears (no longer an ‘anomaly’). This is shown to have better return than the RL based approaches using technique such as CNN-LSTM. More details in this report. This 2024 survey compared 40 different time series anomaly detection algorithms on over 1000 time series data, including all types of techniques, from statistics, machine learning, deep learning, to LLM-based. The time series data and the implementation of the 40 algorithms are available on its GitHub repository. The same group also made an automated solution.
Interactive Model Training
As mentioned before, we always want users to have the control of the trading. This turns out to be essential for model training as well, RL or anomaly detection models, as there are many attempts with different training data, hyperparameter, or even different model architecture (such as LSTM vs CNN-LSTM). We need to be able to track how the performance changes as these change, which is essential to guide the optimisation of the module performance. Some progress has been made in this direction. This is an earlier attempt by Manasi:

And this is the more recent work by Ashley that allow you to interactively change the training data, hyperparameter, among other settings and track the resulting performance. Below is a video demonstrating the interface and more details are in this report.
Project Ideas
The next step is to build on the existing progress and further improve the overall (return) performance.
- It would be nice to have an online storage of collected data (price and news) and sentiment score, so the next student does not have to repeat the process.
- Further improve the interactive interface to allow easier tuning of the trading model, including adding new types of machine learning models not currently supported (through the interface and not changing the code).
- Use LLM to support the analysis, such as suggesting changes to the model (training) to improve performance.
- Investigate newer approaches, such as better anomaly detection algorithm for time-series data.
Resources
See this paper for the details on sentiment analysis using LLM: Expected Returns and Large Language Models
GPM: A graph convolutional network based reinforcement learning framework for portfolio management
Reinforcement-Learning based Portfolio Management with Augmented Asset Movement Prediction States
iQUANT: Interactive Quantitative Investment Using Sparse Regression Factors (Computer Graphics Forum – CFG 2021)
Sentiment Analysis in the Era of Large Language Models: A Reality Check (arXiv 2023)
Software
Alpaca: https://alpaca.markets/
TradingView: https://www.tradingview.com/

You must be logged in to post a comment.