Jump to content
  • How to prepare an application for backtesting historical data


    Issue

    The next step that I would like to bring into our application would be a concept of simulation time to deal with historical events, for example by processing of a set of trades from a time in history.

    Solution

    An application is ready for backtesting and non-real-time testing if it uses timestamps generated externally and has no expressions or constructs that would inject system or wall-clock-time into its expressions.

    The constructs to avoid are:

    • expressions using now(), today(), etc.
    • expressions using system time to generate delays or pauses (except as needed to coordinate with live
    • external systems, e.g. timeout values)
    • time-dimension aggregation
    • Metronome or Heartbeat operators

    Replace references to system time with references to a tuple field containing a timestamp value.

    Replace time-dimension aggregation with field-based aggregation referencing a tuple field containing a timestamp value.

    Similarly, if the data normally enters the application via adapters, it is usually unprofitable to attempt to drive historical data through the adapter.

    There are two alternatives commonly used:

    1. Union every input-adapter output-port with an input stream with the same schema. Use the input stream to inject data into the system. When receiving live data, do not use the paired input streams. When using historical data, set all input adapters to "not start with the application" so they remain idle and do not attempt to connect.
    2. Separate the adapters into their own containers so that those containers may be left unloaded and possibly replaced with a test harness when doing back-testing.

    If the historical input data needs to be delivered to the application using multiple input streams, the sbfeedsim utility knows how to do that. For reference, see the sbfeedsim help:

    • StreamBase Documentation > Test/Debug Guide > Using Feed Simulations

    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...