28 #ifndef _MF_TRADINGSESSION_H_
29 #define _MF_TRADINGSESSION_H_
31 #define USERNAME_LENGTH 32
32 #define PASSWORD_LENGTH 32
33 #define CLORDID_LENGTH 32
34 #define STRATEGY_PARAMETERS_LENGTH 32
38 #include <MFProtoInputBuffer.h>
39 #include <MFProtoOutputBuffer.h>
40 #include <MFProtoMsgWrapper.h>
41 #include <SessionState.h>
43 #include <mftrading/DecimalQtyNULL.hpp>
44 #include <mftrading/TradingSessionStatusRequest.hpp>
45 #include <mftrading/NewOrderSingle.hpp>
46 #include <mftrading/Logon.hpp>
47 #include <mftrading/MarketDefinitionRequest.hpp>
48 #include <mftrading/OrderCancelReplaceRequest.hpp>
49 #include <mftrading/OrderCancelRequest.hpp>
50 #include <mftrading/Logout.hpp>
51 #include <mftrading/LogoutResponse.hpp>
52 #include <mftrading/Heartbeat.hpp>
53 #include <mftrading/OrdType.hpp>
54 #include <mftrading/PriceNULL.hpp>
55 #include <mftrading/Side.hpp>
56 #include <mftrading/SubscriptionRequestType.hpp>
57 #include <mftrading/TimeInForce.hpp>
59 #include <boost/asio.hpp>
60 #include <boost/thread/mutex.hpp>
61 #include <boost/noncopyable.hpp>
121 MFProto::VenueID venueID,
122 mftrading::SubscriptionRequestType::Value subType,
123 MFProto::SeqNum nextExpSeqNum
165 MFProto::VenueID venueID,
166 MFProto::SecurityID securityID,
168 mftrading::Side::Value side,
169 mftrading::OrdType::Value ordType,
170 mftrading::TimeInForce::Value timeInForce,
171 const char** strategyParamName = NULL,
172 mftrading::StrategyParameterType::Value* strategyParamType = NULL,
173 const char** strategyParamValue = NULL,
174 int nStrategyParams = 0
208 MFProto::VenueID venueID,
209 MFProto::SecurityID securityID,
211 const char* origOrdID,
212 MFProto::OrderID orderID,
213 mftrading::Side::Value side,
214 mftrading::OrdType::Value ordType,
215 mftrading::TimeInForce::Value timeInForce
245 MFProto::VenueID venueID,
246 MFProto::SecurityID securityID,
248 const char* origClOrdID,
249 MFProto::OrderID orderID
253 void sendLogonMessage();
254 void sendLogoutMessage();
255 void relogonIfNecessary();
261 bool disconnect(
bool reconnect =
true);
270 template <
typename T>
272 write(msgWrapper.
buf());
275 void write(MFProtoOutputBuffer& outputBuffer);
277 void handle_connect(
const boost::system::error_code& ec);
278 void handle_read(
const boost::system::error_code& ec,
279 size_t bytes_transferred);
281 void onTimer(TimeUtil::Timestamp now);
282 void checkForDeadConnection(TimeUtil::Timestamp now);
283 void sendHeartbeatIfNecessary(TimeUtil::Timestamp now);
284 void closeConnectionIfWaitedTooLongForServerLogoutResponse(
285 TimeUtil::Timestamp now);
288 const std::string& username,
const std::string& password,
289 const std::string& hostname, uint16_t port,
290 bool reconnectOnDisconenect, uint16_t heartBtInt);
294 void write_internal(MFProtoOutputBuffer& outputBuffer);
297 const uint16_t _heartBtInt;
298 boost::asio::ip::tcp::socket _socket;
299 MFProtoInputBuffer _inputBuffer;
300 mutable boost::mutex _outputBufferLock;
301 uint32_t _outputBufferPacketSeqNum;
303 const std::string _username;
304 const std::string _password;
305 const std::string _hostname;
306 const uint16_t _port;
307 const bool _relogonOnDisconnect;
309 long _lastMessageSentTimestamp;
310 long _lastMessageRecvTimestamp;
A wrapper to encapsulate an SBE class instance and the buffer where the message payload is actually s...
Definition: MFProtoMsgWrapper.h:17
mftrading::OrderCancelReplaceRequest & createOrderCancelReplaceRequest(MFProto::VenueID venueID, MFProto::SecurityID securityID, const char *clOrdID, const char *origOrdID, MFProto::OrderID orderID, mftrading::Side::Value side, mftrading::OrdType::Value ordType, mftrading::TimeInForce::Value timeInForce)
Allocate mftrading::OrderCancelReplaceRequest object and populate it with the supplied parameters...
Definition: MFTradingSession.cpp:217
void orderCancelReplaceRequest()
Submit modification to an existing order using the mftrading::OrderCancelReplaceRequest reference ret...
Definition: MFTradingSession.cpp:212
mftrading::NewOrderSingle & createNewOrderSingle(MFProto::VenueID venueID, MFProto::SecurityID securityID, const char *clOrdId, mftrading::Side::Value side, mftrading::OrdType::Value ordType, mftrading::TimeInForce::Value timeInForce, const char **strategyParamName=NULL, mftrading::StrategyParameterType::Value *strategyParamType=NULL, const char **strategyParamValue=NULL, int nStrategyParams=0)
Allocate mftrading::NewOrderSingle object and populate it with the supplied parameters. MFProto::VenueIDMFProto::SecurityIDClient order id. A string up to 32 characters long which is null-terminated unless the length is 32 (in which case, no null-termination necessary). mftrading::Side::Valuemftrading::OrdType::Valuemftrading::TimeInForce::ValueArray of mftrading::NewOrderSingle::StrategyParametersGrp StrategyParamName entries. Each StrategyParamName entry is a string up to 32 characters long. Default is NULLArray of mftrading::StrategyParameterType::Value entries. Default is NULLArray of mftrading::NewOrderSingle::StrategyParametersGrp StrategyParamValue entries. Each StrategyParamValue entry is a string up to 32 characters long. Default is NULLNumber of mftrading::NewOrderSingle::StrategyParametersGrp entries. Default is 0
Definition: MFTradingSession.cpp:170
Applications implement this interface in order to process events from a MFTradingSession ...
Definition: MFTradingHandler.h:47
Central class for managing sessions with MarketFactory. Create sessions using this class...
Definition: MFClient.h:83
void newOrderSingle()
Submit an order. The order submitted will be the mftrading::NewOrderSingle object that was returned a...
Definition: MFTradingSession.cpp:165
void orderCancelRequest()
Submit cancel request for an existing order using the object created by the previous call to createOr...
Definition: MFTradingSession.cpp:240
void tradingRequest(MFProto::VenueID venueID, mftrading::SubscriptionRequestType::Value subType, MFProto::SeqNum nextExpSeqNum)
A request to subscribe or unsubscribe to/from a particular venue (as specified by the venueID paramet...
Definition: MFTradingSession.cpp:149
A session with MarketFactory for trading with all the venues for which a user has access...
Definition: MFTradingSession.h:69
mftrading::OrderCancelRequest & createOrderCancelRequest(MFProto::VenueID venueID, MFProto::SecurityID securityID, const char *clOrdID, const char *origClOrdID, MFProto::OrderID orderID)
Allocate mftrading::OrderCancelRequest object and populate it with the supplied parameters. MFProto::VenueIDMFProto::SecurityIDUnique identifier for Order as assigned by the buy-side. A string up to 32 characters long which is null-terminated unless the length is 32 (in which case, no null-termination necessary). ClOrdID of the order to cancel. A string up to 32 characters long which is null-terminated unless the length is 32 (in which case, no null-termination necessary). MFProto::OrderID
Definition: MFTradingSession.cpp:245
void logoutResponse()
The response to a logout from the server. This should be called if a logout is received so that the c...
Definition: MFTradingSession.cpp:135
void logon()
Sends a logon message with the supplied username and password. Should only be called in the event loo...
Definition: MFTradingSession.cpp:101
uint64_t getSendingTime() const
Retrieve the sending time of the current frame.
Definition: MFTradingSession.h:103
void logout()
Initiates logout. This should be called so a clean and dirty (one where the socket closes w/o a logou...
Definition: MFTradingSession.cpp:120
void marketDefinitionRequest()
A request to receive the definitions of each market.
Definition: MFTradingSession.cpp:140
Definition: SessionState.h:37
MFProtoOutputBuffer & buf()
Return a reference to the buffer where the object payload is stored.
Definition: MFProtoMsgWrapper.h:34