Backtesting

  1. Home
  2. Docs
  3. Goods
  4. Statistical Arbitrage
  5. Backtesting

Backtesting

When we need to test the desired pairs of markets on history, we need to open the testing and optimization module, select the automatic trading system that we want to test and carry out the initial settings

The initial settings are the same for all trading strategies. In these settings, we first select the test period, and then the trading instruments whose data will be available at the time of testing. Then we click on general settings and configure in more detail the market conditions that the backtester will emulate and also configure the trading instruments we have chosen. 

There are not many general settings; in fact, there is only a starting balance with which testing will begin. If you are testing cryptocurrency markets, then it is better to set the deposit size equal to 1000 units, and if you are testing real market futures, then you need to bet 100,000 units, since the calculation of the volume will be based on the value of the contracts, and only whole parts of the contracts will be used, given that the value of the contracts starts from 5,000 or more, you should choose exactly 100,000 or even more if the contract in your market is more expensive.

Now let’s move on to setting up the trading instruments under study. In our case, there are two of them and they have the same settings, so let’s look at this using the example of one of them

Netting type should be set to One Position, because the bot calculates mathematics based on the fact that it works with only one position, and all its simultaneously open positions are virtual.

DOM level size type should be set to Custom so that we can also set this volume value in the Custom DOM level size input field so that we can emulate ideal trade execution.

Let’s go down the settings below and go to the commission settings, here you just need to configure the type of commission that corresponds to the tariffs of your boxer or exchange. In the images above you can see the settings for SWAP trading instruments of the Binance crypto exchange.

We perform the same actions for the second trading instrument and close this menu. Now we are ready to move on to setting up the trading strategy itself and the testing process.

The detailed values of all the settings with which you can adjust the operating modes are described in this documentation in the settings section, and now we will go through the settings in general terms, so that this will be enough for a backtest of the main strategy of this bot.

  • Base account, Quote account – We have access to the only tester account, and we select it.
  • Base symbol, Quote symbol – Let’s assign the base and quoting trading instruments as our first and second trading instruments added to testing, respectively. 
  • Instance name – You can write any values ​​here; this is not relevant in the tester.
  • Period – We indicate the same period that we used to search for pairs of trading instruments using the correlation matrix. In our case it is 1Н (one hour).
  • Work mode – Let’s specify ON for the bot to make transactions.
  • Trading instrument – Let’s indicate both. In this mode, transactions will be made with both trading instruments towards each other.
  • Trading direction – Let’s indicate both. In this mode, both long and short positions will be opened.
  • Normalization period – Let’s set it to 300. This setting has been found through a lot of testing and is most appropriate in general cases, but you can try changing it.
  • Base step – Let’s indicate 1. Depending on the size of the spread by which the two trading symbols under study diverge, you can enter values ​​from 1 to 5.
  • Base step factor – Let’s indicate 1.5. This value increases the distance of the next trigger to the current one, relative to the distance from the previous one to the current one. As a result, each new trigger moves further towards this factor.
  • Max open positions – Let’s indicate 10. It must be taken into account that one trigger trigger generates two opposite positions, that is, 10 open positions are 5 triggers; on the sixth trigger, positions will not be entered.
  • Quantity % – Let’s indicate 10. This is the amount as a percentage of the available deposit balance for which each transaction is opened. Too high a value is fraught with high risks, but also with rapid acceleration of the deposit.
  • Round digits – Let’s indicate 2. This parameter does not participate in any way in the trading logic, but is only needed for rounding the output values ​​of the strategy.

There is another setting for the testing process called Processing mode; it needs to be set to Background to speed up the testing process.

After we have set all the necessary settings, press the START NEW BACKTEST button and we will start one testing instance. There is no need to wait for it to complete, since 10 copies can be tested at once. Therefore, we simply immediately change the settings of trading instruments to the following from your list and launch a new example.

After testing is completed, the test results will be available to us and we can proceed to analyzing the results and selecting trading markets for real trading

How can we help?