com.lmax.api
Interface Session


public interface Session

The main interface for interacting with an LMAX session. Sessions are thread safe, so after a successful login the session object can be passed onto different threads. The only restriction is that start() can not be called more than twice. The implementation enforces this by throwing an IllegalStateException if start is called multiple times without stop being called in between.


Method Summary
 void amendStops(AmendStopsRequest amendStopLossProfitRequest, OrderCallback orderResponseCallback)
          Amend the stop loss and/or profit on an existing order.
 void cancelOrder(CancelOrderRequest cancelOrderRequest, OrderCallback orderResponseCallback)
          Cancel a limit order.
 AccountDetails getAccountDetails()
          Get the account details for the user logged in this session.
 boolean isRunning()
          Determine if the session is currently listening to events from the exchange.
 void logout(Callback callback)
          logout from the exchange.
 void openUrl(java.net.URL url, UrlCallback urlCallback)
          Open a data url from the Lmax Trader platform.
 void placeClosingOrder(ClosingOrderSpecification closingOrderSpecification, OrderCallback orderResponseCallback)
          Close the specified quantity on an instrument position.
 void placeLimitOrder(LimitOrderSpecification limitOrderSpecification, OrderCallback orderResponseCallback)
          Place a limit order onto the exchange.
 void placeMarketOrder(MarketOrderSpecification marketOrderSpecification, OrderCallback orderResponseCallback)
          Place a market order onto the exchange.
 void registerAccountStateEventListener(AccountStateEventListener accountStateEventListener)
          Register for account state events.
 void registerExecutionEventListener(ExecutionEventListener executionListener)
          Register for notification of the execution of your orders.
 void registerHeartbeatListener(HeartbeatEventListener heartbeatEventListener)
          Register a listener for heartbeats on the event stream.
 void registerHistoricMarketDataEventListener(HistoricMarketDataEventListener historicMarketDataEventListener)
          Register for historic market data events.
 void registerInstructionRejectedEventListener(InstructionRejectedEventListener instructionRejectedEventListener)
          Register a listener rejected instructions.
 void registerOrderBookEventListener(OrderBookEventListener orderBookEventListener)
          Register for order book events.
 void registerOrderBookStatusEventListener(OrderBookStatusEventListener eventListener)
          Register for order book status events.
 void registerOrderEventListener(OrderEventListener orderEventListener)
          Register for notification of amendments to the state of your order.
 void registerPositionEventListener(PositionEventListener positionEventListener)
          Register for position events.
 void registerSessionDisconnectedListener(SessionDisconnectedListener sessionDisconnectedListener)
          Register a listener for session disconnected events (when the session has been logged out).
 void registerStreamFailureListener(StreamFailureListener aStreamFailureListener)
          Register a listener for failures on the event stream.
 void requestAccountState(AccountStateRequest accountStateRequest, Callback callback)
          Request an AccountStateEvent from the Lmax Trader platform.
 void requestHeartbeat(HeartbeatRequest heartbeatRequest, HeartbeatCallback heartBeatCallback)
          Request a heartbeat from the Lmax Trader platform.
 void requestHistoricMarketData(HistoricMarketDataRequest historicMarketDataRequest, Callback callback)
          Request historic market data from the Lmax Trader platform.
 void searchInstruments(SearchInstrumentRequest searchRequest, SearchInstrumentCallback searchCallback)
          Request the instruments.
 void setEventStreamDebug(java.io.Writer writer)
          Set the write to push all of XML received by the event stream.
 void start()
          Start listening to events from the exchange.
 void stop()
          Stop listening to events from the exchange.
 void subscribe(SubscriptionRequest subscriptionRequest, Callback callback)
          Place a request to subscribe to events.
 

Method Detail

start

void start()
Start listening to events from the exchange.

Will throw an IllegalStateException if called twice without stop being called.


stop

void stop()
Stop listening to events from the exchange.


isRunning

boolean isRunning()
Determine if the session is currently listening to events from the exchange.

Returns:
true if listening to events from the exchange.

logout

void logout(Callback callback)
logout from the exchange. You should stop listening to events first.

Parameters:
callback - call back to listen to logout events

placeMarketOrder

void placeMarketOrder(MarketOrderSpecification marketOrderSpecification,
                      OrderCallback orderResponseCallback)
Place a market order onto the exchange.

Parameters:
marketOrderSpecification - The order request to place, should contain the instrumentId, quantity and time in force policy.
orderResponseCallback - Callback to handle acknowledgement that the request has been received by LMAX.

placeLimitOrder

void placeLimitOrder(LimitOrderSpecification limitOrderSpecification,
                     OrderCallback orderResponseCallback)
Place a limit order onto the exchange.

Parameters:
limitOrderSpecification - The order request to place, should contain the instrumentId, price, quantity and time in force policy.
orderResponseCallback - Callback to handle acknowledgement that the request has been received by the LMAX.

cancelOrder

void cancelOrder(CancelOrderRequest cancelOrderRequest,
                 OrderCallback orderResponseCallback)
Cancel a limit order.

Parameters:
cancelOrderRequest - The cancel request to place, should contain the instrumentId and the instructionId of the original order.
orderResponseCallback - Callback to handle acknowledgement that the cancel request has been received by the LMAX.

placeClosingOrder

void placeClosingOrder(ClosingOrderSpecification closingOrderSpecification,
                       OrderCallback orderResponseCallback)
Close the specified quantity on an instrument position.

Parameters:
closingOrderSpecification - The specification containing the details of which position to close and for what quantity
orderResponseCallback - Callback to handle acknowledgement that the cancel request has been received by the LMAX.

amendStops

