> For the complete documentation index, see [llms.txt](https://bingstormais-organization.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bingstormais-organization.gitbook.io/product-docs/bingstorm-ai-technology-center/bingstorm-ai-trading-framework.md).

# Bingstorm Ai Trading Framework

Bingstorm's pair trading is a common long-short strategy. To develop a pair trading strategy, there are two core steps: the first is the target to be traded, and the second is to model the price difference between the two, because our assumption is that the price difference between the two will fluctuate in a stable interval (mean regression), so when the price difference deviates from the reasonable range and returns to the reasonable range, we can make profits.

<figure><img src="/files/Jo3wMgi7Nezt2TzlJWDN" alt=""><figcaption></figcaption></figure>

A Pairs Trading Framework Using Machine Learning

pairing model

Mat Lebiz (Chief Engineer of Bingstorm Ai) proposed a pairing model framework based on unsupervised learning, which mainly consists of the following three parts:

The first step - dimensionality reduction: simplify the characteristics that can represent each coin, and mainly apply PCA for dimensionality reduction

The application of PCA here is mainly to construct the characteristics of the price performance of each coin. The specific method is as follows:

Assuming that there are n kinds of coins, first calculate the standardized daily rate of return of each coin. Standardization refers to dividing the standard deviation by the rate of return (rolling window, such as 120-day Rolling Standard Deviation). Calculate the covariance matrix for the above rate of return, and perform PCA dimension reduction, and select the first K eigenvalues, so that each stock has K features.

Step 2 - Unsupervised Learning: Use the above features combined with a clustering algorithm to find potential coin pairings

There are many unsupervised learning algorithms, but the algorithm that meets the current application scenario must have the following characteristics:

1. No need to specify the number of clusters
2. No need to sort all coins
3. Processing of outliers
4. There are no specific assumptions about the shape of the clusters选

Step 3 - Pair Selection: Apply a set of criteria to filter the above pairs

Through the above clustering, we can find potential coin pairs (in most cases, a group of coins). When screening coin pairs, Dr. Mat Lebiz uses the following 4 hard indicators:

1. The coin pairs of the two exchanges must be co-integrated
2. The Hurst index of the price difference should be less than 0.5 (no trend)
3. The half-life of mean-reversion should be within a reasonable range
4. There are enough trading opportunities in history

<figure><img src="/files/yw1Bw67qKVCCsQEQo0G4" alt=""><figcaption></figcaption></figure>

The following figure is the framework diagram of the pairing model of Bingstorm Ai's application of machine learning and the logic of the corresponding algorithm used in each step:

<figure><img src="/files/wl4359ttYx3lvFGZab2Q" alt=""><figcaption></figcaption></figure>

transaction model

transaction model

After the coin pair is selected, the next step is the specific transaction. The actual object of the pair transaction is the price difference formed by the coin pair in different exchanges, as follows (XY is the two exchanges, S is the price difference between the two, beta is the agreement Integer factor):

<figure><img src="/files/rCANdnWOLqYH27xMIYvO" alt=""><figcaption></figcaption></figure>

Machine learning models can be applied to predict S and trigger trading signals based on specific thresholds:：

<figure><img src="/files/RlV8Se1dzbf03FXfBrLG" alt=""><figcaption><p>In this scenario, any machine learning model or deep learning model that can be used to predict time series can be applied to the prediction of price difference. When selecting a specific threshold, it can be selected according to the distribution of the spread return rate in the past period of time. The specific entry and exit trigger mechanism is illustrated in the figure below: Inter-sequence machine learning models or deep learning models can be applied to price difference prediction. When selecting a specific threshold, it can be selected according to the distribution of the spread return rate in the past period of time. The specific entry and exit trigger mechanism is illustrated in the figure below: nce. When selecting a specific threshold, it can be selected according to the distribution of the spread return rate in the past period of time. The specific entry and exit trigger mechanism is illustrated in the figure below: The machine learning model or deep learning model of the inter-sequence can be applied to the prediction of the price difference. When selecting a specific threshold, it can be selected according to the distribution of the spread return rate in the past period of time. The specific entry and exit trigger mechanism is illustrated in the figure below:</p></figcaption></figure>

<figure><img src="/files/UEyIlG8bLcc791iwpRNR" alt=""><figcaption></figcaption></figure>

Summarize

In this framework, Dr. Mat Lebiz first applied the unsupervised model in the link of coin pairing, in which PCA was used to extract the features of the coins, and then clustered based on these extracted features. In this process, we can also add other fundamentals The index or factor of is used as the feature of the coin. Then in the specific trading model, apply machine learning to predict the price difference of coin pairs, and trigger trading signals based on the predicted results and predetermined thresholds.
