ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
itch::ReplayEngine Class Reference

Replays a parsed ITCH stream paced by message timestamps. More...

#include <replay.hpp>

Public Member Functions

 ReplayEngine (double speed_multiplier=1.0) noexcept
 Constructs an engine with a speed multiplier.
 
auto set_speed (double speed_multiplier) noexcept -> void
 Sets the speed multiplier (see the constructor).
 
auto speed () const noexcept -> double
 The current speed multiplier.
 
auto replay (std::span< const std::byte > data, const MessageCallback &callback) const -> std::uint64_t
 Parses data and invokes callback for each message, paced by the message timestamps.
 

Detailed Description

Replays a parsed ITCH stream paced by message timestamps.

For realistic backtesting and system simulation, a consumer often needs the feed delivered at its original wall-clock cadence rather than as fast as the CPU can parse it. The replay engine parses a buffer and invokes the callback for each message, sleeping between messages so the inter-message gaps match the differences in their nanoseconds-past-midnight timestamps, optionally scaled by a speed factor.

Definition at line 27 of file replay.hpp.

Constructor & Destructor Documentation

◆ ReplayEngine()

itch::ReplayEngine::ReplayEngine ( double  speed_multiplier = 1.0)
inlineexplicitnoexcept

Constructs an engine with a speed multiplier.

Parameters
speed_multiplierWall-clock speed relative to the original feed: 1.0 replays in real time, 2.0 twice as fast, 0.5 half speed. A value less than or equal to 0 replays with no pacing (as fast as possible).

Definition at line 34 of file replay.hpp.

Member Function Documentation

◆ set_speed()

auto itch::ReplayEngine::set_speed ( double  speed_multiplier) -> void
inlinenoexcept

Sets the speed multiplier (see the constructor).

Parameters
speed_multiplierWall-clock speed relative to the original feed (see the constructor for the exact semantics).

Definition at line 41 of file replay.hpp.

◆ speed()

auto itch::ReplayEngine::speed ( ) const -> double
inlinenoexcept

The current speed multiplier.

Returns
The currently configured speed multiplier.

Definition at line 48 of file replay.hpp.

◆ replay()

auto itch::ReplayEngine::replay ( std::span< const std::byte >  data,
const MessageCallback callback 
) const -> std::uint64_t

Parses data and invokes callback for each message, paced by the message timestamps.

Parameters
dataA view over the contiguous buffer containing ITCH data.
callbackA function to be called for each successfully parsed message.
Returns
The number of messages replayed.

Definition at line 18 of file replay.cpp.

References itch::Parser::parse().


The documentation for this class was generated from the following files: