The client wanted us to create an actionable AI-backed tool that would analyze traders’ behavior on the market with high operational efficiency and prediction accuracy. From the functional perspective, the tool was expected to perform the following tasks: · Differentiation between several types of traders, including hedgers, arbitrageurs and speculators; · Recognition and processing of trader patterns, based on historical data analysis, i.e. previous trading activities; · Building profiles for each trading pattern to accurately predict the trader’s next moves on the market; · Simulation of traders’ behavior to provide insights on alternative steps a trader can take in ever-changing environments, such as in the case of market fluctuations; · Pinpointing the exact price at which a trader opens and closes the trade (Entry Type: IN/OUT) or increases the trade size.
We developed a solid ML-driven trainable model to track bot trader actions for this project. We have chosen two families of ML models to use for the prediction task:
Both XGB and LSTM models provide three types of outputs:
The project’s takeaways reveal the competitive advantages of using two ML-driven models for building bot traders:
As inputs for both models, we used historical data. In other words, we backtracked changes in prices and a trader’s actions to predict what the trader would do next. There are four important co-requisite touchpoints or parameters we consider: · Time limits for historical data under analysis · Essential features to be taken for initial profiling · Relevant data aggregation. · Raw ticks data to better realize the current market situation
Context length can drastically impact the accuracy level of trader action prediction. To be objective, it should be backed by a comparison of typical time intervals between a trader’s transactions. Having a smaller context often results in accuracy drops. A broader context, on the other hand, is a waste of computational resources and makes learning harder for a model. As such, traders that we sampled in the initial exploratory data analysis had frequencies of around 1-2 hours, which accounts for 100 min for models training a standard context length.
Features that we employed at the training stage were based on the earlier-stage analysis. We collected data on the price, profits and position, volume for the aggregated interval, technical indicators, and the likelihood of price patterns. In principle, simple training on the price data can yield strong enough models, but pairing it with extra data like indicators and profits often adds a few percent to the accuracy. To extract the most relevant features for each trader, we developed a feature selection process based on the correlation with changes in the trader’s position. In this way, we can decrease the amount of features we use, speed up the algorithm, and reduce the memory required for it.
Aggregation helps cut down an input size by the time axis. ML-driven models often have a hard time extracting the sparse meaningful signal from the noise that will be inevitably produced by large-scale data. The best way to address this issue is to introduce aggregation of tick data by time intervals. We experimented with 1-hour, 30, 15, 5, and 1-min aggregation periods. Similarly to context length, the optimal aggregation period correlates with the trading frequency.
Raw ticks also appeared to be useful for a share of traders. The first model used aggregated data, while the second model employed a mix of aggregated data to get a larger context and raw ticks data to capture the current situation. In some cases, raw ticks accounted for up to 2-5% of improvement. However, in other cases, they didn’t affect or even decrease the resulting accuracy. It seems that raw ticks are more important for traders who have frequent transactions, while for traders who have 1 transaction per hour on average, all necessary information can be available in open prices for time intervals.
We as developers can take away the following key findings from the project:
A robust price model can be created by multiple applying the model to the data with the same historical context, yet a different current price.
The price model is trained to track small price changes, with huge price gaps being treated as false or irrelevant.
We treat the current price seesaw as merely one of the factors that affect a trader’s actions and that can overlap with the previous price fluctuations.
The rationale behind the choice of Sell, Buy, and Idle trade modes shows that the order of importance of the abovementioned factors varies greatly from pattern to pattern, albeit some similarities also take place.
As a result, the customer enjoyed an actionable AI-fueled solution that can perform complex large-scale data processing tasks and come up with high-accuracy trade forecasts.