The backtesting platform: The architecture and its requirements

The multi-layer architecture of backtesting platform for evaluating quantitative order processing strategies’ results.
Figure 1- The multi-layer architecture of backtesting platform

Layer one: Fetch Data

Exchanges often provide traders with standard APIs to get historical data. The priority is to have access to price data with different time intervals and precise information to build a backtesting platform. This layer implements the functions or methods to retrieve data from various exchanges through standard APIs and store them in the OLHCV candle price format. In this part, the user just needs to determine the start and end time of data, the list of symbols, and the time interval. While we fix the input and output format in this layer, we can change the internal APIs and exchange logic. We have two different functions for fetching data. One is based on the time range, and the other is based on the number of data points. More detail is shown in figure.2.

The first layer of backtesting architecture for evaluating quantitative trading strategies: fetching data from exchanges
figure 2- The first layer of backtesting architecture: The fetch data layer

Layer two: Feature Extraction

This layer consists of two different modules. The first is feature extraction, and the second one is labeling. Each machine learning model needs data as a feature vector to work and also requires labels if supervised methods are employed. At Eveince, the data team aims to develop quantitative trading strategies with a particular concentration on machine learning methods and models. Hence, feature vectors are one of the most critical aspects of our work. This layer uses technical indicators, fundamental data, and augmented variables as features. You can enrich your indicator library by adding the most useful technical indicators and designing new indicators to represent further aspects of price data in your indicators pool.

The second layer of backtesting architecture for evaluating quantitative trading strategies: feature and label extraction from exchange data
figure 3- The second layer of backtesting architecture: The feature extraction layer

Layer three: Model Fit and Predict

This layer consists of three super important sub-layers in our backtesting procedure. In the first sub-layer, the activities for training and inferencing are done thoroughly, which is the most vital part of our platform. The way that we recognize patterns from feature vectors and how to analyze them quantitatively is determined in this step. We just change the logic in these procedures to explore new ideas or models. To run this sub-layer, we need to determine train and test data, the time for backtesting, and the model’s parameters. The training phase should be executed when we build new models, but the inferencing phase is always performed during backtesting. The outputs are the probabilities and confidence scores of inferences; most of the time, we cannot use them directly to make final decisions. Based on this fact, we need another sub-layer that gets the inferences outputs and convert them into the expectations, which can be used as data for creating final orders. This layer is a mapping between inferences and the expectation of market behavior.

The third layer of backtesting architecture for evaluating quantitative trading strategies: model fit and predict the market from the exchange data
figure 4- The third layer of backtesting architecture: The model fit and predict layer

Layer four: Execution

Execution is the primary layer for creating and executing orders which generate portfolios. It consists of two sub-layers which are execution and portfolio re-balancing. The first one uses the expectation values from the previous layer and converts them into executable orders in the exchange. Like other backtesting platforms, the portfolio values are calculated by simulating the execution without volume restriction. The execution can be long or short, and we support both by implementing spot and future execution methods. In this section, the function uses parameters from the configuration file and the price data for execution. Every order executed in the simulation will update the portfolio value. It means the exact asset value should be calculated according to the profit or loss from the trade and the commission that must be reduced from the asset based on the amount of the trade. In this section, we also manage risk by adjusting the position size based on the risk we can tolerate by measuring the asset risk and the future expectation.

The third layer of backtesting architecture for evaluating quantitative trading strategies: backtest, and rebalancing portfolio
figure 5- The fourth layer of backtesting architecture: The execution model

Layer five: Analytics

This layer is developed to observe and analyze the backtesting results and the portfolio’s performance metrics. It consists of two sub-layer, and the first one is responsible for generating the experiment data for the visualizer segment. This layer divides the output into broker and individual symbols performance.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eveince

Eveince

46 Followers

Eveince is FinTech company, providing a self-driving hedge fund for HNWIs. The funds are developed using AI and ML with quantitative finance approach.