This sample demonstrates how to replay log files for the RDI, EMDI and EOBI feeds.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
22
23#include "RdiListener.h"
24#include "EmdiListener.h"
25#include "EobiListener.h"
26
27#include "../Common/Options.h"
28#include "../Common/Settings.h"
29
32
33class LogReplayConfiguration : public virtual Samples::ConfigurationBase
34{
35public:
36 std::string rdiReplaySource() const
37 {
38 return argOrDefault(options(), "rdiReplaySource", "./logToReplay/rdi.log.bz2");
39 }
40
41 std::string emdiReplaySource() const
42 {
43 return argOrDefault(options(), "emdiReplaySource", "./logToReplay/emdi.log.bz2");
44 }
45
46 std::string eobiReplaySource() const
47 {
48 return argOrDefault(options(), "eobiReplaySource", "./logToReplay/eobi.log.bz2");
49 }
50
51protected:
52 LogReplayConfiguration(size_t qty, char** args)
53 : ConfigurationBase(qty, args)
54 {
55 }
56
57 void showOptions(std::ostream& out) const override
58 {
59 out
60 << " --rdiReplaySource [filePath]" << std::endl
61 << "\tDefault value is ['./logToReplay/rdi.log.bz2']" << std::endl
62 << " --emdiReplaySource [filePath]" << std::endl
63 << "\tDefault value is ['./logToReplay/emdi.log.bz2']" << std::endl
64 << " --eobiReplaySource [filePath]" << std::endl
65 << "\tDefault value is ['./logToReplay/eobi.log.bz2']" << std::endl
66 ;
67 }
68};
69
70template <typename Configuration>
71void runRdiHandler(const Configuration& cfg)
72{
73 RdiListener listener;
74
76 replayOptions.
logs = {cfg.rdiReplaySource()};
78
79 RdiHandler handler(Samples::makeSettings<RdiHandlerSettings>(cfg));
80 handler.registerErrorListener(&listener);
81 handler.registerWarningListener(&listener);
82 handler.registerReferenceDataListener(&listener);
83
84 std::clog << "Will start the RDI Handler in replay log mode ..." << std::endl;
85 handler.start(replayOptions);
86
87 listener.waitUntilReplayFinished();
88
89 std::clog << "RDI Handler Replay finished" << std::endl;
90}
91
92template <typename Configuration>
93void runEmdiHandler(const Configuration& cfg)
94{
95 EmdiListener listener;
96
98 replayOptions.
logs = {cfg.emdiReplaySource()};
100
101 EmdiHandler handler(Samples::makeSettings<EmdiHandlerSettings>(cfg));
102 listener.subscribe(handler);
103
105 map[190] = 10;
106
107 handler.setMarketSegmentId2Depth(map);
108
109 handler.setPartitionIdFilters({3});
110 handler.setMarketSegmentIdFilters({190});
111
112 std::clog << "Will start the EMDI Handler in replay log mode ..." << std::endl;
113 handler.start(replayOptions);
114
115 listener.waitUntilReplayFinished();
116
117 std::clog << "EMDI Handler Replay finished" << std::endl;
118}
119
120template <typename Configuration>
121void runEobiHandler(const Configuration& cfg)
122{
123 EobiListener listener;
124
126 replayOptions.
logs = {cfg.eobiReplaySource()};
128
129 auto settings = Samples::makeSettings<EobiHandlerSettings>(cfg);
130 settings.bookDepth = 10;
131
133 listener.subscribe(handler);
134
135 std::clog << "Will start the EOBI Handler in replay log mode ..." << std::endl;
136 handler.start(replayOptions);
137
138 listener.waitUntilReplayFinished();
139 std::clog << "EOBI Handler Replay finished" << std::endl;
140}
141
143int main(int argc, char* argv[])
144{
145
146 const Samples::AppConfiguration<Samples::LogDirectoryConfiguration, LogReplayConfiguration> cfg{"Backtesting", argc, argv};
147
148 try
149 {
150 runRdiHandler(cfg);
151 runEmdiHandler(cfg);
152 runEobiHandler(cfg);
153 }
154 catch(const std::exception& ex)
155 {
156 std::cerr << "EXCEPTION: " << ex.what() << std::endl;
157 }
158
159 return 0;
160}
Eurex Enhanced Order Book Interface Handler.
Eurex Enhanced Market Data Interface Handler.
Eurex Reference Data Interface Handler.
MarketDepthTraits::MarketSegmentId2Depth MarketSegmentId2Depth
Set the ReplayOptions to run the replay at maximal speed.
ReplayListener * listener
Instance to notify about replay events.
1#pragma once
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <iostream>
21
27
28
29class RdiListener final
34{
35public:
37 RdiListener();
38
40 ~RdiListener() override;
41
44
46 void onWarning(
const std::string& description)
override;
47
48 void onReplayError(
const std::string& errorDescription)
override
49 {
50 std::clog << "Replay error: " << errorDescription << std::endl;
51 replaySemaphore_.release();
52 }
53
55 {
56 replaySemaphore_.release();
57 }
58
60 void waitUntilReplayFinished()
61 {
62 replaySemaphore_.acquire();
63 }
64
67
69 void onProduct(
const OnixS::Eurex::MarketData::ProductSnapshot& productSnapshot,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
70
72 void onInstrument(
const OnixS::Eurex::MarketData::InstrumentSnapshot& msg,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
73
75 void onInstrumentIncremental(
const OnixS::Eurex::MarketData::InstrumentIncremental& msg,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
76
78 void onVarianceFuturesStatus(
const OnixS::Eurex::MarketData::VarianceFuturesStatus& msg,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
79
81 void onTotalReturnFuturesStatus(
const OnixS::Eurex::MarketData::TotalReturnFuturesStatus& msg,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
82
84 void onTradeAtReferencePriceStatus(
const OnixS::Eurex::MarketData::TradeAtReferencePriceStatus& msg,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
85
88
89private:
91 OnixS::Eurex::MarketData::Semaphore replaySemaphore_;
92};
virtual void onError(ErrorCode::Enum code, const std::string &description)=0
virtual void onTradeAtReferencePriceStatus(const TradeAtReferencePriceStatus &status, const DataSource &dataSource)=0
Is called when TradeAtReferencePriceStatus message is received.
virtual void onSnapshotCycleStart()=0
Is called when reference data snapshot cycle is started.
virtual void onVarianceFuturesStatus(const VarianceFuturesStatus &status, const DataSource &dataSource)=0
Is called when variance futures status is received.
virtual void onSnapshotCycleEnd()=0
Is called when reference data snapshot cycle is ended.
virtual void onInstrumentIncremental(const InstrumentIncremental &incremental, const DataSource &dataSource)=0
Is called when instrument incremental update is received.
virtual void onProduct(const ProductSnapshot &snapshot, const DataSource &dataSource)=0
Is called when product snapshot is received.
virtual void onTotalReturnFuturesStatus(const TotalReturnFuturesStatus &status, const DataSource &dataSource)=0
Is called when total return futures status message is received.
virtual void onInstrument(const InstrumentSnapshot &snapshot, const DataSource &dataSource)=0
Is called when instrument snapshot is received.
Listening interface for log replay-related events.
virtual void onReplayFinished()=0
Is called once the replay is finished.
virtual void onReplayError(const std::string &errorDescription)=0
Is called once error occurs while replaying.
virtual void onWarning(const std::string &reason)=0
Is called when the Warning condition is detected.
Enum
Known (selected) error codes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#pragma once
20
21#include <iostream>
22#include <sstream>
23
40
41class EmdiListener final
56{
57public:
59 EmdiListener();
60
62 ~EmdiListener() override;
63
65
68
70 void onWarning(
const std::string& description)
override;
71
72 void onReplayError(
const std::string& errorDescription)
override
73 {
74 std::clog << "Replay error: " << errorDescription << std::endl;
75 replaySemaphore_.release();
76 }
77
79 {
80 replaySemaphore_.release();
81 }
82
84 void waitUntilReplayFinished()
85 {
86 replaySemaphore_.acquire();
87 }
88
89 void onDepthSnapshot(
const OnixS::Eurex::MarketData::DepthSnapshot& snapshot,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
90
92 void onDepthIncremental(
const OnixS::Eurex::MarketData::DepthIncremental& incremental,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
93
96
99
101 void onTopOfBookImplied(
const OnixS::Eurex::MarketData::TopOfBookImplied& msg,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
102
104 void onProductStateChange(
const OnixS::Eurex::MarketData::ProductStateChange& change,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
105
107 void onMassInstrumentStateChange(
const OnixS::Eurex::MarketData::MassInstrumentStateChange& change,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
108
110 void onInstrumentStateChange(
const OnixS::Eurex::MarketData::InstrumentStateChange& change,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
111
113 void onQuoteRequest(
const OnixS::Eurex::MarketData::QuoteRequest& request,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
114
116 void onCrossRequest(
const OnixS::Eurex::MarketData::CrossRequest& request,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
117
119 void onComplexInstrumentUpdate(
const OnixS::Eurex::MarketData::ComplexInstrumentUpdate& update,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
120
122 void onFlexibleInstrumentUpdate(
const OnixS::Eurex::MarketData::FlexibleInstrumentUpdate& update,
const OnixS::Eurex::MarketData::DataSource& dataSource)
override;
123
126
129
131 void onSnapshotTrade(
const OnixS::Eurex::MarketData::SnapshotTrade& trade)
override;
132
134 void onIncrementalTrade(
const OnixS::Eurex::MarketData::IncrementalTrade& trade)
override;
135
136private:
138 OnixS::Eurex::MarketData::Semaphore replaySemaphore_;
139};
Complex Instrument Update listener.
virtual void onComplexInstrumentUpdate(const ComplexInstrumentUpdate &update, const DataSource &dataSource)=0
Is called when complex instrument update is received.
virtual void onCrossRequest(const CrossRequest &request, const DataSource &dataSource)=0
Is called when cross request is received.
virtual void onDepthReset(MarketSegmentId marketSegmentId)=0
Is called when all the books are reset for a given market segment.
virtual void onDepthOutOfDate(MarketSegmentId marketSegmentId)=0
virtual void onDepthSnapshot(const DepthSnapshot &snapshot, const DataSource &dataSource)=0
Is called when depth snapshot is received.
virtual void onDepthIncremental(const DepthIncremental &incremental, const DataSource &dataSource)=0
Is called when depth incremental is received.
Flexible Instrument Update listener.
virtual void onFlexibleInstrumentUpdate(const FlexibleInstrumentUpdate &update, const DataSource &dataSource)=0
Is called when mass instrument state change is received.
Instrument State Change listener.
virtual void onInstrumentStateChange(const InstrumentStateChange &change, const DataSource &dataSource)=0
Is called when instrument state change is received.
Mass Instrument State Change listener.
virtual void onMassInstrumentStateChange(const MassInstrumentStateChange &change, const DataSource &dataSource)=0
Is called when mass instrument state change is received.
virtual void onOrderBookUpdated(const OrderBook &book)=0
virtual void onOrderBookOutOfDate(const OrderBook &book)=0
Product State Change listener.
virtual void onProductStateChange(const ProductStateChange &change, const DataSource &dataSource)=0
Is called when product state change is received.
virtual void onQuoteRequest(const QuoteRequest &request, const DataSource &dataSource)=0
Is called when quote request is received.
Top Of Book Implied listener.
virtual void onTopOfBookImplied(const TopOfBookImplied &msg, const DataSource &dataSource)=0
Is called when Top Of Book Implied message is received.
virtual void onSnapshotTrade(const SnapshotTrade &trade)=0
Is called when a snapshot trade market data entry is received.
virtual void onIncrementalTrade(const IncrementalTrade &trade)=0
Is called when a incremental trade market data entry is received.
UInt32 MarketSegmentId
Alias for Market Segment ID type.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include "EmdiListener.h"
20
22
23
24
25
26
27EmdiListener::EmdiListener()
28 : replaySemaphore_(0)
29{
30}
31
33{
47}
48
49EmdiListener::~EmdiListener() = default;
50
51void EmdiListener::onError(
ErrorCode::Enum code,
const std::string& description)
52{
53 std::clog <<
"Error occurred, errorCode = " <<
enumToString(code) <<
". Description: '" << description <<
"'" << std::endl;
54}
55
56void EmdiListener::onWarning(const std::string& description)
57{
58 std::stringstream ss;
59 std::clog << "Warning occurred. Description: '" << description << "'" << std::endl;
60}
61
63{
64 std::clog <<
"Message received: " << msg.
toString(
'|') << std::endl;
65}
66
68{
69 std::clog <<
"Message received: " << msg.
toString(
'|') << std::endl;
70}
71
73{
74}
75
77{
78}
79
81{
82}
83
85{
86}
87
89{
90}
91
93{
94}
95
97{
98}
99
101{
102}
103
105{
106}
107
109{
110}
111
112void EmdiListener::onOrderBookUpdated(
const OrderBook&)
113{
114}
115
116void EmdiListener::onOrderBookOutOfDate(
const OrderBook&)
117{
118}
119
121{
122}
123
125{
126}
Complex instrument update.
EmdiHandler & registerWarningListener(WarningListener *listener)
EmdiHandler & registerErrorListener(ErrorListener *listener)
EmdiHandler & registerCrossRequestListener(CrossRequestListener *listener)
EmdiHandler & registerMassInstrumentStateChangeListener(MassInstrumentStateChangeListener *listener)
EmdiHandler & registerTopOfBookImpliedListener(TopOfBookImpliedListener *listener)
EmdiHandler & registerTradeListener(TradeListener *listener)
EmdiHandler & registerQuoteRequestListener(QuoteRequestListener *listener)
EmdiHandler & registerComplexInstrumentUpdateListener(ComplexInstrumentUpdateListener *listener)
EmdiHandler & registerInstrumentStateChangeListener(InstrumentStateChangeListener *listener)
EmdiHandler & registerOrderBookListener(OrderBookListener *listener)
EmdiHandler & registerFlexibleInstrumentUpdateListener(FlexibleInstrumentUpdateListener *listener)
EmdiHandler & registerProductStateChangeListener(ProductStateChangeListener *listener)
EmdiHandler & registerDepthListener(DepthListener *listener)
Mass instrument state change.
Mass instrument state change.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <iostream>
20#include <sstream>
21
23
24#include "EobiListener.h"
25
28
29
30
31
32
33EobiListener::EobiListener()
34 : replaySemaphore_(0)
35{
36}
37
39{
50}
51
52EobiListener::~EobiListener() = default;
53
54void EobiListener::onError(
ErrorCode::Enum code,
const std::string& description)
55{
56 std::clog <<
"Error occurred, errorCode = " <<
enumToString(code) <<
". Description: '" << description <<
"'" << std::endl;
57}
58
59void EobiListener::onWarning(const std::string& description)
60{
61 std::stringstream ss;
62 std::clog << "Warning occurred. Description: '" << description << "'" << std::endl;
63}
64
65void EobiListener::onReplayError(const std::string& errorDescription)
66{
67 std::clog << "Replay error: " << errorDescription << std::endl;
68 replaySemaphore_.release();
69}
70
71void EobiListener::onReplayFinished()
72{
73 replaySemaphore_.release();
74}
75
77void EobiListener::waitUntilReplayFinished()
78{
79 replaySemaphore_.acquire();
80}
81
83{
84 std::clog <<
"Handler state changed: " <<
enumToString(newState) << std::endl;
85}
86
88{
90}
91
92void EobiListener::onOrderAdd(
const OrderAdd& msg)
93{
94 std::clog << "Message received: " << toString(msg) << std::endl;
95}
96
97void EobiListener::onOrderModify(
const OrderModify& msg)
98{
99 std::clog << "Message received: " << toString(msg) << std::endl;
100}
101
103{
104 std::clog << "Message received: " << toString(msg) << std::endl;
105}
106
107void EobiListener::onOrderDelete(
const OrderDelete& msg)
108{
109 std::clog << "Message received: " << toString(msg) << std::endl;
110}
111
113{
114 std::clog << "Message received: " << toString(msg) << std::endl;
115}
116
118{
119 std::clog << "Message received: " << toString(msg) << std::endl;
120}
121
123{
124 std::clog << "Message received: " << toString(msg) << std::endl;
125}
126
128{
129 std::clog << "Message received: " << toString(msg) << std::endl;
130}
131
133{
134 std::clog << "Message received: " << toString(msg) << std::endl;
135}
136
137void EobiListener::onTopOfBook(
const TopOfBook& msg)
138{
139 std::clog << "Message received: " << toString(msg) << std::endl;
140}
141
143{
144 std::clog << "Message received: " << toString(msg) << std::endl;
145}
146
148{
149 std::clog << "Message received: " << toString(msg) << std::endl;
150}
151
153{
154 std::clog << "Message received: " << toString(msg) << std::endl;
155}
156
157void EobiListener::onTradeReport(
const TradeReport& msg)
158{
159 std::clog << "Message received: " << toString(msg) << std::endl;
160}
161
163{
164 std::clog << "Message received: " << toString(msg) << std::endl;
165}
166
168{
169 std::clog << "Message received: " << toString(msg) << std::endl;
170}
171
173{
174 std::clog << "Message received: " << toString(msg) << std::endl;
175}
176
178{
179 std::clog << "Message received: " << toString(msg) << std::endl;
180}
181
182void EobiListener::onMassInstrumentStateChange(
184{
185 std::clog << "Message received: " << toString(msg) << std::endl;
186}
187
189{
190 std::clog << "Message received: " << toString(msg) << std::endl;
191}
192
194{
195 std::clog << "Message received: " << toString(msg) << std::endl;
196}
197
199{
200 std::clog << "Message received: " << toString(msg) << std::endl;
201}
202
204{
205 std::clog << "Message received: " << toString(msg) << std::endl;
206}
207
209{
210 std::clog << "Message received: " << toString(msg) << std::endl;
211}
212
214{
215 std::clog << "Message received: " << toString(msg) << std::endl;
216}
217
219{
220}
221
223{
224}
225
227{
228}
229
231{
232}
233
234void EobiListener::onSnapshotCycleBegin()
235{
236}
237
238void EobiListener::onSnapshotCycleEnd()
239{
240}
EobiHandler & registerMessageListener(MessageListener *listener)
EobiHandler & registerWarningListener(WarningListener *listener)
EobiHandler & registerHandlerStateListener(HandlerStateListener *listener)
EobiHandler & registerOrderBookListener(OrderBookListener *listener)
EobiHandler & registerStateChangeListener(StateChangeListener *listener)
EobiHandler & registerSnapshotListener(SnapshotListener *listener)
EobiHandler & registerErrorListener(ErrorListener *listener)
EobiHandler & registerReferenceDataListener(ReferenceDataListener *listener)
EobiHandler & registerTradeDataListener(TradeDataListener *listener)
EobiHandler & registerOrderDataListener(OrderDataListener *listener)
std::string toString() const
Returns text presentation.