OnixS C++ Eurex T7 Market and Reference Data (EMDI, MDI, RDI, EOBI) Handlers 20.0.1
Users' manual and API documentation
Loading...
Searching...
No Matches
Getting Started Sample

This sample demonstrates how to connect to the RDI, EMDI and EOBI feeds.

Source code

1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
25
26#include "RdiListener.h"
27#include "EmdiListener.h"
28#include "MdiListener.h"
29#include "EobiListener.h"
30
31#include "../Common/Signal.h"
32#include "../Common/Options.h"
33#include "../Common/Settings.h"
34#include "../Common/Utils.h"
35
36using namespace OnixS::Eurex::MarketData;
37using namespace OnixS::Eurex::MarketData::EOBI;
38
39template <typename Configuration> std::unique_ptr<EmdiHandlerManager> makeEmdiHandlerManager(EmdiListener&, const Configuration&);
40template <typename Configuration> std::unique_ptr<MdiHandlerManager> makeMdiHandlerManager(MdiListener&, const Configuration& );
41template <typename Configuration> std::unique_ptr<EobiHandlerManager> makeEobiHandlerManager(EobiListener&, const Configuration&);
42
44int main(int argc, char* argv[])
45{
46 // `--help` to show options.
47 const Samples::AppConfiguration<
48 Samples::NetworkInterfaceConfiguration
49 , Samples::EnvironmentConfiguration
50 , Samples::LogDirectoryConfiguration
51 > cfg{"GettingStarted", argc, argv};
52
53 try
54 {
55 Samples::SignalHelper::manageSignals();
56
57 auto rdiSettings = Samples::makeSettings<RdiHandlerSettings>(cfg);
58 fillEnvironment(rdiSettings, cfg);
59
60 SocketFeedEngine feedEngine;
61 FeedEngineThreadPoolSettings feedEngineThreadPoolSettings;
62 FeedEngineThreadPool pool(feedEngineThreadPoolSettings, &feedEngine);
63
64 RdiListener rdiListener{rdiSettings.logDirectory};
65 auto rdiHandler = Samples::makeUnique<RdiHandler>(rdiSettings);
66
67 rdiHandler->bindFeedEngine(feedEngine);
68
69 rdiHandler
70 ->registerErrorListener(&rdiListener)
71 .registerWarningListener(&rdiListener)
72 .registerReferenceDataListener(&rdiListener);
73
74 std::clog << "Will start the RDI Handler ..." << std::endl;
75 rdiHandler->start();
76
77 rdiListener.waitUntilReferenceDataReceived();
78
79 const MarketSegments productNames {"FDAX", "FGBL", "FGBM"};
80
81 EmdiListener emdiListener{rdiSettings.logDirectory};
82 MdiListener mdiListener{rdiSettings.logDirectory};
83 EobiListener eobiListener;
84
85 auto emdiHandlerManager = makeEmdiHandlerManager(emdiListener, cfg);
86 auto mdiHandlerManager = makeMdiHandlerManager(mdiListener, cfg);
87 auto eobiHandlerManager = makeEobiHandlerManager(eobiListener, cfg);
88
89 emdiHandlerManager->start(rdiHandler.get(), productNames, feedEngine);
90 mdiHandlerManager->start(rdiHandler.get(), productNames, feedEngine);
91 eobiHandlerManager->start(rdiHandler.get(), productNames, feedEngine);
92
93 Samples::SignalHelper::waitUntilKey("to stop the handlers");
94
95 std::clog << "Stopping..." << std::endl;
96
97 rdiHandler->stop();
98 emdiHandlerManager->stop();
99 eobiHandlerManager->stop();
100 mdiHandlerManager->stop();
101
102 std::clog << "All the Handlers are stopped." << std::endl;
103 }
104 catch(const std::exception& ex)
105 {
106 std::cerr << "EXCEPTION: " << ex.what() << std::endl;
107 }
108
109 return 0;
110}
111
112template <typename Configuration>
113std::unique_ptr<EmdiHandlerManager> makeEmdiHandlerManager(EmdiListener& listener, const Configuration& cfg)
114{
115 auto manager = Samples::makeUnique<EmdiHandlerManager>(Samples::makeSettings<EmdiHandlerSettings>(cfg));
116
117 manager->
118 registerDepthListener(&listener)
119 .registerErrorListener(&listener)
120 .registerWarningListener(&listener)
121 .registerTopOfBookImpliedListener(&listener)
122 .registerProductStateChangeListener(&listener)
123 .registerMassInstrumentStateChangeListener(&listener)
124 .registerInstrumentStateChangeListener(&listener)
125 .registerQuoteRequestListener(&listener)
126 .registerCrossRequestListener(&listener)
127 .registerComplexInstrumentUpdateListener(&listener)
128 .registerFlexibleInstrumentUpdateListener(&listener)
129 .registerOrderBookListener(&listener)
130 .registerTradeListener(&listener);
131
132 return manager;
133}
134
135template <typename Configuration>
136std::unique_ptr<MdiHandlerManager> makeMdiHandlerManager(MdiListener& listener, const Configuration& cfg)
137{
138 auto manager = Samples::makeUnique<MdiHandlerManager>(Samples::makeSettings<MdiHandlerSettings>(cfg));
139
140 manager->
141 registerDepthListener(&listener)
142 .registerErrorListener(&listener)
143 .registerWarningListener(&listener)
144 .registerTopOfBookImpliedListener(&listener)
145 .registerProductStateChangeListener(&listener)
146 .registerMassInstrumentStateChangeListener(&listener)
147 .registerInstrumentStateChangeListener(&listener)
148 .registerQuoteRequestListener(&listener)
149 .registerCrossRequestListener(&listener)
150 .registerComplexInstrumentUpdateListener(&listener)
151 .registerFlexibleInstrumentUpdateListener(&listener)
152 .registerOrderBookListener(&listener)
153 .registerTradeListener(&listener);
154
155 return manager;
156}
157
158template <typename Configuration>
159std::unique_ptr<EobiHandlerManager> makeEobiHandlerManager(EobiListener& listener, const Configuration& cfg)
160{
161 auto manager = Samples::makeUnique<EobiHandlerManager>(Samples::makeSettings<EobiHandlerSettings>(cfg));
162
163 manager->
164 registerErrorListener(&listener)
165 .registerWarningListener(&listener)
166 .registerHandlerStateListener(&listener)
167 .registerOrderDataListener(&listener)
168 .registerTradeDataListener(&listener)
169 .registerStateChangeListener(&listener)
170 .registerReferenceDataListener(&listener)
171 .registerSnapshotListener(&listener)
172 .registerMessageListener(&listener)
173 .registerOrderBookListener(&listener);
174
175 return manager;
176}
A pool of threads executing feed engine tasks.
Definition FeedEngine.h:350
The given class implements feed engine concept using pool of working threads and standard socket API.
Definition FeedEngine.h:139
IInterfaceDescriptorProvider::MarketSegments MarketSegments
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#pragma once
20
21#include <iostream>
22#include <fstream>
23
28
29class RdiListener final
33{
34public:
36 explicit RdiListener(const std::string& logDir);
37
39 ~RdiListener() override;
40
42 void onError(OnixS::Eurex::MarketData::ErrorCode::Enum code, const std::string& description) override;
43
45 void onWarning(const std::string& description) override;
46
48 void onSnapshotCycleStart() override;
49
52
55
58
61
64
67
69 void onSnapshotCycleEnd()override;
70
72 void waitUntilReferenceDataReceived();
73
74
75private:
77 OnixS::Eurex::MarketData::Semaphore referenceDataReady_;
78
79 std::ofstream referenceDataLog_;
80
81 std::string lastProductName_;
82
83 unsigned int lasProductInstrumentNumber_{};
84};
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.
virtual void onWarning(const std::string &reason)=0
Is called when the Warning condition is detected.
Enum
Known (selected) error codes.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#include <sstream>
20
21#include "RdiListener.h"
22
23using namespace OnixS::Eurex::MarketData;
24using namespace OnixS::Eurex::MarketData::EOBI;
25
26/*
27 RdiListener
28*/
29
30RdiListener::RdiListener(const std::string& logDir)
31 : referenceDataReady_(0)
32{
33 const std::string referenceDataLogName = logDir + "/ReferenceData.txt";
34 referenceDataLog_.open(referenceDataLogName.c_str());
35 if(!referenceDataLog_)
36 throw std::domain_error("Cannot open " + referenceDataLogName);
37}
38
39RdiListener::~RdiListener() = default;
40
41void RdiListener::onError(ErrorCode::Enum code, const std::string& description)
42{
43 std::clog << "Error occurred, errorCode = " << enumToString(code) << ". Description: '" << description << "'" << std::endl;
44}
45
46void RdiListener::onWarning(const std::string& description)
47{
48 std::stringstream ss;
49 std::clog << "Warning occurred. Description: '" << description << "'" << std::endl;
50}
51
52void RdiListener::onSnapshotCycleStart()
53{
54 referenceDataLog_ << "onSnapshotCycleStart" << std::endl;
55 std::clog << "onSnapshotCycleStart" << std::endl;
56}
57
58void RdiListener::onProduct(const ProductSnapshot& msg, const DataSource&)
59{
60 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
61
62 if(!lastProductName_.empty())
63 std::clog << lastProductName_ << "(" << lasProductInstrumentNumber_ << "), ";
64
65 lastProductName_ = msg.marketSegment().toString();
66 lasProductInstrumentNumber_ = 0;
67}
68
69void RdiListener::onInstrument(const InstrumentSnapshot& msg, const DataSource&)
70{
71 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
72
73 ++lasProductInstrumentNumber_;
74}
75
76void RdiListener::onInstrumentIncremental(const InstrumentIncremental& msg, const DataSource&)
77{
78 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
79}
80
81void RdiListener::onVarianceFuturesStatus(const VarianceFuturesStatus& msg, const DataSource&)
82{
83 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
84}
85
86void RdiListener::onTotalReturnFuturesStatus(const TotalReturnFuturesStatus& msg, const DataSource&)
87{
88 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
89}
90
91void RdiListener::onTradeAtReferencePriceStatus(const TradeAtReferencePriceStatus& msg, const DataSource&)
92{
93 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
94}
95
96void RdiListener::onSnapshotCycleEnd()
97{
98 referenceDataLog_ << "onSnapshotCycleEnd" << std::endl;
99 std::clog << std::endl << "onSnapshotCycleEnd" << std::endl;
100 referenceDataReady_.release();
101}
102
103void RdiListener::waitUntilReferenceDataReceived()
104{
105 referenceDataReady_.acquire();
106}
std::string toStringWithFieldNames() const
Definition Message.h:111
StringRef marketSegment() const
Product name.
void toString(std::string &str) const
Definition StringRef.h:175
std::string enumToString(HandlerState::Enum)
Returns string representation of HandlerState value.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#pragma once
20
21#include <fstream>
22#include <iostream>
23
37
38
39class EmdiListener final
53{
54public:
56 explicit
57 EmdiListener(const std::string& logDir, size_t outputNormalizer = 100);
58
60 ~EmdiListener() override;
61
63 void onError(OnixS::Eurex::MarketData::ErrorCode::Enum code, const std::string& description) override;
64
66 void onWarning(const std::string& description) override;
67
70
73
75 void onDepthReset(OnixS::Eurex::MarketData::MarketSegmentId marketSegmentId) override;
76
79
82
85
88
91
94
97
100
103
106
109
112
115
116private:
117 std::ofstream marketDataLog_;
118
119 size_t outputNormalizer_;
120};
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.
virtual void onFlexibleInstrumentUpdate(const FlexibleInstrumentUpdate &update, const DataSource &dataSource)=0
Is called when mass instrument state change is received.
virtual void onInstrumentStateChange(const InstrumentStateChange &change, const DataSource &dataSource)=0
Is called when instrument state change is received.
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
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.
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.
Definition Defines.h:40
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#include <sstream>
20
32
33#include "EmdiListener.h"
34
35using namespace OnixS::Eurex::MarketData;
36
37/*
38 EmdiListener
39*/
40
41EmdiListener::EmdiListener(const std::string& logDir, size_t outputNormalizer)
42 : outputNormalizer_(outputNormalizer)
43{
44 const std::string marketDataLogName = logDir + "/MarketData.txt";
45 marketDataLog_.open(marketDataLogName.c_str());
46 if(!marketDataLog_)
47 throw std::domain_error("Cannot open " + marketDataLogName);
48}
49
50EmdiListener::~EmdiListener() = default;
51
52void EmdiListener::onError(ErrorCode::Enum code, const std::string& description)
53{
54 std::clog << "Error occurred, errorCode = " << enumToString(code) << ". Description: '" << description << "'" << std::endl;
55}
56
57void EmdiListener::onWarning(const std::string& description)
58{
59 std::stringstream ss;
60 std::clog << "Warning occurred. Description: '" << description << "'" << std::endl;
61}
62
63void EmdiListener::onDepthSnapshot(const DepthSnapshot&, const DataSource&)
64{
65 static size_t counter = 0;
66 if(0 == ++counter % outputNormalizer_)
67 std::clog << "Ds" << std::endl;
68}
69
70void EmdiListener::onDepthIncremental(const DepthIncremental& incremental, const DataSource&)
71{
72 static size_t counter = 0;
73 if(0 == ++counter % outputNormalizer_)
74 std::clog << "Di" << std::endl;
75
76 marketDataLog_ << incremental.toStringWithFieldNames() << std::endl;
77}
78
79void EmdiListener::onDepthReset(MarketSegmentId)
80{
81}
82
83void EmdiListener::onDepthOutOfDate(MarketSegmentId)
84{
85}
86
87void EmdiListener::onTopOfBookImplied(const TopOfBookImplied& msg, const DataSource&)
88{
89 static size_t counter = 0;
90 if(0 == ++counter % outputNormalizer_)
91 std::clog << "Top" << std::endl;
92
93 marketDataLog_ << msg.toStringWithFieldNames() << std::endl;
94}
95
96void EmdiListener::onProductStateChange(const OnixS::Eurex::MarketData::ProductStateChange& change, const DataSource&)
97{
98 static size_t counter = 0;
99 if(0 == ++counter % outputNormalizer_)
100 std::clog << "Psc" << std::endl;
101
102 marketDataLog_ << change.toStringWithFieldNames() << std::endl;
103}
104
105void EmdiListener::onMassInstrumentStateChange(const MassInstrumentStateChange& change, const DataSource&)
106{
107 static size_t counter = 0;
108 if(0 == ++counter % outputNormalizer_)
109 std::clog << "Misc" << std::endl;
110
111 marketDataLog_ << change.toStringWithFieldNames() << std::endl;
112}
113
114void EmdiListener::onInstrumentStateChange(const OnixS::Eurex::MarketData::InstrumentStateChange& change, const DataSource&)
115{
116 static size_t counter = 0;
117 if(0 == ++counter % outputNormalizer_)
118 std::clog << "Sc" << std::endl;
119
120 marketDataLog_ << change.toStringWithFieldNames() << std::endl;
121}
122
123void EmdiListener::onQuoteRequest(const OnixS::Eurex::MarketData::QuoteRequest& request, const DataSource&)
124{
125 static size_t counter = 0;
126 if(0 == ++counter % outputNormalizer_)
127 std::clog << "Qr" << std::endl;
128
129 marketDataLog_ << request.toStringWithFieldNames() << std::endl;
130}
131
132void EmdiListener::onCrossRequest(const OnixS::Eurex::MarketData::CrossRequest& request, const DataSource&)
133{
134 static size_t counter = 0;
135 if(0 == ++counter % outputNormalizer_)
136 std::clog << "Cr" << std::endl;
137
138 marketDataLog_ << request.toStringWithFieldNames() << std::endl;
139}
140
141void EmdiListener::onComplexInstrumentUpdate(const ComplexInstrumentUpdate& update, const DataSource&)
142{
143 static size_t counter = 0;
144 if(0 == ++counter % outputNormalizer_)
145 std::clog << "Ciu" << std::endl;
146
147 marketDataLog_ << update.toStringWithFieldNames() << std::endl;
148}
149
150void EmdiListener::onFlexibleInstrumentUpdate(const FlexibleInstrumentUpdate& update, const DataSource&)
151{
152 static size_t counter = 0;
153 if(0 == ++counter % outputNormalizer_)
154 std::clog << "Fiu" << std::endl;
155
156 marketDataLog_ << update.toStringWithFieldNames() << std::endl;
157}
158
159
160void EmdiListener::onOrderBookUpdated(const OnixS::Eurex::MarketData::OrderBook& book)
161{
162 marketDataLog_ << book.toFormattedString() << std::endl;
163}
164
165void EmdiListener::onOrderBookOutOfDate(const OnixS::Eurex::MarketData::OrderBook&)
166{
167}
168
169void EmdiListener::onSnapshotTrade(const SnapshotTrade& trade)
170{
171 std::string tradeStr;
172 trade.toString(tradeStr);
173 marketDataLog_ << tradeStr << std::endl;
174}
175
176void EmdiListener::onIncrementalTrade(const IncrementalTrade& trade)
177{
178 std::string tradeStr;
179 trade.toString(tradeStr);
180 marketDataLog_ << tradeStr << std::endl;
181}
void toString(std::string &) const override
Appends text presentation.
std::string toFormattedString() const
Returns formatted presentation of the book.
Definition OrderBook.h:279
void toString(std::string &) const override
Appends text presentation.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#pragma once
20
21#include <iostream>
22#include <fstream>
23
37
38
39class MdiListener final
53{
54public:
56 explicit MdiListener(const std::string& logDir, size_t outputNormalizer = 100);
57
59 ~MdiListener() override;
60
62 void onError(OnixS::Eurex::MarketData::ErrorCode::Enum code, const std::string& description) override;
63
65 void onWarning(const std::string& description) override;
66
69
72
74 void onDepthReset(OnixS::Eurex::MarketData::MarketSegmentId marketSegmentId) override;
75
78
81
84
87
90
93
96
99
102
105
108
111
114
115private:
116 std::ofstream marketDataLog_;
117
118 size_t outputNormalizer_;
119};
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#include <sstream>
20
32
33#include "MdiListener.h"
34
35using namespace OnixS::Eurex::MarketData;
36
37/*
38 MdiListener
39*/
40
41MdiListener::MdiListener(const std::string& logDir, size_t outputNormalizer)
42 : outputNormalizer_(outputNormalizer)
43{
44 const std::string marketDataLogName = logDir + "/MarketData.txt";
45 marketDataLog_.open(marketDataLogName.c_str());
46 if(! marketDataLog_)
47 throw std::domain_error("Cannot open " + marketDataLogName);
48}
49
50MdiListener::~MdiListener() = default;
51
52void MdiListener::onError(ErrorCode::Enum code, const std::string& description)
53{
54 std::clog << "Error occurred, errorCode = " << enumToString(code) << ". Description: '" << description << "'" << std::endl;
55}
56
57void MdiListener::onWarning(const std::string& description)
58{
59 std::stringstream ss;
60 std::clog << "Warning occurred. Description: '" << description << "'" << std::endl;
61}
62
63void MdiListener::onDepthSnapshot(const DepthSnapshot&, const DataSource&)
64{
65 static size_t counter = 0;
66 if(0 == ++counter % outputNormalizer_)
67 std::clog << "Ds" << std::endl;
68}
69
70void MdiListener::onDepthIncremental(const DepthIncremental& incremental, const DataSource&)
71{
72 static size_t counter = 0;
73 if(0 == ++counter % outputNormalizer_)
74 std::clog << "Di" << std::endl;
75
76 marketDataLog_ << incremental.toStringWithFieldNames() << std::endl;
77}
78
79void MdiListener::onDepthReset(MarketSegmentId)
80{
81}
82
83void MdiListener::onDepthOutOfDate(MarketSegmentId)
84{
85}
86
87void MdiListener::onTopOfBookImplied(const TopOfBookImplied& msg, const DataSource&)
88{
89 static size_t counter = 0;
90 if(0 == ++counter % outputNormalizer_)
91 std::clog << "Top" << std::endl;
92
93 marketDataLog_ << msg.toStringWithFieldNames() << std::endl;
94}
95
96void MdiListener::onProductStateChange(const OnixS::Eurex::MarketData::ProductStateChange& change, const DataSource&)
97{
98 static size_t counter = 0;
99 if(0 == ++counter % outputNormalizer_)
100 std::clog << "Psc" << std::endl;
101
102 marketDataLog_ << change.toStringWithFieldNames() << std::endl;
103}
104
105void MdiListener::onMassInstrumentStateChange(const MassInstrumentStateChange& change, const DataSource&)
106{
107 static size_t counter = 0;
108 if(0 == ++counter % outputNormalizer_)
109 std::clog << "Misc" << std::endl;
110
111 marketDataLog_ << change.toStringWithFieldNames() << std::endl;
112}
113
114void MdiListener::onInstrumentStateChange(const OnixS::Eurex::MarketData::InstrumentStateChange& change, const DataSource&)
115{
116 static size_t counter = 0;
117 if(0 == ++counter % outputNormalizer_)
118 std::clog << "Sc" << std::endl;
119
120 marketDataLog_ << change.toStringWithFieldNames() << std::endl;
121}
122
123void MdiListener::onQuoteRequest(const OnixS::Eurex::MarketData::QuoteRequest& request, const DataSource&)
124{
125 static size_t counter = 0;
126 if(0 == ++counter % outputNormalizer_)
127 std::clog << "Qr" << std::endl;
128
129 marketDataLog_ << request.toStringWithFieldNames() << std::endl;
130}
131
132void MdiListener::onCrossRequest(const OnixS::Eurex::MarketData::CrossRequest& request, const DataSource&)
133{
134 static size_t counter = 0;
135 if(0 == ++counter % outputNormalizer_)
136 std::clog << "Cr" << std::endl;
137
138 marketDataLog_ << request.toStringWithFieldNames() << std::endl;
139}
140
141void MdiListener::onComplexInstrumentUpdate(const ComplexInstrumentUpdate& update, const DataSource&)
142{
143 static size_t counter = 0;
144 if(0 == ++counter % outputNormalizer_)
145 std::clog << "Ciu" << std::endl;
146
147 marketDataLog_ << update.toStringWithFieldNames() << std::endl;
148}
149
150void MdiListener::onFlexibleInstrumentUpdate(const FlexibleInstrumentUpdate& update, const DataSource&)
151{
152 static size_t counter = 0;
153 if(0 == ++counter % outputNormalizer_)
154 std::clog << "Fiu" << std::endl;
155
156 marketDataLog_ << update.toStringWithFieldNames() << std::endl;
157}
158
159
160void MdiListener::onOrderBookUpdated(const OnixS::Eurex::MarketData::OrderBook& book)
161{
162 marketDataLog_ << book.toFormattedString() << std::endl;
163}
164
165void MdiListener::onOrderBookOutOfDate(const OnixS::Eurex::MarketData::OrderBook&)
166{
167}
168
169void MdiListener::onSnapshotTrade(const SnapshotTrade& trade)
170{
171 std::string tradeStr;
172 trade.toString(tradeStr);
173 marketDataLog_ << tradeStr << std::endl;
174}
175
176void MdiListener::onIncrementalTrade(const IncrementalTrade& trade)
177{
178 std::string tradeStr;
179 trade.toString(tradeStr);
180 marketDataLog_ << tradeStr << std::endl;
181}
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#pragma once
20
33
34
35class EobiListener final
46{
47public:
49 void onError(OnixS::Eurex::MarketData::ErrorCode::Enum code, const std::string& description) override;
50
52 void onWarning(const std::string& description) override;
53
55
56 void onOrderAdd(const OnixS::Eurex::MarketData::EOBI::OrderAdd& orderAdd) override;
57
58 void onOrderModify(const OnixS::Eurex::MarketData::EOBI::OrderModify& orderModify) override;
59
61
62 void onOrderDelete(const OnixS::Eurex::MarketData::EOBI::OrderDelete& orderDelete) override;
63
64 void onOrderMassDelete(const OnixS::Eurex::MarketData::EOBI::OrderMassDelete& orderMassDelete) override;
65
67
68 void onFullOrderExecution(const OnixS::Eurex::MarketData::EOBI::FullOrderExecution& fullOrderExecution) override;
69
70 void onAuctionBestBidOffer(const OnixS::Eurex::MarketData::EOBI::AuctionBestBidOffer& auctionBestBidOffer) override;
71
73
74 void onTopOfBook(const OnixS::Eurex::MarketData::EOBI::TopOfBook& topOfBook) override;
75
76 void onExecutionSummary(const OnixS::Eurex::MarketData::EOBI::ExecutionSummary& executionSummary) override;
77
78 void onQuoteRequest(const OnixS::Eurex::MarketData::EOBI::QuoteRequest& quoteRequest) override;
79
80 void onCrossRequest(const OnixS::Eurex::MarketData::EOBI::CrossRequest& crossRequest) override;
81
82 void onTradeReport(const OnixS::Eurex::MarketData::EOBI::TradeReport& tradeReport) override;
83
84 void onTradeReversal(const OnixS::Eurex::MarketData::EOBI::TradeReversal& tradeReversal) override;
85
86 void onProductStateChange(const OnixS::Eurex::MarketData::EOBI::ProductStateChange& productStateChange) override;
87
89
91
93
94 void onProductSummary(const OnixS::Eurex::MarketData::EOBI::ProductSummary& productSummary) override;
95
96 void onInstrumentSummary(const OnixS::Eurex::MarketData::EOBI::InstrumentSummary& instrumentSummary) override;
97
98 void onSnapshotOrder(const OnixS::Eurex::MarketData::EOBI::SnapshotOrder& snapshotOrder) override;
99
101
103
105
107
108 void onAddFlexibleInstrument(const OnixS::Eurex::MarketData::EOBI::AddFlexibleInstrument& addFlexibleInstrument) override;
109
111
113
114 void onSnapshotCycleBegin() override;
115
116 void onSnapshotCycleEnd() override;
117};
virtual void onMarketSegmentOutOfDate(MarketSegmentId marketSegmentId)=0
virtual void onMarketSegmentReset(MarketSegmentId marketSegmentId)=0
Is called when all the information should be reset for a given market segment.
virtual void onOrderBookUpdated(const OrderBook &book)=0
virtual void onOrderBookOutOfDate(const OrderBook &book)=0
virtual void onOrderModify(const OrderModify &orderModify)=0
virtual void onFullOrderExecution(const FullOrderExecution &fullOrderExecution)=0
virtual void onAuctionBestBidOffer(const AuctionBestBidOffer &auctionBestBidOffer)=0
virtual void onOrderDelete(const OrderDelete &orderDelete)=0
virtual void onTopOfBook(const TopOfBook &topOfBook)=0
virtual void onOrderAdd(const OrderAdd &orderAdd)=0
virtual void onPartialOrderExecution(const PartialOrderExecution &partialOrderExecution)=0
virtual void onOrderModifySamePriority(const OrderModifySamePriority &orderModifySamePriority)=0
virtual void onOrderMassDelete(const OrderMassDelete &orderMassDelete)=0
virtual void onAuctionClearingPrice(const AuctionClearingPrice &auctionClearingPrice)=0
virtual void onAddComplexInstrument(const AddComplexInstrument &addComplexInstrument)=0
virtual void onAddScaledSimpleInstrument(const AddScaledSimpleInstrument &addFlexibleInstrument)=0
virtual void onAddFlexibleInstrument(const AddFlexibleInstrument &addFlexibleInstrument)=0
virtual void onProductSummary(const ProductSummary &productSummary)=0
virtual void onInstrumentSummary(const InstrumentSummary &instrumentSummary)=0
virtual void onSnapshotOrder(const SnapshotOrder &snapshotOrder)=0
virtual void onProductStateChange(const ProductStateChange &productStateChange)=0
virtual void onInstrumentStateChange(const InstrumentStateChange &instrumentStateChange)=0
virtual void onMassInstrumentStateChange(const MassInstrumentStateChange &instrumentStateChange)=0
virtual void onTradeReport(const TradeReport &tradeReport)=0
virtual void onTESTradeReport(const TESTradeReport &tradeReport)=0
virtual void onCrossRequest(const CrossRequest &crossRequest)=0
virtual void onTradeReversal(const TradeReversal &tradeReversal)=0
virtual void onQuoteRequest(const QuoteRequest &quoteRequest)=0
virtual void onExecutionSummary(const ExecutionSummary &executionSummary)=0
virtual void onStateChanged(HandlerState::Enum newState)=0
Implement this member to get notifications about handler state change.
Enum
Defines the state that the handler is in.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement(the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19
20#include <iostream>
21#include <sstream>
22
24
25#include "EobiListener.h"
26
27using namespace OnixS::Eurex::MarketData;
28using namespace OnixS::Eurex::MarketData::EOBI;
29
30/*
31 EobiListener
32*/
33
34void EobiListener::onError(ErrorCode::Enum code, const std::string& description)
35{
36 std::clog << "Error occurred, errorCode = " << enumToString(code) << ". Description: '" << description << "'" << std::endl;
37}
38
39void EobiListener::onWarning(const std::string& description)
40{
41 std::clog << "Warning occurred. Description: '" << description << "'" << std::endl;
42}
43
44void EobiListener::onStateChanged(HandlerState::Enum newState)
45{
46 std::clog << "Handler state changed: " << enumToString(newState) << std::endl;
47}
48
49std::string toString(const MessageBase& msg)
50{
51 return msg.toString();
52}
53
54void EobiListener::onOrderAdd(const OrderAdd& msg)
55{
56 std::clog << "Message received: " << toString(msg) << std::endl;
57}
58
59void EobiListener::onOrderModify(const OrderModify& msg)
60{
61 std::clog << "Message received: " << toString(msg) << std::endl;
62}
63
64void EobiListener::onOrderModifySamePriority(const OrderModifySamePriority& msg)
65{
66 std::clog << "Message received: " << toString(msg) << std::endl;
67}
68
69void EobiListener::onOrderDelete(const OrderDelete& msg)
70{
71 std::clog << "Message received: " << toString(msg) << std::endl;
72}
73
74void EobiListener::onOrderMassDelete(const OrderMassDelete& msg)
75{
76 std::clog << "Message received: " << toString(msg) << std::endl;
77}
78
79void EobiListener::onPartialOrderExecution(const PartialOrderExecution& msg)
80{
81 std::clog << "Message received: " << toString(msg) << std::endl;
82}
83
84void EobiListener::onFullOrderExecution(const FullOrderExecution& msg)
85{
86 std::clog << "Message received: " << toString(msg) << std::endl;
87}
88
89void EobiListener::onAuctionBestBidOffer(const AuctionBestBidOffer& msg)
90{
91 std::clog << "Message received: " << toString(msg) << std::endl;
92}
93
94void EobiListener::onAuctionClearingPrice(const AuctionClearingPrice& msg)
95{
96 std::clog << "Message received: " << toString(msg) << std::endl;
97}
98
99void EobiListener::onTopOfBook(const TopOfBook& msg)
100{
101 std::clog << "Message received: " << toString(msg) << std::endl;
102}
103
104void EobiListener::onExecutionSummary(const ExecutionSummary& msg)
105{
106 std::clog << "Message received: " << toString(msg) << std::endl;
107}
108
109void EobiListener::onQuoteRequest(const EOBI::QuoteRequest& msg)
110{
111 std::clog << "Message received: " << toString(msg) << std::endl;
112}
113
114void EobiListener::onCrossRequest(const EOBI::CrossRequest& msg)
115{
116 std::clog << "Message received: " << toString(msg) << std::endl;
117}
118
119void EobiListener::onTradeReport(const TradeReport& msg)
120{
121 std::clog << "Message received: " << toString(msg) << std::endl;
122}
123
124void EobiListener::onTradeReversal(const TradeReversal& msg)
125{
126 std::clog << "Message received: " << toString(msg) << std::endl;
127}
128
129void EobiListener::onProductStateChange(const EOBI::ProductStateChange& msg)
130{
131 std::clog << "Message received: " << toString(msg) << std::endl;
132}
133
134void EobiListener::onInstrumentStateChange(const EOBI::InstrumentStateChange& msg)
135{
136 std::clog << "Message received: " << toString(msg) << std::endl;
137}
138
139void EobiListener::onMassInstrumentStateChange(
141{
142 std::clog << "Message received: " << toString(msg) << std::endl;
143}
144
145void EobiListener::onAddComplexInstrument(const AddComplexInstrument& msg)
146{
147 std::clog << "Message received: " << toString(msg) << std::endl;
148}
149
150void EobiListener::onProductSummary(const ProductSummary& msg)
151{
152 std::clog << "Message received: " << toString(msg) << std::endl;
153}
154
155void EobiListener::onInstrumentSummary(const InstrumentSummary& msg)
156{
157 std::clog << "Message received: " << toString(msg) << std::endl;
158}
159
160void EobiListener::onSnapshotOrder(const SnapshotOrder& msg)
161{
162 std::clog << "Message received: " << toString(msg) << std::endl;
163}
164
165void EobiListener::onAddFlexibleInstrument(const AddFlexibleInstrument& msg)
166{
167 std::clog << "Message received: " << toString(msg) << std::endl;
168}
169
170void EobiListener::onTESTradeReport(const TESTradeReport& msg)
171{
172 std::clog << "Message received: " << toString(msg) << std::endl;
173}
174
175void EobiListener::onAddScaledSimpleInstrument(const AddScaledSimpleInstrument& msg)
176{
177 std::clog << "Message received: " << toString(msg) << std::endl;
178}
179
180void EobiListener::onMarketSegmentReset(MarketSegmentId)
181{
182}
183
184void EobiListener::onMarketSegmentOutOfDate(MarketSegmentId)
185{
186}
187
188void EobiListener::onOrderBookUpdated(const EOBI::OrderBook&)
189{
190}
191
192void EobiListener::onOrderBookOutOfDate(const EOBI::OrderBook&)
193{
194}
195
196void EobiListener::onSnapshotCycleBegin()
197{
198}
199
200void EobiListener::onSnapshotCycleEnd()
201{
202}
std::string toString() const
Returns text presentation.