void amendStops(AmendStopsRequest amendStopLossProfitRequest,
                OrderCallback orderResponseCallback)
Amend the stop loss and/or profit on an existing order.

Parameters:
amendStopLossProfitRequest - An amend order request containing a reference to the original order and the new stop loss/profit offsets
orderResponseCallback - Callback to handle acknowledgement that the amend request has been received by the LMAX.

subscribe

void subscribe(SubscriptionRequest subscriptionRequest,
               Callback callback)
Place a request to subscribe to events.

This method will invoke the success callback when the subscription request completes. It will invoke the failure callback when the response contains errors.

Parameters:
subscriptionRequest - The details of the order books to subscribe to in this request.
callback - A callback to be invoked with the outcome of the request.

registerAccountStateEventListener

void registerAccountStateEventListener(AccountStateEventListener accountStateEventListener)
Register for account state events.

Parameters:
accountStateEventListener - The listener for account state events.

registerExecutionEventListener

void registerExecutionEventListener(ExecutionEventListener executionListener)
Register for notification of the execution of your orders.

Events for ALL order you have placed will be delivered to this listener.

Parameters:
executionListener - The listener for ALL executions of your orders.

registerHeartbeatListener

void registerHeartbeatListener(HeartbeatEventListener heartbeatEventListener)
Register a listener for heartbeats on the event stream.

Parameters:
heartbeatEventListener - The listener to notify when heartbeats arrive on the event stream.

registerHistoricMarketDataEventListener

void registerHistoricMarketDataEventListener(HistoricMarketDataEventListener historicMarketDataEventListener)
Register for historic market data events.

Parameters:
historicMarketDataEventListener - The listener for historic market data events.

registerInstructionRejectedEventListener

void registerInstructionRejectedEventListener(InstructionRejectedEventListener instructionRejectedEventListener)
Register a listener rejected instructions.

Parameters:
instructionRejectedEventListener - the listener to notify when instructions are rejected.

registerOrderBookEventListener

void registerOrderBookEventListener(OrderBookEventListener orderBookEventListener)
Register for order book events.

Events for ALL order books you subscribe to will be delivered to this listener.

Parameters:
orderBookEventListener - The listener for ALL order book events.

registerOrderBookStatusEventListener

void registerOrderBookStatusEventListener(OrderBookStatusEventListener eventListener)
Register for order book status events.

Events for ALL order books you subscribe to will be delivered to this listener.

Parameters:
eventListener - The listener for ALL order book status events.

registerOrderEventListener

void registerOrderEventListener(OrderEventListener orderEventListener)
Register for notification of amendments to the state of your order.

Events for ALL orders you have placed will be delivered to this listener.

Parameters:
orderEventListener - The listener for ALL amendments to the state of your orders.

registerPositionEventListener

void registerPositionEventListener(PositionEventListener positionEventListener)
Register for position events.

Events for ALL positions you subscribe to will be delivered to this listener.

Parameters:
positionEventListener - The listener for ALL position events.

registerStreamFailureListener

void registerStreamFailureListener(StreamFailureListener aStreamFailureListener)
Register a listener for failures on the event stream.

Parameters:
aStreamFailureListener - the listener to notify when there are problems on the event stream.
See Also:
StreamFailureListener

registerSessionDisconnectedListener

void registerSessionDisconnectedListener(SessionDisconnectedListener sessionDisconnectedListener)
Register a listener for session disconnected events (when the session has been logged out).

Parameters:
sessionDisconnectedListener - the listener to notify if the session has been disconnected.
See Also:
SessionDisconnectedListener

getAccountDetails

AccountDetails getAccountDetails()
Get the account details for the user logged in this session.

Returns:
The account details

requestAccountState

void requestAccountState(AccountStateRequest accountStateRequest,
                         Callback callback)
Request an AccountStateEvent from the Lmax Trader platform. This will push an AccountStateEvent out via the stream interface.

Parameters:
accountStateRequest - The request to send.
callback - Callback fired to indicate if the request has succeeded or failed.

requestHistoricMarketData

void requestHistoricMarketData(HistoricMarketDataRequest historicMarketDataRequest,
                               Callback callback)
Request historic market data from the Lmax Trader platform. This will push an HistoricMarketDataEvent out via the stream interface.

Parameters:
historicMarketDataRequest - The request to send.
callback - Callback fired to indicate if the request has succeeded or failed.

requestHeartbeat

void requestHeartbeat(HeartbeatRequest heartbeatRequest,
                      HeartbeatCallback heartBeatCallback)
Request a heartbeat from the Lmax Trader platform. This will push a heartbeat event out via the stream interface.

Parameters:
heartbeatRequest - The request to send.
heartBeatCallback - Callback fired to indicate if the request has succeeded or failed.

searchInstruments

void searchInstruments(SearchInstrumentRequest searchRequest,
                       SearchInstrumentCallback searchCallback)
Request the instruments. The instruments will not returned in this call, but will cause the system to generate an asynchronous event(s) containing the information. Instrument information is paged, on the callback will be a boolean value indicating if there are any more values to be received. The last instrumentId should be used as the offsetInstrumentId on the subsequent request. The results will be returned ordered by instrument name.

Parameters:
searchRequest - The request for instruments.
searchCallback - Will be called if the request succeeds.

openUrl

void openUrl(java.net.URL url,
             UrlCallback urlCallback)
Open a data url from the Lmax Trader platform.

Parameters:
url - The url of the file to open.
urlCallback - Callback fired to indicate if the request has succeeded or failed.

setEventStreamDebug

void setEventStreamDebug(java.io.Writer writer)
Set the write to push all of XML received by the event stream.

Parameters:
writer - The writer to push data too.