com.dxfeed.model.market
Class OrderBookModel

java.lang.Object
  extended by com.dxfeed.model.market.OrderBookModel

public class OrderBookModel
extends Object

Model for convenient Order Book management.

Sample usage

The following code prints bid orders for "AAPL" to console whenever the book is updated:

 DXFeed feed = ...;
 OrderBookModel model = new OrderBookModel();
 model.setFilter(OrderBookModelFilter.ALL);
 model.setSymbol("GOOG");
 model.getBuyOrders().addListener(new ObservableListModelListener() {
     public void modelChanged(Change<? extends Order> change) {
         for (Order order : change.getSource())
             System.out.println(order);
         System.out.println();
     }
 });
 model.attach(feed);
 

Threads and locks

This class is not tread-safe and requires external synchronization. You must query the state of attached model only from inside of the notification invocations or from within the thread that performs those notifications.

Listeners are invoked in the context of the corresponding DXEndpoint executor and the corresponding notification is guaranteed to never be concurrent, even though it may happen from different threads if executor is multi-threaded.


Constructor Summary
OrderBookModel()
          Creates new model.
 
Method Summary
 void attach(DXFeed feed)
          Attaches model to the specified feed.
 void detach(DXFeed feed)
          Detaches model from the specified feed.
 ObservableListModel<Order> getBuyOrders()
          Returns bid side (buy orders) of the order book.
 OrderBookModelFilter getFilter()
          Returns filter for the model.
 int getLotSize()
          Returns lot size.
 ObservableListModel<Order> getSellOrders()
          Returns offer side (sell orders) of the order book.
 String getSymbol()
          Returns order book symbol, or null for empty subscription.
 void setFilter(OrderBookModelFilter filter)
          Sets the specified filter to the model.
 void setLotSize(int lotSize)
          Sets the lot size.
 void setSymbol(String symbol)
          Sets symbol for the order book to subscribe for.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderBookModel

public OrderBookModel()
Creates new model. This model is not attached to any feed, not subscribed to any symbol, and has filter set by default to OrderBookModelFilter.ALL.

Method Detail

getFilter

public OrderBookModelFilter getFilter()
Returns filter for the model. This filter specifies which order events are shown in the book.

Returns:
model filter.
See Also:
OrderBookModelFilter

setFilter

public void setFilter(OrderBookModelFilter filter)
Sets the specified filter to the model.

Implementation notes

Parameters:
filter - model filter

getSymbol

public String getSymbol()
Returns order book symbol, or null for empty subscription.

Returns:
order book symbol.

setSymbol

public void setSymbol(String symbol)
Sets symbol for the order book to subscribe for.

Parameters:
symbol - order book symbol.

getLotSize

public int getLotSize()
Returns lot size. Lot size is a multiplier applied to COMPOSITE, REGIONAL, and AGGREGATE level orders.

Returns:
lot size

setLotSize

public void setLotSize(int lotSize)
Sets the lot size.

Parameters:
lotSize - lot size multiplier
See Also:
getLotSize()

getBuyOrders

public ObservableListModel<Order> getBuyOrders()
Returns bid side (buy orders) of the order book.

Returns:
bid side of the order book

getSellOrders

public ObservableListModel<Order> getSellOrders()
Returns offer side (sell orders) of the order book.

Returns:
offer side of the order book.

attach

public void attach(DXFeed feed)
Attaches model to the specified feed.

Parameters:
feed - feed to attach to.

detach

public void detach(DXFeed feed)
Detaches model from the specified feed.

Parameters:
feed - feed to detach from.


Copyright © 2013 Devexperts. All Rights Reserved.