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
Advanced Sample

This sample demonstrates how to connect to the RDI and EMDI 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*/
22
23#include "../Common/Signal.h"
24#include "../Common/Options.h"
25#include "../Common/Settings.h"
26#include "../Common/Utils.h"
27
28#include "MyListener.h"
29
30using namespace OnixS::Eurex::MarketData;
31
33int main(int argc, char* argv[])
34{
35 // `--help` to show options.
36 const Samples::AppConfiguration<
37 Samples::NetworkInterfaceConfiguration
38 , Samples::EnvironmentConfiguration
39 , Samples::LogDirectoryConfiguration
40 > cfg{"Advanced", argc, argv};
41
42 try
43 {
44 Samples::SignalHelper::manageSignals();
45
46 SocketFeedEngine feedEngine;
47 FeedEngineThreadPoolSettings feedEngineThreadPoolSettings;
48 FeedEngineThreadPool pool(feedEngineThreadPoolSettings, &feedEngine);
49
50 auto rdiSettings = Samples::makeSettings<RdiHandlerSettings>(cfg);
51 fillEnvironment(rdiSettings, cfg);
52
53 MyListener myListener{rdiSettings.logDirectory};
54
55 auto rdiHandler = Samples::makeUnique<RdiHandler>(rdiSettings);
56
57 rdiHandler
58 ->bindFeedEngine(feedEngine)
59 .registerErrorListener(&myListener)
60 .registerWarningListener(&myListener)
61 .registerReferenceDataListener(&myListener);
62
63 std::clog << "Will start the RDI Handler ..." << std::endl;
64 rdiHandler->start();
65
66 myListener.waitUntilReferenceDataReceived();
67
68 auto emdiSettings = Samples::makeSettings<EmdiHandlerSettings>(cfg);
69 emdiSettings.buildInternalOrderBooks = true;
70 emdiSettings.lostPacketWaitTime = 500;
71
72 std::vector<std::unique_ptr<EmdiHandler>> handlers;
73
74 const auto descriptors = rdiHandler->findEmdiDescriptors({"FDAX", "FGBL", "FGBM", "FSMI"});
75 for(auto && descriptor : descriptors)
76 {
77 emdiSettings.logFileNamePrefix = std::string("Emdi_") + descriptor.productInfos[0].marketSegment;
78 emdiSettings.interfaceDescriptor.incrementalFeed = descriptor.incrementalFeed;
79 emdiSettings.interfaceDescriptor.snapshotFeed = descriptor.snapshotFeed;
80
81 handlers.emplace_back(Samples::makeUnique<EmdiHandler>(emdiSettings));
82
83 auto& handler = handlers.back();
84
85 handler->
86 bindFeedEngine(feedEngine)
87
88 .registerErrorListener(&myListener)
89 .registerWarningListener(&myListener)
90 .registerDepthListener(&myListener)
91 .registerTopOfBookImpliedListener(&myListener)
92 .registerProductStateChangeListener(&myListener)
93 .registerMassInstrumentStateChangeListener(&myListener)
94 .registerInstrumentStateChangeListener(&myListener)
95 .registerQuoteRequestListener(&myListener)
96 .registerCrossRequestListener(&myListener)
97 .registerComplexInstrumentUpdateListener(&myListener)
98 .registerFlexibleInstrumentUpdateListener(&myListener)
99 .registerOrderBookListener(&myListener)
100 .registerTradeListener(&myListener)
101
102 .setMarketSegmentId2Depth(descriptor.marketSegmentId2Depth)
103 .setPartitionIdFilters(descriptor.partitionIdFilters)
104 .setMarketSegmentIdFilters(descriptor.marketSegmentIdFilters);
105
106 handler->start();
107 }
108
109 Samples::SignalHelper::waitUntilKey("to stop the handlers");
110
111 std::clog << "Stopping..." << std::endl;
112
113 for(auto && handler : handlers)
114 handler->stop();
115
116 handlers.clear();
117 rdiHandler->stop();
118
119 std::clog << "All the Handlers are stopped." << std::endl;
120 }
121 catch (const std::exception& ex)
122 {
123 std::cerr << "EXCEPTION: " << ex.what() << std::endl;
124 }
125
126 return 0;
127}
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/*
3* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
4*
5* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
6* and international copyright treaties.
7*
8* Access to and use of the software is governed by the terms of the applicable ONIXS Software
9* Services Agreement (the Agreement) and Customer end user license agreements granting
10* a non-assignable, non-transferable and non-exclusive license to use the software
11* for it's own data processing purposes under the terms defined in the Agreement.
12*
13* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
14* of this source code or associated reference material to any other location for further reproduction
15* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
16*
17* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
18* the terms of the Agreement is a violation of copyright law.
19*/
20#pragma once
21
22#include <iostream>
23#include <fstream>
24
40
41
42class MyListener final
57{
58public:
60 explicit MyListener(const std::string& logDir);
61
63 ~MyListener() override;
64
66 void onError(OnixS::Eurex::MarketData::ErrorCode::Enum code, const std::string& description) override;
67
69 void onWarning(const std::string& description) override;
70
72 void onSnapshotCycleStart() override;
73
75 void onProduct(const OnixS::Eurex::MarketData::ProductSnapshot& productSnapshot, const OnixS::Eurex::MarketData::DataSource& dataSource) override;
76
79
82
85
88
91
93 void onSnapshotCycleEnd() override;
94
96 void waitUntilReferenceDataReceived();
97
99
102
104 void onDepthReset(OnixS::Eurex::MarketData::MarketSegmentId marketSegmentId) override;
105
107 void onDepthOutOfDate(OnixS::Eurex::MarketData::MarketSegmentId marketSegmentId) override;
108
111
114
117
120
123
126
129
132
135
138
140 void onSnapshotTrade (const OnixS::Eurex::MarketData::SnapshotTrade& trade) override;
141
144
145private:
147 OnixS::Eurex::MarketData::Semaphore referenceDataReady_;
148
149 std::ofstream referenceDataLog_;
150};
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 onError(ErrorCode::Enum code, const std::string &description)=0
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 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 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.
virtual void onWarning(const std::string &reason)=0
Is called when the Warning condition is detected.
UInt32 MarketSegmentId
Alias for Market Segment ID type.
Definition Defines.h:40
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#include <fstream>
22
23#include "MyListener.h"
24
25using namespace OnixS::Eurex::MarketData;
26
27/*
28 MyListener
29*/
30
31MyListener::MyListener(const std::string& logDir)
32 : referenceDataReady_(0)
33{
34 const std::string referenceDataLogName = logDir + "/ReferenceData.txt";
35 referenceDataLog_.open(referenceDataLogName.c_str());
36 if(!referenceDataLog_)
37 throw std::domain_error("Cannot open " + referenceDataLogName);
38}
39
40MyListener::~MyListener() = default;
41
42void MyListener::onError(ErrorCode::Enum code, const std::string& description)
43{
44 std::clog << "Error occurred, errorCode = " << enumToString(code) << ". Description: '" << description << "'" << std::endl;
45}
46
47void MyListener::onWarning(const std::string& description)
48{
49 std::stringstream ss;
50 std::clog << "Warning occurred. Description: '" << description << "'" << std::endl;
51}
52
53void MyListener::onSnapshotCycleStart()
54{
55 referenceDataLog_ << "onSnapshotCycleStart" << std::endl;
56}
57
58void MyListener::onProduct(const ProductSnapshot& msg, const DataSource&)
59{
60 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
61}
62
63void MyListener::onInstrument(const InstrumentSnapshot& msg, const DataSource&)
64{
65 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
66}
67
68void MyListener::onInstrumentIncremental(const InstrumentIncremental& msg, const DataSource&)
69{
70 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
71}
72
73void MyListener::onVarianceFuturesStatus(const VarianceFuturesStatus& msg, const DataSource&)
74{
75 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
76}
77
78void MyListener::onTotalReturnFuturesStatus(const TotalReturnFuturesStatus& msg, const DataSource&)
79{
80 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
81}
82
83void MyListener::onTradeAtReferencePriceStatus(const TradeAtReferencePriceStatus& msg, const DataSource&)
84{
85 referenceDataLog_ << msg.toStringWithFieldNames() << std::endl;
86}
87
88void MyListener::onSnapshotCycleEnd()
89{
90 referenceDataLog_ << "onSnapshotCycleEnd" << std::endl;
91 referenceDataReady_.release();
92}
93
94void MyListener::waitUntilReferenceDataReceived()
95{
96 referenceDataReady_.acquire();
97}
98
99void MyListener::onDepthSnapshot(const DepthSnapshot&, const DataSource&)
100{
101}
102
103void MyListener::onDepthIncremental(const DepthIncremental&, const DataSource&)
104{
105}
106
107void MyListener::onDepthReset(MarketSegmentId)
108{
109}
110
111void MyListener::onDepthOutOfDate(MarketSegmentId)
112{
113}
114
115void MyListener::onTopOfBookImplied(const TopOfBookImplied&, const DataSource&)
116{
117}
118
119void MyListener::onProductStateChange(const ProductStateChange&, const DataSource&)
120{
121}
122
123void MyListener::onMassInstrumentStateChange(const MassInstrumentStateChange&, const DataSource&)
124{
125}
126
127void MyListener::onInstrumentStateChange(const InstrumentStateChange&, const DataSource&)
128{
129}
130
131void MyListener::onQuoteRequest(const QuoteRequest&, const DataSource&)
132{
133}
134
135void MyListener::onCrossRequest(const CrossRequest&, const DataSource&)
136{
137}
138
139void MyListener::onComplexInstrumentUpdate(const ComplexInstrumentUpdate&, const DataSource&)
140{
141}
142
143void MyListener::onFlexibleInstrumentUpdate(const FlexibleInstrumentUpdate&, const DataSource&)
144{
145}
146
147void MyListener::onOrderBookUpdated(const OrderBook&)
148{
149}
150
151void MyListener::onOrderBookOutOfDate(const OrderBook&)
152{
153}
154
155void MyListener::onSnapshotTrade (const SnapshotTrade&)
156{
157}
158
159void MyListener::onIncrementalTrade (const IncrementalTrade&)
160{
161}
std::string toStringWithFieldNames() const
Definition Message.h:111
std::string enumToString(HandlerState::Enum)
Returns string representation of HandlerState value.