Backtesting/Emulation
Click or drag to resize

Backtesting/Emulation

Strategies written by using Strategy can be tested in three modes:

  1. Historical data testing. With this kind of data both a market analysis to find patterns and the strategy parameters optimization may be carried out.
  2. Random data testing. A convenient tool for initial strategy testing to identify errors in the algorithms. Or for automated tests that run on a schedule.
  3. Simulator testing based on data received from a real connection to the trading system (for example, from OpenECry), but without the actual orders registration (execution is emulated based on incoming order books).

When using all three modes the maximum emphasis is focused on the fact that the strategy code, written by using Strategy is not changed when switching from real trading to testing and back. This is achieved through the implementation of the IConnector main interface, which is a gateway to the trading system. How the interface is used – this has been shown already in the StockSharp Architecture section. In testing mode not real trading system, but the emulation will act as the trading system (depending on the selected mode). Therefore, the strategy code will never know about it - whether it is trading with a real exchange, or it is the emulation.

The basic requirement for the strategies code is that it should not contain gateway specific operations. For example, if we are talking about the OpenECry the strategy code should not have methods to work with Historical data.