MFClient  1.3.0
 All Classes Functions Variables Enumerations
MFClient.h
1 /*
2  * Copyright (C) 2017 MarketFactory, Inc. All rights reserved.
3  * Use in source and binary forms, with or without modification, is permitted
4  * provided that the following conditions are met:
5  * 1. You may only use this software for internal evaluation and testing
6  * purposes and may not use the software for engaging
7  * in live trades, unless and until you have entered into a separate agreement
8  * with MarketFactory governing the use of
9  * MarketFactory software in a production environment.
10  * 2. You may not distribute the software (in either source or binary forms) to
11  * third parties.
12  * 3. All copies of source code must retain the above copyright notice, this
13  * list of conditions and the following disclaimer.
14  * THIS SOFTWARE IS PROVIDED BY MARKETFACTORY AND ITS LICENSORS "AS IS" AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
16  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
17  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18  * NO EVENT SHALL MARKETFACTORY OR ITS LICENSORS BE LIABLE FOR ANY DIRECT,
19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23  * LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 #ifndef _MF_MFCLIENT_H
29 #define _MF_MFCLIENT_H
30 
31 #include <MFTradingSession.h>
32 #include <MFStpBookingSession.h>
33 #include <MFMarketDataSession.h>
34 #include <MFTradeDateRollOverSession.h>
35 
36 #include <MFProto.h>
37 
38 #include <EASTL/vector_map.h>
39 
40 #include <boost/asio.hpp>
41 #include <boost/noncopyable.hpp>
42 
43 #include <string>
44 
45 class MFTradingHandler;
49 
50 //-------------------------------------------------------------------------------------------
83 class MFClient : private boost::noncopyable {
84  public:
88  static const uint16_t AUTO_CALCULATE_PORT_VALUE = 0;
89 
96  MFClient();
97 
106  MFClient(uint16_t baseport);
107  ~MFClient();
108 
120  size_t run();
121 
128  void stop();
129 
141  size_t runStpBooking();
142 
149  void stopStpBooking();
150 
162  size_t runTradeDateRollOver();
163 
170  void stopTradeDateRollOver();
171 
189  (
190  MFTradingHandler& handler,
191  const std::string& username,
192  const std::string& password,
193  const std::string& hostname,
194  uint16_t port,
195  bool relogonOnDisconnect
196  );
197 
215  (
216  MFStpBookingHandler& handler,
217  const std::string& username,
218  const std::string& password,
219  const std::string& hostname,
220  uint16_t port,
221  bool relogonOnDisconnect
222  );
223 
242  (
243  MFTradeDateRollOverHandler& handler,
244  const std::string& username,
245  const std::string& password,
246  const std::string& hostname,
247  MFProto::VenueID venueID,
248  uint16_t port,
249  bool relogonOnDisconnect
250  );
251 
273  (
274  MFMarketDataHandler& handler,
275  const std::string& venueName,
276  MFProto::VenueID venueID,
277  const std::string& username,
278  const std::string& password,
279  const std::string& hostname,
280  uint16_t port,
281  bool relogonOnDisconnect
282  );
283 
289  bool isMarketDataSessionRegistered(MFProto::VenueID venueID);
290 
291  private:
292  void onTimer(const boost::system::error_code& ec);
293 
294  typedef eastl::vector_map<MFProto::VenueID, MFMarketDataSession*>
295  MarketDataSessionMap;
296 
297  std::auto_ptr<MFTradingSession> _tradingSession;
298  std::auto_ptr<MFStpBookingSession> _stpBookingSession;
299  std::auto_ptr <MFTradeDateRollOverSession> _tradeDateRollOverSession;
300 
301  MarketDataSessionMap _marketDataSessions;
302  boost::asio::io_service _ioService;
303  uint16_t _baseport;
304  bool _isRunning;
305  boost::asio::deadline_timer _timer;
306 };
307 
308 #endif
MFStpBookingSession * newTcpStpBookingSession(MFStpBookingHandler &handler, const std::string &username, const std::string &password, const std::string &hostname, uint16_t port, bool relogonOnDisconnect)
Creates a session for connecting to the stp booking gateway over TCP. If the MFClient(uint16_t base...
Definition: MFClient.cpp:185
MFTradingSession * newTcpTradingSession(MFTradingHandler &handler, const std::string &username, const std::string &password, const std::string &hostname, uint16_t port, bool relogonOnDisconnect)
Creates a session for connecting to the trading gateway over TCP. If the MFClient(uint16_t baseport...
Definition: MFClient.cpp:159
Applications implement this interface in order to process marketdata messages from a MFMarketDataSess...
Definition: MFMarketDataHandler.h:49
Applications implement this interface in order to process events from a MFStpBookingSession ...
Definition: MFStpBookingHandler.h:51
Applications implement this interface in order to process events from a MFTradeRollOverDateSession ...
Definition: MFTradeDateRollOverHandler.h:48
bool isMarketDataSessionRegistered(MFProto::VenueID venueID)
Returns whether or not there is a registered market data session for a venueID. MFProto::VenueID
Definition: MFClient.cpp:272
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
MFMarketDataSession * newTcpMarketDataSession(MFMarketDataHandler &handler, const std::string &venueName, MFProto::VenueID venueID, const std::string &username, const std::string &password, const std::string &hostname, uint16_t port, bool relogonOnDisconnect)
Creates a session for connecting to a particular venue gateway over TCP. If the MFClient(uint16_t b...
Definition: MFClient.cpp:239
size_t run()
Runs the event loop. This will trigger the onStart method on any registered handlers. Runs the event loop. This will trigger the onStart method on any registered handlers. If this loop ends by the user calling MFClient::stop(), the MFClient is dead and cannot be reused.
Definition: MFClient.cpp:83
void stop()
Stops the event loop and closes open sockets. Signals onStop in all registered handlers. This can be called from an external thread or internally from a handler.
Definition: MFClient.cpp:97
MFClient()
Initialize MFClient with no baseport. You must provide a port to the trading session with a MFClient:...
Definition: MFClient.cpp:44
A session with MarketFactory for trading with all the venues for which a user has access...
Definition: MFTradingSession.h:69
void stopStpBooking()
Stops the StpBooking event loop and closes open sockets. Signals onStop in all registered handlers...
Definition: MFClient.cpp:121
MFTradeDateRollOverSession * newTcpTradeDateRollOverSession(MFTradeDateRollOverHandler &handler, const std::string &username, const std::string &password, const std::string &hostname, MFProto::VenueID venueID, uint16_t port, bool relogonOnDisconnect)
Creates a session for connecting to the trade date roll over gateway over TCP. If the MFClient(uint...
Definition: MFClient.cpp:214
A session used to interact with a single venue for market data.
Definition: MFMarketDataSession.h:60
A session with MarketFactory for trading with all the venues for which a user has access...
Definition: MFStpBookingSession.h:69
size_t runTradeDateRollOver()
Runs the TradeDateRollOver event loop. This will trigger the onStart method on any registered handler...
Definition: MFClient.cpp:132
static const uint16_t AUTO_CALCULATE_PORT_VALUE
Definition: MFClient.h:88
void stopTradeDateRollOver()
Stops the TradeDateRollOver event loop and closes open sockets. Signals onStop in all registered hand...
Definition: MFClient.cpp:144
size_t runStpBooking()
Runs the StpBooking event loop. This will trigger the onStart method on any registered handlers...
Definition: MFClient.cpp:109
A session with MarketFactory for trading with all the venues for which a user has access...
Definition: MFTradeDateRollOverSession.h:65