28 #ifndef _MF_MFMARKETDATASESSION_H_
29 #define _MF_MFMARKETDATASESSION_H_
31 #define USERNAME_LENGTH 32
32 #define PASSWORD_LENGTH 32
33 #define TEXT_LENGTH 64
36 #include <MFProtoInputBuffer.h>
37 #include <MFProtoOutputBuffer.h>
38 #include <MFProtoMsgWrapper.h>
39 #include <SessionState.h>
41 #include <mfmarketdata/SubscriptionRequestType.hpp>
42 #include <mfmarketdata/Logon.hpp>
43 #include <mfmarketdata/SecurityDefinitionRequest.hpp>
44 #include <mfmarketdata/MarketDataRequest.hpp>
45 #include <mfmarketdata/RegisterForBatch.hpp>
46 #include <mfmarketdata/UnregisterForBatch.hpp>
47 #include <mfmarketdata/Logout.hpp>
48 #include <mfmarketdata/LogoutResponse.hpp>
49 #include <mfmarketdata/Heartbeat.hpp>
51 #include <boost/asio.hpp>
52 #include <boost/thread/mutex.hpp>
53 #include <boost/noncopyable.hpp>
91 void logout(
const char* text);
116 MFProto::SecurityID securityID);
121 mfmarketdata::SubscriptionRequestType::Value subType,
122 MFProto::VenueID venueID, MFProto::SecurityID securityID,
123 uint64_t startTime, uint64_t endTime);
135 MFProto::BatchDefID batchDefID,
136 MFProto::SecurityID* securityIDs,
int numSecurityIDs);
151 void sendLogonMessage();
152 void sendLogoutMessage(
const char* text);
154 void relogonIfNecessary();
159 bool disconnect(
bool reconnect =
true);
167 template <
typename T>
169 write(msgWrapper.
buf());
172 void write(MFProtoOutputBuffer& outputBuffer);
174 void handle_connect(
const boost::system::error_code& ec);
175 void handle_read(
const boost::system::error_code& ec,
176 size_t bytes_transferred);
178 void onTimer(TimeUtil::Timestamp now);
179 void checkForDeadConnection(TimeUtil::Timestamp now);
180 void sendHeartbeatIfNecessary(TimeUtil::Timestamp now);
183 boost::asio::io_service& ios,
184 const std::string& venueName, MFProto::VenueID venueID,
185 const std::string& username,
const std::string& password,
186 const std::string& hostname,
int port,
187 bool relogonOnDisconnect, uint32_t heartBtInt);
192 void write_internal(MFProtoOutputBuffer& outputBuffer);
195 const uint16_t _heartBtInt;
196 boost::asio::ip::tcp::socket _socket;
197 MFProtoInputBuffer _inputBuffer;
198 mutable boost::mutex _outputBufferLock;
199 uint32_t _outputBufferPacketSeqNum;
200 const std::string _username;
201 const std::string _password;
202 const std::string _hostname;
203 const uint16_t _port;
204 const std::string _venueName;
205 const uint16_t _venueID;
206 const bool _relogonOnDisconnect;
208 uint64_t _lastMessageSentTimestamp;
209 uint64_t _lastMessageRecvTimestamp;
A wrapper to encapsulate an SBE class instance and the buffer where the message payload is actually s...
Definition: MFProtoMsgWrapper.h:17
Applications implement this interface in order to process marketdata messages from a MFMarketDataSess...
Definition: MFMarketDataHandler.h:49
uint64_t getSendingTime() const
Retrieve the sending time of the current frame.
Definition: MFMarketDataSession.h:77
void securityDefinitionRequest()
Requests information about the securities supported on this venue. See MFMarketDataHandler::on(const ...
Definition: MFMarketDataSession.cpp:131
void marketDataRequestHistoric(mfmarketdata::SubscriptionRequestType::Value subType, MFProto::VenueID venueID, MFProto::SecurityID securityID, uint64_t startTime, uint64_t endTime)
Definition: MFMarketDataSession.cpp:151
void registerForBatch(MFProto::VenueID venueID, MFProto::BatchDefID batchDefID, MFProto::SecurityID *securityIDs, int numSecurityIDs)
Register for a given list of markets on a given feed. MFProto::VenueIDMFProto::BatchDefIDArray of MFP...
Definition: MFMarketDataSession.cpp:171
void logoutResponse()
The response to a logout from the server. This should be called if a logout is received so that the c...
Definition: MFMarketDataSession.cpp:126
Central class for managing sessions with MarketFactory. Create sessions using this class...
Definition: MFClient.h:83
const std::string getVenueName() const
Get the venue name associated with this session.
Definition: MFMarketDataSession.h:72
bool isLoggedOn() const
Returns whether this session is connected.
Definition: MFMarketDataSession.cpp:382
void logon()
Sends a logon message with the supplied username and password. Should only be called in the event loo...
Definition: MFMarketDataSession.cpp:90
A session used to interact with a single venue for market data.
Definition: MFMarketDataSession.h:60
uint16_t getVenueID() const
Get the venue ID associated with this session.
Definition: MFMarketDataSession.h:67
void marketDataRequest(mfmarketdata::SubscriptionRequestType::Value subType, MFProto::SecurityID securityID)
A request to subscribe or unsubscribe to a particular security. mfmarketdata::SubscriptionRequestType...
Definition: MFMarketDataSession.cpp:140
void logout(const char *text)
Initiates logout. This should be called so a clean and dirty (one where the socket closes w/o a logou...
Definition: MFMarketDataSession.cpp:109
void unregisterFromBatch(MFProto::BatchDefID batchDefID)
Unregister market combination based on the id provided in onBatchEvent callback. MFProto::BatchDefID
Definition: MFMarketDataSession.cpp:189
Definition: SessionState.h:37
MFProtoOutputBuffer & buf()
Return a reference to the buffer where the object payload is stored.
Definition: MFProtoMsgWrapper.h:34