Using Logs to Replay Market Data
Under normal flow, the Handler logs all important aspects of its execution. Logged events also include the original market data processed by the Handler. Development and support teams may use this information during investigations of non-standard situations. However, it can be used to reproduce normal Handler's behavior for a certain period of time.
The Handler can extract market data from a log file if the OnixS::CME::Streamlined::MDH::FileLogger produced it.
- Warning
- To get market data recorded into a log file, the OnixS::CME::Streamlined::MDH::FileLoggerSettings::severityLevel parameter must be set to either the OnixS::CME::Streamlined::MDH::LogSeverity::Regular or the OnixS::CME::Streamlined::MDH::LogSeverity::Debug value. Otherwise, Handler triggers no market-related events due to absense of a source for those events.
Market data replay can be done with the help of the OnixS::CME::Streamlined::MDH::Handler::replay member. It accepts an instance of OnixS::CME::Streamlined::MDH::ReplaySettings class containing a list of logs for replay.
A collection of log files to replay can be either assigned manually or fulfilled using utility routines provided by the SDK if log files were recorded using standard naming conventions used by the SDK and the OnixS::CME::Streamlined::MDH::FileLogger in particular.
ReplaySettings replaySettings;
replaySettings.logs(),
310,
"logStore");
handler.replay(replaySettings);
Alternatively, it is possible to define a list of log files manually. A manually manipulated list of log files allows replaying log files which names differ from the names used by the Handler.
ReplaySettings replaySettings;
replaySettings.logs().push_back("1.txt");
replaySettings.logs().push_back("2.txt");
replaySettings.logs().push_back("3.txt");
- Note
- Files to be replayed must be in exact order as they were recorded by the Handler in bounds of a single processing session.
-
In contrast to the previous major versions, the Handler performs a log file replay synchronously. As a result, the OnixS::CME::Streamlined::MDH::Handler::replay does not return the control to the caller unless entire data is replayed. The given approach simplifies detection of the end of the replay.
From the event invocation perspective, there's no difference whether the Handler processes market received by the network or from a log file.
- Note
- In case of live market data processing, the Handler raises events that reflect processing results as soon as market data is received from the network and processed. However, the CME Streamlined spreads market data with different frequency, which depends on live market activity. Therefore, there're delays of different duration between triggered events. When the Handler replays a log file, it does not do any pauses between data items, and thus, it raises corresponding events as soon as data is retrieved from that log file.
During the replay, the OnixS::CME::Streamlined::MDH::PacketArgs::receiveTime member returns original time when market data packet was obtained from the network.
- Note
- Currently, log replay must be run with the same set of the Handler's settings which were originally used.
A sample application demonstrating a Log Replay feature can be found in the samples/LogReplay subfolder of the SDK distributive package.