Page History
| Warning |
|---|
The trading interface of the Classic 3.14.0 SBE protocol should not be used. It is best practice to use Classic MFAPI for trading. |
First, use the MFFactory class to create an MFClient instance.
Second, create an instance of your application's trading handler (which implements the MFTradingHandler interface).
Third, use the factory method .newTcpTradingSession() on the MFClient instance to create the trading session object, passing in your application's trading handler. This returns an instance of MFTradingSession, which connects to MarketFactory via TCP.
At this point, the dispatch of events to handlers may be started by calling .run() on the client.
| Code Block | ||||
|---|---|---|---|---|
| ||||
final MFClient client = MFFactory.createMFClient(); |
...
final MyTradingHandler handler = new MyTradingHandler(client); |
...
MFTradingSession session = client.newTcpTradingSession(handler, USERNAME, PASSWORD, HOSTNAME, PORT, true); |
...
client.run(); |
...
|
Calling newTcpTradingSession() above does not connect and logon the session. Once client.run() is called, and the session starts the first handler function to be called is onStart(). The onStart() handler function is responsible for calling the .logon() method on the session object.
| Info | ||
|---|---|---|
| ||
Note that the MFTradingSession object is used for all venues – all but one of the methods on it include |
...
a venueID argument. |
| Code Block | ||||
|---|---|---|---|---|
| ||||
@Override public void onStart(final MFTradingSession session) { |
...
try { |
...
session.logon(); |
...
} catch (MFException e) { System.out.println("Failed to logon."); e.printStackTrace(); |
...
System.exit(-1); |
...
} |
...
} |
The call to session.logon() will, in the of a successful logon, the on(LogonResponse logonResponse, MFTradingSession session) callback will be called.
...