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
EMDS Handler Sample

This sample demonstrates how to connect to the EMDS 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*/
19#include <iostream>
20#include <sstream>
21
25
26#include "MyListener.h"
27
28#include "../Common/Signal.h"
29#include "../Common/Options.h"
30#include "../Common/Settings.h"
31
32using namespace OnixS::Eurex::MarketData;
33
35int main(int argc, char* argv[])
36{
37 // `--help` to show options.
38 const Samples::AppConfiguration<
39 Samples::NetworkInterfaceConfiguration
40 , Samples::LogDirectoryConfiguration
41 > cfg{"EMDS", argc, argv};
42
43 try
44 {
45 Samples::SignalHelper::manageSignals();
46
47 MyListener myListener;
48
49 SocketFeedEngine feedEngine;
50 FeedEngineThreadPoolSettings feedEngineThreadPoolSettings;
51 FeedEngineThreadPool pool(feedEngineThreadPoolSettings, &feedEngine);
52
53 auto settings = Samples::makeSettings<EmdsHandlerSettings>(cfg);
54
55 std::clog << "Starting EMDS handler for realtime service" << std::endl;
56 settings.logFileNamePrefix = "emdsRealtime";
57 {
59 settings.settlementFeedDescriptor.serviceA.address = "224.0.50.93";
60 settings.settlementFeedDescriptor.serviceA.port = 59500;
61 settings.settlementFeedDescriptor.serviceB.address = "224.0.50.221";
62 settings.settlementFeedDescriptor.serviceB.port = 59500;
63
64 settings.openInterestFeedDescriptor.serviceA.address = "224.0.50.94";
65 settings.openInterestFeedDescriptor.serviceA.port = 59500;
66 settings.openInterestFeedDescriptor.serviceB.address = "224.0.50.222";
67 settings.openInterestFeedDescriptor.serviceB.port = 59500;
68
69 // Xetra trades(XETR) - ATP
70 settings.exchangeTradeFeedDescriptor.serviceA.address = "224.0.164.120";
71 settings.exchangeTradeFeedDescriptor.serviceA.port = 59500;
72 settings.exchangeTradeFeedDescriptor.serviceB.address = "224.0.165.120";
73 settings.exchangeTradeFeedDescriptor.serviceB.port = 59500;
74 }
75
76 EmdsHandler handlerForRealtime(settings);
77 handlerForRealtime.bindFeedEngine(feedEngine);
78
79 handlerForRealtime.registerErrorListener(&myListener);
80 handlerForRealtime.registerWarningListener(&myListener);
81 handlerForRealtime.registerOpenInterestListener(&myListener);
82 handlerForRealtime.registerSettlementListener(&myListener);
83 handlerForRealtime.start();
84
85 std::clog << "Starting EMDS handler for replay service" << std::endl;
86 settings.logFileNamePrefix = "emdsReplay";
87 {
88 // Simulation environment
89 settings.settlementFeedDescriptor.serviceA.address = "224.0.50.93";
90 settings.settlementFeedDescriptor.serviceA.port = 59501;
91 settings.settlementFeedDescriptor.serviceB.address = "224.0.50.221";
92 settings.settlementFeedDescriptor.serviceB.port = 59501;
93
94 settings.openInterestFeedDescriptor.serviceA.address = "224.0.50.94";
95 settings.openInterestFeedDescriptor.serviceA.port = 59501;
96 settings.openInterestFeedDescriptor.serviceB.address = "224.0.50.222";
97 settings.openInterestFeedDescriptor.serviceB.port = 59501;
98
99 settings.exchangeTradeFeedDescriptor.serviceA.address = "224.0.50.95";
100 settings.exchangeTradeFeedDescriptor.serviceA.port = 59501;
101 settings.exchangeTradeFeedDescriptor.serviceB.address = "224.0.50.223";
102 settings.exchangeTradeFeedDescriptor.serviceB.port = 59501;
103 }
104
105 EmdsHandler handlerForReplay(settings);
106 handlerForReplay.bindFeedEngine(feedEngine);
107
108 handlerForReplay.registerErrorListener(&myListener);
109 handlerForReplay.registerWarningListener(&myListener);
110 handlerForReplay.registerOpenInterestListener(&myListener);
111 handlerForReplay.registerSettlementListener(&myListener);
112 handlerForReplay.registerExchangeTradeListener(&myListener);
113 handlerForReplay.start();
114
115 std::clog << "Starting EMDS handler for replay service for Xetra trades" << std::endl;
116 settings.logFileNamePrefix = "emdsReplayForXetra";
117 {
118 settings.settlementFeedDescriptor.clear();
119 settings.openInterestFeedDescriptor.clear();
120
122 settings.exchangeTradeFeedDescriptor.serviceA.address = "224.0.164.120";
123 settings.exchangeTradeFeedDescriptor.serviceA.port = 59501;
124 settings.exchangeTradeFeedDescriptor.serviceB.address = "224.0.165.120";
125 settings.exchangeTradeFeedDescriptor.serviceB.port = 59501;
126 }
127
128 EmdsHandler handlerForReplayXetra(settings);
129 handlerForReplayXetra.bindFeedEngine(feedEngine);
130
131 handlerForReplayXetra.registerErrorListener(&myListener);
132 handlerForReplayXetra.registerWarningListener(&myListener);
133 handlerForReplayXetra.registerExchangeTradeListener(&myListener);
134 handlerForReplayXetra.start();
135
136 Samples::SignalHelper::waitUntilKey("to stop the handlers");
137
138 std::clog << "Stopping..." << std::endl;
139
140 handlerForRealtime.stop();
141 handlerForReplay.stop();
142 handlerForReplayXetra.stop();
143
144 std::clog << "Handlers are stopped." << std::endl;
145 }
146 catch(const std::exception& ex)
147 {
148 std::cerr << "EXCEPTION: " << ex.what() << std::endl;
149 }
150
151 return 0;
152}
Eurex Extended Market Data Service Handler.
Definition EmdsHandler.h:41
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
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
27
28class MyListener final
34{
35public:
37 MyListener();
38
40 ~MyListener() override;
41
43 void onError(OnixS::Eurex::MarketData::ErrorCode::Enum code, const std::string& description) override;
44
46 void onWarning(const std::string& description) override;
47
49 void onSettlement(const OnixS::Eurex::MarketData::Settlement& settlement, const OnixS::Eurex::MarketData::DataSource& dataSource) override;
50
53
56
59
62
64 void onOpenInterestReplayCycleEnd(const OnixS::Eurex::MarketData::DataSource&) override {}
65
67 void onExchangeTrade(const OnixS::Eurex::MarketData::ExchangeTrade& trade, const OnixS::Eurex::MarketData::DataSource& dataSource) override;
68
70 void onExchangeTradeReplayCycleStart(OnixS::Eurex::MarketData::UInt32, const OnixS::Eurex::MarketData::DataSource&) override {}
71
73 void onExchangeTradeReplayCycleEnd(const OnixS::Eurex::MarketData::DataSource&) override {}
74
75private:
77 OnixS::Eurex::MarketData::Semaphore referenceDataReady_;
78};
virtual void onError(ErrorCode::Enum code, const std::string &description)=0
virtual void onExchangeTrade(const ExchangeTrade &trade, const DataSource &dataSource)=0
Is called when single leg OTC trade is received.
virtual void onExchangeTradeReplayCycleEnd(const DataSource &dataSource)=0
Is called when the corresponding MDReport message is received for the Replay Service.
virtual void onExchangeTradeReplayCycleStart(UInt32 mdCount, const DataSource &dataSource)=0
Is called when the corresponding MDReport message is received for the Replay Service.
virtual void onOpenInterestReplayCycleEnd(const DataSource &dataSource)=0
Is called when the corresponding MDReport message is received for the Replay Service.
virtual void onOpenInterestReplayCycleStart(UInt32 mdCount, const DataSource &dataSource)=0
Is called when the corresponding MDReport message is received for the Replay Service.
virtual void onOpenInterest(const OpenInterest &interest, const DataSource &dataSource)=0
Is called when open interest is received.
virtual void onSettlement(const Settlement &settlement, const DataSource &dataSource)=0
Is called when settlement is received.
virtual void onSettlementReplayCycleStart(UInt32 mdCount, const DataSource &dataSource)=0
Is called when the corresponding MDReport message is received for the Replay Service.
virtual void onSettlementReplayCycleEnd(const DataSource &dataSource)=0
Is called when the corresponding MDReport message is received for the Replay Service.
virtual void onWarning(const std::string &reason)=0
Is called when the Warning condition is detected.
unsigned int UInt32
Definition Numeric.h:41
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 <iostream>
20#include <sstream>
21
22#include "MyListener.h"
23
24using namespace OnixS::Eurex::MarketData;
25
26/*
27 MyListener
28*/
29
30MyListener::MyListener()
31 : referenceDataReady_(0)
32{
33}
34
35MyListener::~MyListener() = default;
36
37void MyListener::onError(ErrorCode::Enum code, const std::string& description)
38{
39 std::clog << "Error occurred, errorCode = " << enumToString(code) << ". Description: '" << description << "'" << std::endl;
40}
41
42void MyListener::onWarning(const std::string& description)
43{
44 std::clog << "Warning occurred. Description: '" << description << "'" << std::endl;
45}
46
47void MyListener::onSettlement(const Settlement&, const DataSource&)
48{
49}
50
51void MyListener::onOpenInterest(const OpenInterest&, const DataSource&)
52{
53}
54
55void MyListener::onExchangeTrade(const ExchangeTrade&, const DataSource&)
56{
57}
std::string enumToString(HandlerState::Enum)
Returns string representation of HandlerState value.